Path: blob/master/node_modules/@jimp/plugin-dither/es/index.js
1126 views
"use strict";12Object.defineProperty(exports, "__esModule", {3value: true4});5exports["default"] = void 0;67var _utils = require("@jimp/utils");89/**10* Apply a ordered dithering effect11* @param {function(Error, Jimp)} cb (optional) a callback for when complete12* @returns {Jimp} this for chaining of methods13*/14function dither(cb) {15var rgb565Matrix = [1, 9, 3, 11, 13, 5, 15, 7, 4, 12, 2, 10, 16, 8, 14, 6];16this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, function (x, y, idx) {17var thresholdId = ((y & 3) << 2) + x % 4;18var dither = rgb565Matrix[thresholdId];19this.bitmap.data[idx] = Math.min(this.bitmap.data[idx] + dither, 0xff);20this.bitmap.data[idx + 1] = Math.min(this.bitmap.data[idx + 1] + dither, 0xff);21this.bitmap.data[idx + 2] = Math.min(this.bitmap.data[idx + 2] + dither, 0xff);22});2324if ((0, _utils.isNodePattern)(cb)) {25cb.call(this, null, this);26}2728return this;29}3031var _default = function _default() {32return {33dither565: dither,34dither16: dither35};36};3738exports["default"] = _default;39//# sourceMappingURL=index.js.map4041