Initial commit
This commit is contained in:
commit
e49726988c
5445 files changed
+1089914
No files matched your search
+8
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "../src",
|
||||
"module": "nodenext",
|
||||
"moduleResolution": "nodenext"
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"extends": "./build.json",
|
||||
"include": [
|
||||
"../src/**/*.ts",
|
||||
"../src/**/*.cts",
|
||||
"../src/**/*.tsx",
|
||||
"../src/**/*.json"
|
||||
],
|
||||
"exclude": [
|
||||
"../**/*.test.ts",
|
||||
"../src/**/*.mts",
|
||||
"../src/package.json"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"outDir": "../.tshy-build/commonjs"
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"extends": "./build.json",
|
||||
"include": [
|
||||
"../src/**/*.ts",
|
||||
"../src/**/*.mts",
|
||||
"../src/**/*.tsx",
|
||||
"../src/**/*.json"
|
||||
],
|
||||
"exclude": [
|
||||
"../**/*.test.ts",
|
||||
"../src/package.json"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"outDir": "../.tshy-build/esm"
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
|
||||
|
||||
> @jimp/plugin-circle@1.5.0 build /Users/andrewlisowski/Documents/jimp/plugins/plugin-circle
|
||||
> tshy
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
|
||||
|
||||
> @jimp/plugin-circle@1.1.2 lint /Users/andrewlisowski/Documents/jimp/plugins/plugin-circle
|
||||
> eslint .
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
|
||||
|
||||
> @jimp/plugin-circle@1.1.2 test:browser /Users/andrewlisowski/Documents/jimp/plugins/plugin-circle
|
||||
> vitest --config vitest.config.browser.mjs "--watch=false"
|
||||
|
||||
Re-optimizing dependencies because lockfile has changed
|
||||
Port 5173 is in use, trying another one...
|
||||
Port 5174 is in use, trying another one...
|
||||
Port 5175 is in use, trying another one...
|
||||
Port 5176 is in use, trying another one...
|
||||
|
||||
[7m[1m[36m RUN [39m[22m[27m [36mv2.0.5[39m [90m/Users/andrewlisowski/Documents/jimp/plugins/plugin-circle[39m
|
||||
[2m[32m Browser runner started at http://localhost:5177/[39m[22m
|
||||
|
||||
[2m1:39:27 AM[22m [31m[1m[vite][22m[39m [31merror while updating dependencies:
|
||||
Error: The service was stopped
|
||||
at /Users/andrewlisowski/Documents/jimp/node_modules/.pnpm/esbuild@0.21.5/node_modules/esbuild/lib/main.js:993:26
|
||||
at responseCallbacks.<computed> (/Users/andrewlisowski/Documents/jimp/node_modules/.pnpm/esbuild@0.21.5/node_modules/esbuild/lib/main.js:622:9)
|
||||
at Socket.afterClose (/Users/andrewlisowski/Documents/jimp/node_modules/.pnpm/esbuild@0.21.5/node_modules/esbuild/lib/main.js:613:28)
|
||||
at Socket.emit (node:events:529:35)
|
||||
at endReadableNT (node:internal/streams/readable:1400:12)
|
||||
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)[39m
|
||||
[41m[30m ELIFECYCLE [39m[49m [31mCommand failed with exit code 130.[39m
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
|
||||
|
||||
> @jimp/plugin-circle@1.1.2 test /Users/andrewlisowski/Documents/jimp/plugins/plugin-circle
|
||||
> vitest "--watch=false"
|
||||
|
||||
|
||||
[7m[1m[36m RUN [39m[22m[27m [36mv2.0.5[39m [90m/Users/andrewlisowski/Documents/jimp/plugins/plugin-circle[39m
|
||||
|
||||
[?25l [90m·[39m [2msrc/[22mindex[2m.test.ts[22m[2m (3)[22m
|
||||
[90m·[39m Circle[2m (3)[22m
|
||||
[90m·[39m makes a circle based on image height and width
|
||||
[90m·[39m makes a circle using provided radius
|
||||
[90m·[39m should
|
||||
[?25l[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [32m✓[39m [2msrc/[22mindex[2m.test.ts[22m[2m (3)[22m
|
||||
[32m✓[39m Circle[2m (3)[22m
|
||||
[32m✓[39m makes a circle based on image height and width
|
||||
[32m✓[39m makes a circle using provided radius
|
||||
[32m✓[39m should
|
||||
[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [32m✓[39m [2msrc/[22mindex[2m.test.ts[22m[2m (3)[22m
|
||||
[32m✓[39m Circle[2m (3)[22m
|
||||
[32m✓[39m makes a circle based on image height and width
|
||||
[32m✓[39m makes a circle using provided radius
|
||||
[32m✓[39m should
|
||||
|
||||
[2m Test Files [22m [1m[32m1 passed[39m[22m[90m (1)[39m
|
||||
[2m Tests [22m [1m[32m3 passed[39m[22m[90m (3)[39m
|
||||
[2m Start at [22m 01:33:39
|
||||
[2m Duration [22m 2.52s[2m (transform 449ms, setup 0ms, collect 761ms, tests 27ms, environment 0ms, prepare 440ms)[22m
|
||||
|
||||
[?25h[?25h
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
# v1.1.3 (Mon Sep 02 2024)
|
||||
|
||||
#### 🐛 Bug Fix
|
||||
|
||||
- Update deps [#1319](https://github.com/jimp-dev/jimp/pull/1319) ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
#### Authors: 1
|
||||
|
||||
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
---
|
||||
|
||||
# v1.1.0 (Sun Sep 01 2024)
|
||||
|
||||
#### ⚠️ Pushed to `main`
|
||||
|
||||
- upgrade tshy ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
- update more docs ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
#### Authors: 1
|
||||
|
||||
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
---
|
||||
|
||||
# v1.0.3 (Sat Aug 31 2024)
|
||||
|
||||
#### 🐛 Bug Fix
|
||||
|
||||
- Fix build [#1303](https://github.com/jimp-dev/jimp/pull/1303) ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
#### ⚠️ Pushed to `main`
|
||||
|
||||
- add clean script ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
#### Authors: 1
|
||||
|
||||
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
---
|
||||
|
||||
# v1.0.2 (Sat Aug 31 2024)
|
||||
|
||||
#### ⚠️ Pushed to `main`
|
||||
|
||||
- set side effects ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
- fix versions ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
- add publish config ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
#### Authors: 1
|
||||
|
||||
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 Oliver Moran
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
<div align="center">
|
||||
<img width="200" height="200"
|
||||
src="https://s3.amazonaws.com/pix.iemoji.com/images/emoji/apple/ios-11/256/crayon.png">
|
||||
<h1>@jimp/plugin-circle</h1>
|
||||
<p>Creates a circle out of an image.</p>
|
||||
</div>
|
||||
|
||||
- [circle](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#circle)
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
import { JimpClass } from "@jimp/types";
|
||||
import { z } from "zod";
|
||||
declare const CircleOptionsSchema: z.ZodObject<{
|
||||
/** the x position to draw the circle */
|
||||
x: z.ZodOptional<z.ZodNumber>;
|
||||
/** the y position to draw the circle */
|
||||
y: z.ZodOptional<z.ZodNumber>;
|
||||
/** the radius of the circle */
|
||||
radius: z.ZodOptional<z.ZodNumber>;
|
||||
}, "strip", z.ZodTypeAny, {
|
||||
x?: number | undefined;
|
||||
y?: number | undefined;
|
||||
radius?: number | undefined;
|
||||
}, {
|
||||
x?: number | undefined;
|
||||
y?: number | undefined;
|
||||
radius?: number | undefined;
|
||||
}>;
|
||||
export type CircleOptions = z.infer<typeof CircleOptionsSchema>;
|
||||
export declare const methods: {
|
||||
/**
|
||||
* Creates a circle out of an image.
|
||||
* @example
|
||||
* ```ts
|
||||
* import { Jimp } from "jimp";
|
||||
*
|
||||
* const image = await Jimp.read("test/image.png");
|
||||
*
|
||||
* image.circle();
|
||||
* // or
|
||||
* image.circle({ radius: 50, x: 25, y: 25 });
|
||||
* ```
|
||||
*/
|
||||
circle<I extends JimpClass>(image: I, options?: CircleOptions): I;
|
||||
};
|
||||
export {};
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,QAAA,MAAM,mBAAmB;IACvB,wCAAwC;;IAExC,wCAAwC;;IAExC,+BAA+B;;;;;;;;;;EAE/B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,eAAO,MAAM,OAAO;IAClB;;;;;;;;;;;;OAYG;WACI,CAAC,SAAS,SAAS,SAAS,CAAC,YAAW,aAAa;CA2B7D,CAAC"}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.methods = void 0;
|
||||
const zod_1 = require("zod");
|
||||
const CircleOptionsSchema = zod_1.z.object({
|
||||
/** the x position to draw the circle */
|
||||
x: zod_1.z.number().optional(),
|
||||
/** the y position to draw the circle */
|
||||
y: zod_1.z.number().optional(),
|
||||
/** the radius of the circle */
|
||||
radius: zod_1.z.number().min(0).optional(),
|
||||
});
|
||||
exports.methods = {
|
||||
/**
|
||||
* Creates a circle out of an image.
|
||||
* @example
|
||||
* ```ts
|
||||
* import { Jimp } from "jimp";
|
||||
*
|
||||
* const image = await Jimp.read("test/image.png");
|
||||
*
|
||||
* image.circle();
|
||||
* // or
|
||||
* image.circle({ radius: 50, x: 25, y: 25 });
|
||||
* ```
|
||||
*/
|
||||
circle(image, options = {}) {
|
||||
const parsed = CircleOptionsSchema.parse(options);
|
||||
const radius = parsed.radius ||
|
||||
(image.bitmap.width > image.bitmap.height
|
||||
? image.bitmap.height
|
||||
: image.bitmap.width) / 2;
|
||||
const center = {
|
||||
x: typeof parsed.x === "number" ? parsed.x : image.bitmap.width / 2,
|
||||
y: typeof parsed.y === "number" ? parsed.y : image.bitmap.height / 2,
|
||||
};
|
||||
image.scan((x, y, idx) => {
|
||||
const curR = Math.sqrt(Math.pow(x - center.x, 2) + Math.pow(y - center.y, 2));
|
||||
if (radius - curR <= 0.0) {
|
||||
image.bitmap.data[idx + 3] = 0;
|
||||
}
|
||||
else if (radius - curR < 1.0) {
|
||||
image.bitmap.data[idx + 3] = 255 * (radius - curR);
|
||||
}
|
||||
});
|
||||
return image;
|
||||
},
|
||||
};
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AACA,6BAAwB;AAExB,MAAM,mBAAmB,GAAG,OAAC,CAAC,MAAM,CAAC;IACnC,wCAAwC;IACxC,CAAC,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACxB,wCAAwC;IACxC,CAAC,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACxB,+BAA+B;IAC/B,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CACrC,CAAC,CAAC;AAIU,QAAA,OAAO,GAAG;IACrB;;;;;;;;;;;;OAYG;IACH,MAAM,CAAsB,KAAQ,EAAE,UAAyB,EAAE;QAC/D,MAAM,MAAM,GAAG,mBAAmB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAClD,MAAM,MAAM,GACV,MAAM,CAAC,MAAM;YACb,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM;gBACvC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM;gBACrB,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAE9B,MAAM,MAAM,GAAG;YACb,CAAC,EAAE,OAAO,MAAM,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC;YACnE,CAAC,EAAE,OAAO,MAAM,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC;SACrE,CAAC;QAEF,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE;YACvB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CACpB,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CACtD,CAAC;YAEF,IAAI,MAAM,GAAG,IAAI,IAAI,GAAG,EAAE,CAAC;gBACzB,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;YACjC,CAAC;iBAAM,IAAI,MAAM,GAAG,IAAI,GAAG,GAAG,EAAE,CAAC;gBAC/B,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;YACrD,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAC"}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "commonjs"
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
import { JimpClass } from "@jimp/types";
|
||||
import { z } from "zod";
|
||||
declare const CircleOptionsSchema: z.ZodObject<{
|
||||
/** the x position to draw the circle */
|
||||
x: z.ZodOptional<z.ZodNumber>;
|
||||
/** the y position to draw the circle */
|
||||
y: z.ZodOptional<z.ZodNumber>;
|
||||
/** the radius of the circle */
|
||||
radius: z.ZodOptional<z.ZodNumber>;
|
||||
}, "strip", z.ZodTypeAny, {
|
||||
x?: number | undefined;
|
||||
y?: number | undefined;
|
||||
radius?: number | undefined;
|
||||
}, {
|
||||
x?: number | undefined;
|
||||
y?: number | undefined;
|
||||
radius?: number | undefined;
|
||||
}>;
|
||||
export type CircleOptions = z.infer<typeof CircleOptionsSchema>;
|
||||
export declare const methods: {
|
||||
/**
|
||||
* Creates a circle out of an image.
|
||||
* @example
|
||||
* ```ts
|
||||
* import { Jimp } from "jimp";
|
||||
*
|
||||
* const image = await Jimp.read("test/image.png");
|
||||
*
|
||||
* image.circle();
|
||||
* // or
|
||||
* image.circle({ radius: 50, x: 25, y: 25 });
|
||||
* ```
|
||||
*/
|
||||
circle<I extends JimpClass>(image: I, options?: CircleOptions): I;
|
||||
};
|
||||
export {};
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,QAAA,MAAM,mBAAmB;IACvB,wCAAwC;;IAExC,wCAAwC;;IAExC,+BAA+B;;;;;;;;;;EAE/B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,eAAO,MAAM,OAAO;IAClB;;;;;;;;;;;;OAYG;WACI,CAAC,SAAS,SAAS,SAAS,CAAC,YAAW,aAAa;CA2B7D,CAAC"}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
import { z } from "zod";
|
||||
const CircleOptionsSchema = z.object({
|
||||
/** the x position to draw the circle */
|
||||
x: z.number().optional(),
|
||||
/** the y position to draw the circle */
|
||||
y: z.number().optional(),
|
||||
/** the radius of the circle */
|
||||
radius: z.number().min(0).optional(),
|
||||
});
|
||||
export const methods = {
|
||||
/**
|
||||
* Creates a circle out of an image.
|
||||
* @example
|
||||
* ```ts
|
||||
* import { Jimp } from "jimp";
|
||||
*
|
||||
* const image = await Jimp.read("test/image.png");
|
||||
*
|
||||
* image.circle();
|
||||
* // or
|
||||
* image.circle({ radius: 50, x: 25, y: 25 });
|
||||
* ```
|
||||
*/
|
||||
circle(image, options = {}) {
|
||||
const parsed = CircleOptionsSchema.parse(options);
|
||||
const radius = parsed.radius ||
|
||||
(image.bitmap.width > image.bitmap.height
|
||||
? image.bitmap.height
|
||||
: image.bitmap.width) / 2;
|
||||
const center = {
|
||||
x: typeof parsed.x === "number" ? parsed.x : image.bitmap.width / 2,
|
||||
y: typeof parsed.y === "number" ? parsed.y : image.bitmap.height / 2,
|
||||
};
|
||||
image.scan((x, y, idx) => {
|
||||
const curR = Math.sqrt(Math.pow(x - center.x, 2) + Math.pow(y - center.y, 2));
|
||||
if (radius - curR <= 0.0) {
|
||||
image.bitmap.data[idx + 3] = 0;
|
||||
}
|
||||
else if (radius - curR < 1.0) {
|
||||
image.bitmap.data[idx + 3] = 255 * (radius - curR);
|
||||
}
|
||||
});
|
||||
return image;
|
||||
},
|
||||
};
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,wCAAwC;IACxC,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACxB,wCAAwC;IACxC,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACxB,+BAA+B;IAC/B,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CACrC,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB;;;;;;;;;;;;OAYG;IACH,MAAM,CAAsB,KAAQ,EAAE,UAAyB,EAAE;QAC/D,MAAM,MAAM,GAAG,mBAAmB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAClD,MAAM,MAAM,GACV,MAAM,CAAC,MAAM;YACb,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM;gBACvC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM;gBACrB,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAE9B,MAAM,MAAM,GAAG;YACb,CAAC,EAAE,OAAO,MAAM,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC;YACnE,CAAC,EAAE,OAAO,MAAM,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC;SACrE,CAAC;QAEF,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE;YACvB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CACpB,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CACtD,CAAC;YAEF,IAAI,MAAM,GAAG,IAAI,IAAI,GAAG,EAAE,CAAC;gBACzB,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;YACjC,CAAC;iBAAM,IAAI,MAAM,GAAG,IAAI,GAAG,GAAG,EAAE,CAAC;gBAC/B,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;YACrD,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAC"}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "module"
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
import shared from "@jimp/config-eslint/base.js";
|
||||
export default [...shared];
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
{
|
||||
"name": "@jimp/plugin-circle",
|
||||
"version": "1.6.0",
|
||||
"repository": "jimp-dev/jimp",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"test": "vitest",
|
||||
"test:browser": "vitest --config vitest.config.browser.mjs",
|
||||
"build": "tshy",
|
||||
"dev": "tshy --watch",
|
||||
"clean": "rm -rf node_modules .tshy .tshy-build dist .turbo"
|
||||
},
|
||||
"author": "Andrew Lisowski <lisowski54@gmail.com>",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@jimp/types": "1.6.0",
|
||||
"zod": "^3.23.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@jimp/config-eslint": "1.6.0",
|
||||
"@jimp/config-typescript": "1.6.0",
|
||||
"@jimp/config-vitest": "1.6.0",
|
||||
"@jimp/core": "1.6.0",
|
||||
"@jimp/test-utils": "1.6.0",
|
||||
"@vitest/browser": "^2.0.5",
|
||||
"eslint": "^9.9.1",
|
||||
"tshy": "^3.0.2",
|
||||
"typescript": "^5.5.4",
|
||||
"vite-plugin-node-polyfills": "^0.22.0",
|
||||
"vitest": "^2.0.5"
|
||||
},
|
||||
"tshy": {
|
||||
"exclude": [
|
||||
"**/*.test.ts"
|
||||
],
|
||||
"exports": {
|
||||
"./package.json": "./package.json",
|
||||
".": "./src/index.ts"
|
||||
}
|
||||
},
|
||||
"exports": {
|
||||
"./package.json": "./package.json",
|
||||
".": {
|
||||
"import": {
|
||||
"types": "./dist/esm/index.d.ts",
|
||||
"default": "./dist/esm/index.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/commonjs/index.d.ts",
|
||||
"default": "./dist/commonjs/index.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
"main": "./dist/commonjs/index.js",
|
||||
"types": "./dist/commonjs/index.d.ts",
|
||||
"type": "module",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"module": "./dist/esm/index.js",
|
||||
"gitHead": "c88abe6046dccbdb6e4f5f00c3dd403c81d83515"
|
||||
}
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`Circle > makes a circle based on image height and width 1`] = `
|
||||
Visualization:
|
||||
|
||||
▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾
|
||||
▾▾▾▾▾▾▾▾8A▦A8▾▾▾▾▾▾▾
|
||||
▾▾▾▾▾▾▾E▦▦▦▦▦E▾▾▾▾▾▾
|
||||
▾▾▾▾▾▾8▦▦▦▦▦▦▦8▾▾▾▾▾
|
||||
▾▾▾▾▾▾A▦▦▦▦▦▦▦A▾▾▾▾▾
|
||||
▾▾▾▾▾▾▦▦▦▦▦▦▦▦▦▾▾▾▾▾
|
||||
▾▾▾▾▾▾A▦▦▦▦▦▦▦A▾▾▾▾▾
|
||||
▾▾▾▾▾▾8▦▦▦▦▦▦▦8▾▾▾▾▾
|
||||
▾▾▾▾▾▾▾E▦▦▦▦▦E▾▾▾▾▾▾
|
||||
▾▾▾▾▾▾▾▾8A▦A8▾▾▾▾▾▾▾
|
||||
|
||||
Data:
|
||||
|
||||
80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰
|
||||
80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁸⁶ 80-80-80ᵈᶠ 80-80-80ᶠᶠ 80-80-80ᵈᶠ 80-80-80⁸⁶ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰
|
||||
80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80ᶜ¹ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶜ¹ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰
|
||||
80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁸⁶ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80⁸⁶ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰
|
||||
80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80ᵈᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᵈᶠ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰
|
||||
80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰
|
||||
80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80ᵈᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᵈᶠ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰
|
||||
80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁸⁶ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80⁸⁶ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰
|
||||
80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80ᶜ¹ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶜ¹ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰
|
||||
80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁸⁶ 80-80-80ᵈᶠ 80-80-80ᶠᶠ 80-80-80ᵈᶠ 80-80-80⁸⁶ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰
|
||||
`;
|
||||
|
||||
exports[`Circle > makes a circle using provided radius 1`] = `
|
||||
Visualization:
|
||||
|
||||
▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾
|
||||
▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾
|
||||
▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾
|
||||
▾▾▾▾▾▾▾▾ F▦F ▾▾▾▾▾▾▾
|
||||
▾▾▾▾▾▾▾▾F▦▦▦F▾▾▾▾▾▾▾
|
||||
▾▾▾▾▾▾▾▾▦▦▦▦▦▾▾▾▾▾▾▾
|
||||
▾▾▾▾▾▾▾▾F▦▦▦F▾▾▾▾▾▾▾
|
||||
▾▾▾▾▾▾▾▾ F▦F ▾▾▾▾▾▾▾
|
||||
▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾
|
||||
▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾
|
||||
|
||||
Data:
|
||||
|
||||
80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰
|
||||
80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰
|
||||
80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰
|
||||
80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80²ᵇ 80-80-80ᶜ² 80-80-80ᶠᶠ 80-80-80ᶜ² 80-80-80²ᵇ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰
|
||||
80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80ᶜ² 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶜ² 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰
|
||||
80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰
|
||||
80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80ᶜ² 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶜ² 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰
|
||||
80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80²ᵇ 80-80-80ᶜ² 80-80-80ᶠᶠ 80-80-80ᶜ² 80-80-80²ᵇ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰
|
||||
80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰
|
||||
80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰
|
||||
`;
|
||||
|
||||
exports[`Circle > should 1`] = `
|
||||
Visualization:
|
||||
|
||||
▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾▾
|
||||
▾▾▾8A▦A8▾▾▾▾▾▾▾▾▾▾▾▾
|
||||
▾▾E▦▦▦▦▦E▾▾▾▾▾▾▾▾▾▾▾
|
||||
▾8▦▦▦▦▦▦▦8▾▾▾▾▾▾▾▾▾▾
|
||||
▾A▦▦▦▦▦▦▦A▾▾▾▾▾▾▾▾▾▾
|
||||
▾▦▦▦▦▦▦▦▦▦▾▾▾▾▾▾▾▾▾▾
|
||||
▾A▦▦▦▦▦▦▦A▾▾▾▾▾▾▾▾▾▾
|
||||
▾8▦▦▦▦▦▦▦8▾▾▾▾▾▾▾▾▾▾
|
||||
▾▾E▦▦▦▦▦E▾▾▾▾▾▾▾▾▾▾▾
|
||||
▾▾▾8A▦A8▾▾▾▾▾▾▾▾▾▾▾▾
|
||||
|
||||
Data:
|
||||
|
||||
80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰
|
||||
80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁸⁶ 80-80-80ᵈᶠ 80-80-80ᶠᶠ 80-80-80ᵈᶠ 80-80-80⁸⁶ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰
|
||||
80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80ᶜ¹ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶜ¹ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰
|
||||
80-80-80⁰⁰ 80-80-80⁸⁶ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80⁸⁶ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰
|
||||
80-80-80⁰⁰ 80-80-80ᵈᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᵈᶠ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰
|
||||
80-80-80⁰⁰ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰
|
||||
80-80-80⁰⁰ 80-80-80ᵈᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᵈᶠ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰
|
||||
80-80-80⁰⁰ 80-80-80⁸⁶ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80⁸⁶ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰
|
||||
80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80ᶜ¹ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶜ¹ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰
|
||||
80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁸⁶ 80-80-80ᵈᶠ 80-80-80ᶠᶠ 80-80-80ᵈᶠ 80-80-80⁸⁶ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰ 80-80-80⁰⁰
|
||||
`;
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
import { expect, test, describe } from "vitest";
|
||||
|
||||
import { makeTestImage } from "@jimp/test-utils";
|
||||
import { createJimp } from "@jimp/core";
|
||||
|
||||
import { methods } from "./index.js";
|
||||
|
||||
const Jimp = createJimp({ plugins: [methods] });
|
||||
|
||||
describe("Circle", () => {
|
||||
test("makes a circle based on image height and width", () => {
|
||||
const imgSrc = Jimp.fromBitmap(
|
||||
makeTestImage(
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
),
|
||||
);
|
||||
|
||||
expect(imgSrc.circle()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test("makes a circle using provided radius", () => {
|
||||
const imgSrc = Jimp.fromBitmap(
|
||||
makeTestImage(
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
),
|
||||
);
|
||||
|
||||
expect(imgSrc.circle({ radius: 3 })).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test("should ", () => {
|
||||
const imgSrc = Jimp.fromBitmap(
|
||||
makeTestImage(
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
),
|
||||
);
|
||||
|
||||
expect(imgSrc.circle({ radius: 5, x: 5, y: 5 })).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
import { JimpClass } from "@jimp/types";
|
||||
import { z } from "zod";
|
||||
|
||||
const CircleOptionsSchema = z.object({
|
||||
/** the x position to draw the circle */
|
||||
x: z.number().optional(),
|
||||
/** the y position to draw the circle */
|
||||
y: z.number().optional(),
|
||||
/** the radius of the circle */
|
||||
radius: z.number().min(0).optional(),
|
||||
});
|
||||
|
||||
export type CircleOptions = z.infer<typeof CircleOptionsSchema>;
|
||||
|
||||
export const methods = {
|
||||
/**
|
||||
* Creates a circle out of an image.
|
||||
* @example
|
||||
* ```ts
|
||||
* import { Jimp } from "jimp";
|
||||
*
|
||||
* const image = await Jimp.read("test/image.png");
|
||||
*
|
||||
* image.circle();
|
||||
* // or
|
||||
* image.circle({ radius: 50, x: 25, y: 25 });
|
||||
* ```
|
||||
*/
|
||||
circle<I extends JimpClass>(image: I, options: CircleOptions = {}) {
|
||||
const parsed = CircleOptionsSchema.parse(options);
|
||||
const radius =
|
||||
parsed.radius ||
|
||||
(image.bitmap.width > image.bitmap.height
|
||||
? image.bitmap.height
|
||||
: image.bitmap.width) / 2;
|
||||
|
||||
const center = {
|
||||
x: typeof parsed.x === "number" ? parsed.x : image.bitmap.width / 2,
|
||||
y: typeof parsed.y === "number" ? parsed.y : image.bitmap.height / 2,
|
||||
};
|
||||
|
||||
image.scan((x, y, idx) => {
|
||||
const curR = Math.sqrt(
|
||||
Math.pow(x - center.x, 2) + Math.pow(y - center.y, 2),
|
||||
);
|
||||
|
||||
if (radius - curR <= 0.0) {
|
||||
image.bitmap.data[idx + 3] = 0;
|
||||
} else if (radius - curR < 1.0) {
|
||||
image.bitmap.data[idx + 3] = 255 * (radius - curR);
|
||||
}
|
||||
});
|
||||
|
||||
return image;
|
||||
},
|
||||
};
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"extends": "@jimp/config-typescript/base.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "dist"
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import config from "@jimp/config-vitest/browser";
|
||||
|
||||
export default config;
|
||||
Reference in new issue
Block a user