Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
MR414N-ID
GitHub Repository: MR414N-ID/botku2
Path: blob/master/node_modules/@jimp/plugin-dither/dist/index.js
1126 views
1
"use strict";
2
3
Object.defineProperty(exports, "__esModule", {
4
value: true
5
});
6
exports["default"] = void 0;
7
8
var _utils = require("@jimp/utils");
9
10
/**
11
* Apply a ordered dithering effect
12
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
13
* @returns {Jimp} this for chaining of methods
14
*/
15
function dither(cb) {
16
var rgb565Matrix = [1, 9, 3, 11, 13, 5, 15, 7, 4, 12, 2, 10, 16, 8, 14, 6];
17
this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, function (x, y, idx) {
18
var thresholdId = ((y & 3) << 2) + x % 4;
19
var dither = rgb565Matrix[thresholdId];
20
this.bitmap.data[idx] = Math.min(this.bitmap.data[idx] + dither, 0xff);
21
this.bitmap.data[idx + 1] = Math.min(this.bitmap.data[idx + 1] + dither, 0xff);
22
this.bitmap.data[idx + 2] = Math.min(this.bitmap.data[idx + 2] + dither, 0xff);
23
});
24
25
if ((0, _utils.isNodePattern)(cb)) {
26
cb.call(this, null, this);
27
}
28
29
return this;
30
}
31
32
var _default = function _default() {
33
return {
34
dither565: dither,
35
dither16: dither
36
};
37
};
38
39
exports["default"] = _default;
40
module.exports = exports.default;
41
//# sourceMappingURL=index.js.map
42