This commit is contained in:
Yamozha
2021-04-02 02:24:13 +03:00
parent c23950b545
commit 7256d79e2c
31493 changed files with 3036630 additions and 0 deletions

67
node_modules/@jimp/plugin-threshold/dist/index.js generated vendored Normal file
View File

@ -0,0 +1,67 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _utils = require("@jimp/utils");
/**
* Applies a minimum color threshold to a greyscale image. Converts image to greyscale by default
* @param {number} options object
* max: A number auto limited between 0 - 255
* replace: (optional) A number auto limited between 0 - 255 (default 255)
* autoGreyscale: (optional) A boolean whether to apply greyscale beforehand (default true)
* @param {number} cb (optional) a callback for when complete
* @return {this} this for chaining of methods
*/
var _default = function _default() {
return {
threshold: function threshold(_ref, cb) {
var _this = this;
var max = _ref.max,
_ref$replace = _ref.replace,
replace = _ref$replace === void 0 ? 255 : _ref$replace,
_ref$autoGreyscale = _ref.autoGreyscale,
autoGreyscale = _ref$autoGreyscale === void 0 ? true : _ref$autoGreyscale;
if (typeof max !== 'number') {
return _utils.throwError.call(this, 'max must be a number', cb);
}
if (typeof replace !== 'number') {
return _utils.throwError.call(this, 'replace must be a number', cb);
}
if (typeof autoGreyscale !== 'boolean') {
return _utils.throwError.call(this, 'autoGreyscale must be a boolean', cb);
}
max = this.constructor.limit255(max);
replace = this.constructor.limit255(replace);
if (autoGreyscale) {
this.greyscale();
}
this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, function (x, y, idx) {
var grey = _this.bitmap.data[idx] < max ? _this.bitmap.data[idx] : replace;
_this.bitmap.data[idx] = grey;
_this.bitmap.data[idx + 1] = grey;
_this.bitmap.data[idx + 2] = grey;
});
if ((0, _utils.isNodePattern)(cb)) {
cb.call(this, null, this);
}
return this;
}
};
};
exports["default"] = _default;
module.exports = exports.default;
//# sourceMappingURL=index.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../src/index.js"],"names":["threshold","cb","max","replace","autoGreyscale","throwError","call","constructor","limit255","greyscale","scanQuiet","bitmap","width","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AACQ,MAAL,CAAYO,IAAZ,CAAiBF,GAAjB,IAAwBC,IAAxB;AACA,QAAA,KAAI,CAACN,MAAL,CAAYO,IAAZ,CAAiBF,GAAG,GAAG,CAAvB,IAA4BC,IAA5B;AACA,QAAA,KAAI,CAACN,MAAL,CAAYO,IAAZ,CAAiBF,GAAG,GAAG,CAAvB,IAA4BC,IAA5B;AACD,OAPD;;AASA,UAAI,0BAAchB,EAAd,CAAJ,EAAuB;AACrBA,QAAAA,EAAE,CAACK,IAAH,CAAQ,IAAR,EAAc,IAAd,EAAoB,IAApB;AACD;;AAED,aAAO,IAAP;AACD;AAnCmB,GAAP;AAAA,C","sourcesContent":["import { isNodePattern, throwError } from '@jimp/utils';\n\n/**\n * Applies a minimum color threshold to a greyscale image. Converts image to greyscale by default\n * @param {number} options object\n * max: A number auto limited between 0 - 255\n * replace: (optional) A number auto limited between 0 - 255 (default 255)\n * autoGreyscale: (optional) A boolean whether to apply greyscale beforehand (default true)\n * @param {number} cb (optional) a callback for when complete\n * @return {this} this for chaining of methods\n */\nexport default () => ({\n threshold({ max, replace = 255, autoGreyscale = true }, cb) {\n if (typeof max !== 'number') {\n return throwError.call(this, 'max must be a number', cb);\n }\n\n if (typeof replace !== 'number') {\n return throwError.call(this, 'replace must be a number', cb);\n }\n\n if (typeof autoGreyscale !== 'boolean') {\n return throwError.call(this, 'autoGreyscale must be a boolean', cb);\n }\n\n max = this.constructor.limit255(max);\n replace = this.constructor.limit255(replace);\n\n if (autoGreyscale) {\n this.greyscale();\n }\n\n this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, (x, y, idx) => {\n const grey =\n this.bitmap.data[idx] < max ? this.bitmap.data[idx] : replace;\n\n this.bitmap.data[idx] = grey;\n this.bitmap.data[idx + 1] = grey;\n this.bitmap.data[idx + 2] = grey;\n });\n\n if (isNodePattern(cb)) {\n cb.call(this, null, this);\n }\n\n return this;\n }\n});\n"],"file":"index.js"}