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

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

@ -0,0 +1,65 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _utils = require("@jimp/utils");
/**
* Creates a circle out of an image.
* @param {object} options (optional) r: radius of effect
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
* @returns {Jimp} this for chaining of methods
*/
var _default = function _default() {
return {
fisheye: function fisheye() {
var _this = this;
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
r: 2.5
};
var cb = arguments.length > 1 ? arguments[1] : undefined;
if (typeof options === 'function') {
cb = options;
options = {
r: 2.5
};
}
var source = this.cloneQuiet();
var _source$bitmap = source.bitmap,
width = _source$bitmap.width,
height = _source$bitmap.height;
source.scanQuiet(0, 0, width, height, function (x, y) {
var hx = x / width;
var hy = y / height;
var r = Math.sqrt(Math.pow(hx - 0.5, 2) + Math.pow(hy - 0.5, 2));
var rn = 2 * Math.pow(r, options.r);
var cosA = (hx - 0.5) / r;
var sinA = (hy - 0.5) / r;
var newX = Math.round((rn * cosA + 0.5) * width);
var newY = Math.round((rn * sinA + 0.5) * height);
var color = source.getPixelColor(newX, newY);
_this.setPixelColor(color, x, y);
});
/* Set center pixel color, otherwise it will be transparent */
this.setPixelColor(source.getPixelColor(width / 2, height / 2), width / 2, height / 2);
if ((0, _utils.isNodePattern)(cb)) {
cb.call(this, null, this);
}
return this;
}
};
};
exports["default"] = _default;
module.exports = exports.default;
//# sourceMappingURL=index.js.map

1
node_modules/@jimp/plugin-fisheye/dist/index.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":["../src/index.js"],"names":["fisheye","options","r","cb","source","cloneQuiet","bitmap","width","height","scanQuiet","x","y","hx","hy","Math","sqrt","pow","rn","cosA","sinA","newX","round","newY","color","getPixelColor","setPixelColor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e,IAAI,GAAGR,IAAI,CAACO,KAAL,CAAW,CAACJ,EAAE,GAAGE,IAAL,GAAY,GAAb,IAAoBX,MAA/B,CAAb;AACA,YAAMe,KAAK,GAAGnB,MAAM,CAACoB,aAAP,CAAqBJ,IAArB,EAA2BE,IAA3B,CAAd;;AAEA,QAAA,KAAI,CAACG,aAAL,CAAmBF,KAAnB,EAA0Bb,CAA1B,EAA6BC,CAA7B;AACD,OAZD;AAcA;;AACA,WAAKc,aAAL,CACErB,MAAM,CAACoB,aAAP,CAAqBjB,KAAK,GAAG,CAA7B,EAAgCC,MAAM,GAAG,CAAzC,CADF,EAEED,KAAK,GAAG,CAFV,EAGEC,MAAM,GAAG,CAHX;;AAMA,UAAI,0BAAcL,EAAd,CAAJ,EAAuB;AACrBA,QAAAA,EAAE,CAACuB,IAAH,CAAQ,IAAR,EAAc,IAAd,EAAoB,IAApB;AACD;;AAED,aAAO,IAAP;AACD;AApCmB,GAAP;AAAA,C","sourcesContent":["import { isNodePattern } from '@jimp/utils';\n\n/**\n * Creates a circle out of an image.\n * @param {object} options (optional) r: radius of effect\n * @param {function(Error, Jimp)} cb (optional) a callback for when complete\n * @returns {Jimp} this for chaining of methods\n */\nexport default () => ({\n fisheye(options = { r: 2.5 }, cb) {\n if (typeof options === 'function') {\n cb = options;\n options = { r: 2.5 };\n }\n\n const source = this.cloneQuiet();\n const { width, height } = source.bitmap;\n\n source.scanQuiet(0, 0, width, height, (x, y) => {\n const hx = x / width;\n const hy = y / height;\n const r = Math.sqrt(Math.pow(hx - 0.5, 2) + Math.pow(hy - 0.5, 2));\n const rn = 2 * Math.pow(r, options.r);\n const cosA = (hx - 0.5) / r;\n const sinA = (hy - 0.5) / r;\n const newX = Math.round((rn * cosA + 0.5) * width);\n const newY = Math.round((rn * sinA + 0.5) * height);\n const color = source.getPixelColor(newX, newY);\n\n this.setPixelColor(color, x, y);\n });\n\n /* Set center pixel color, otherwise it will be transparent */\n this.setPixelColor(\n source.getPixelColor(width / 2, height / 2),\n width / 2,\n height / 2\n );\n\n if (isNodePattern(cb)) {\n cb.call(this, null, this);\n }\n\n return this;\n }\n});\n"],"file":"index.js"}