chore: add jimp dependency, icon padding script, and update configuration

This commit is contained in:
2026-05-31 14:04:37 +02:00
parent 30f81045ac
commit 7cd17307ba
1126 changed files with 166400 additions and 2 deletions
+36
View File
@@ -0,0 +1,36 @@
import { isNodePattern } from "@jimp/utils";
/**
* Creates a circle out of an image.
* @param {function(Error, Jimp)} options (optional) radius, x, y
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
* @returns {Jimp} this for chaining of methods
*/
export default (() => ({
circle() {
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
let cb = arguments.length > 1 ? arguments[1] : undefined;
if (typeof options === "function") {
cb = options;
options = {};
}
const radius = options.radius || (this.bitmap.width > this.bitmap.height ? this.bitmap.height : this.bitmap.width) / 2;
const center = {
x: typeof options.x === "number" ? options.x : this.bitmap.width / 2,
y: typeof options.y === "number" ? options.y : this.bitmap.height / 2
};
this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, function (x, y, idx) {
const curR = Math.sqrt(Math.pow(x - center.x, 2) + Math.pow(y - center.y, 2));
if (radius - curR <= 0.0) {
this.bitmap.data[idx + 3] = 0;
} else if (radius - curR < 1.0) {
this.bitmap.data[idx + 3] = 255 * (radius - curR);
}
});
if (isNodePattern(cb)) {
cb.call(this, null, this);
}
return this;
}
}));
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","names":["isNodePattern","circle","options","cb","radius","bitmap","width","height","center","x","y","scanQuiet","idx","curR","Math","sqrt","pow","data","call"],"sources":["../src/index.js"],"sourcesContent":["import { isNodePattern } from \"@jimp/utils\";\n\n/**\n * Creates a circle out of an image.\n * @param {function(Error, Jimp)} options (optional) radius, x, y\n * @param {function(Error, Jimp)} cb (optional) a callback for when complete\n * @returns {Jimp} this for chaining of methods\n */\nexport default () => ({\n circle(options = {}, cb) {\n if (typeof options === \"function\") {\n cb = options;\n options = {};\n }\n\n const radius =\n options.radius ||\n (this.bitmap.width > this.bitmap.height\n ? this.bitmap.height\n : this.bitmap.width) / 2;\n\n const center = {\n x: typeof options.x === \"number\" ? options.x : this.bitmap.width / 2,\n y: typeof options.y === \"number\" ? options.y : this.bitmap.height / 2,\n };\n\n this.scanQuiet(\n 0,\n 0,\n this.bitmap.width,\n this.bitmap.height,\n function (x, y, idx) {\n const curR = Math.sqrt(\n Math.pow(x - center.x, 2) + Math.pow(y - center.y, 2)\n );\n\n if (radius - curR <= 0.0) {\n this.bitmap.data[idx + 3] = 0;\n } else if (radius - curR < 1.0) {\n this.bitmap.data[idx + 3] = 255 * (radius - curR);\n }\n }\n );\n\n if (isNodePattern(cb)) {\n cb.call(this, null, this);\n }\n\n return this;\n },\n});\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,aAAa;;AAE3C;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;EACpBC,MAAM,GAAmB;IAAA,IAAlBC,OAAO,uEAAG,CAAC,CAAC;IAAA,IAAEC,EAAE;IACrB,IAAI,OAAOD,OAAO,KAAK,UAAU,EAAE;MACjCC,EAAE,GAAGD,OAAO;MACZA,OAAO,GAAG,CAAC,CAAC;IACd;IAEA,MAAME,MAAM,GACVF,OAAO,CAACE,MAAM,IACd,CAAC,IAAI,CAACC,MAAM,CAACC,KAAK,GAAG,IAAI,CAACD,MAAM,CAACE,MAAM,GACnC,IAAI,CAACF,MAAM,CAACE,MAAM,GAClB,IAAI,CAACF,MAAM,CAACC,KAAK,IAAI,CAAC;IAE5B,MAAME,MAAM,GAAG;MACbC,CAAC,EAAE,OAAOP,OAAO,CAACO,CAAC,KAAK,QAAQ,GAAGP,OAAO,CAACO,CAAC,GAAG,IAAI,CAACJ,MAAM,CAACC,KAAK,GAAG,CAAC;MACpEI,CAAC,EAAE,OAAOR,OAAO,CAACQ,CAAC,KAAK,QAAQ,GAAGR,OAAO,CAACQ,CAAC,GAAG,IAAI,CAACL,MAAM,CAACE,MAAM,GAAG;IACtE,CAAC;IAED,IAAI,CAACI,SAAS,CACZ,CAAC,EACD,CAA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