@al8b/image 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -0
- package/dist/blending.d.mts +3 -0
- package/dist/blending.d.ts +3 -0
- package/dist/blending.js +65 -0
- package/dist/blending.js.map +1 -0
- package/dist/blending.mjs +40 -0
- package/dist/blending.mjs.map +1 -0
- package/dist/color-DJyRSbpZ.d.mts +16 -0
- package/dist/color-DJyRSbpZ.d.ts +16 -0
- package/dist/core/color.d.mts +1 -0
- package/dist/core/color.d.ts +1 -0
- package/dist/core/color.js +61 -0
- package/dist/core/color.js.map +1 -0
- package/dist/core/color.mjs +36 -0
- package/dist/core/color.mjs.map +1 -0
- package/dist/core/context.d.mts +25 -0
- package/dist/core/context.d.ts +25 -0
- package/dist/core/context.js +77 -0
- package/dist/core/context.js.map +1 -0
- package/dist/core/context.mjs +53 -0
- package/dist/core/context.mjs.map +1 -0
- package/dist/core/drawing.d.mts +2 -0
- package/dist/core/drawing.d.ts +2 -0
- package/dist/core/drawing.js +165 -0
- package/dist/core/drawing.js.map +1 -0
- package/dist/core/drawing.mjs +134 -0
- package/dist/core/drawing.mjs.map +1 -0
- package/dist/core/font.d.mts +19 -0
- package/dist/core/font.d.ts +19 -0
- package/dist/core/font.js +80 -0
- package/dist/core/font.js.map +1 -0
- package/dist/core/font.mjs +55 -0
- package/dist/core/font.mjs.map +1 -0
- package/dist/core/image.d.mts +84 -0
- package/dist/core/image.d.ts +84 -0
- package/dist/core/image.js +1018 -0
- package/dist/core/image.js.map +1 -0
- package/dist/core/image.mjs +993 -0
- package/dist/core/image.mjs.map +1 -0
- package/dist/core/map-rendering.d.mts +2 -0
- package/dist/core/map-rendering.d.ts +2 -0
- package/dist/core/map-rendering.js +95 -0
- package/dist/core/map-rendering.js.map +1 -0
- package/dist/core/map-rendering.mjs +70 -0
- package/dist/core/map-rendering.mjs.map +1 -0
- package/dist/core/pixel.d.mts +18 -0
- package/dist/core/pixel.d.ts +18 -0
- package/dist/core/pixel.js +99 -0
- package/dist/core/pixel.js.map +1 -0
- package/dist/core/pixel.mjs +73 -0
- package/dist/core/pixel.mjs.map +1 -0
- package/dist/core/shapes.d.mts +2 -0
- package/dist/core/shapes.d.ts +2 -0
- package/dist/core/shapes.js +218 -0
- package/dist/core/shapes.js.map +1 -0
- package/dist/core/shapes.mjs +187 -0
- package/dist/core/shapes.mjs.map +1 -0
- package/dist/core/sprite-rendering.d.mts +2 -0
- package/dist/core/sprite-rendering.d.ts +2 -0
- package/dist/core/sprite-rendering.js +135 -0
- package/dist/core/sprite-rendering.js.map +1 -0
- package/dist/core/sprite-rendering.mjs +108 -0
- package/dist/core/sprite-rendering.mjs.map +1 -0
- package/dist/core/text.d.mts +2 -0
- package/dist/core/text.d.ts +2 -0
- package/dist/core/text.js +105 -0
- package/dist/core/text.js.map +1 -0
- package/dist/core/text.mjs +78 -0
- package/dist/core/text.mjs.map +1 -0
- package/dist/core/transform.d.mts +2 -0
- package/dist/core/transform.d.ts +2 -0
- package/dist/core/transform.js +101 -0
- package/dist/core/transform.js.map +1 -0
- package/dist/core/transform.mjs +71 -0
- package/dist/core/transform.mjs.map +1 -0
- package/dist/drawing-Bo2U4IUE.d.mts +31 -0
- package/dist/drawing-e7iVDl14.d.ts +31 -0
- package/dist/index.d.mts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +1098 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1066 -0
- package/dist/index.mjs.map +1 -0
- package/dist/map-rendering-CzeC061I.d.mts +20 -0
- package/dist/map-rendering-DcldCBtY.d.ts +20 -0
- package/dist/shapes-BY37IuhJ.d.ts +27 -0
- package/dist/shapes-CpCwX9Rp.d.mts +27 -0
- package/dist/sprite-rendering-Dac9FQ2x.d.ts +30 -0
- package/dist/sprite-rendering-DfQuLVXT.d.mts +30 -0
- package/dist/text-CIoUSRc-.d.mts +19 -0
- package/dist/text-HW25Qq3e.d.ts +19 -0
- package/dist/transform-Dqo6bY4r.d.mts +25 -0
- package/dist/transform-iwq8WdqR.d.ts +25 -0
- package/package.json +43 -0
package/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# @al8b/image
|
|
2
|
+
|
|
3
|
+
Canvas image utilities shared across rendering packages. It exposes the `Image` abstraction plus focused modules for drawing, color operations, text, transforms, sprite rendering, and map rendering.
|
|
4
|
+
|
|
5
|
+
## Public API
|
|
6
|
+
|
|
7
|
+
- `Image`
|
|
8
|
+
- `BLENDING_MODES`
|
|
9
|
+
- `ColorOps`
|
|
10
|
+
- `DrawingOps`
|
|
11
|
+
- `ShapeOps`
|
|
12
|
+
- `TextOps`
|
|
13
|
+
- `SpriteRenderingOps`
|
|
14
|
+
- `MapRenderingOps`
|
|
15
|
+
- `TransformOps`
|
|
16
|
+
- Font helpers: `loadFont`, `isFontReady`, `clearFontCache`
|
|
17
|
+
- Types: `ImageContextState`, `RGBColor`, `RGBAColor`, `SpriteSource`, `MapSource`
|
|
18
|
+
|
|
19
|
+
## Notes
|
|
20
|
+
|
|
21
|
+
- Used by `@al8b/screen`, `@al8b/sprites`, and runtime asset rendering.
|
|
22
|
+
- Browser-oriented package built around canvas APIs.
|
|
23
|
+
|
|
24
|
+
## Scripts
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
bun run build
|
|
28
|
+
bun run test
|
|
29
|
+
bun run clean
|
|
30
|
+
```
|
package/dist/blending.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/blending.ts
|
|
21
|
+
var blending_exports = {};
|
|
22
|
+
__export(blending_exports, {
|
|
23
|
+
BLENDING_MODES: () => BLENDING_MODES
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(blending_exports);
|
|
26
|
+
var BLENDING_MODES = {
|
|
27
|
+
normal: "source-over",
|
|
28
|
+
additive: "lighter"
|
|
29
|
+
};
|
|
30
|
+
var MODES = [
|
|
31
|
+
"source-over",
|
|
32
|
+
"source-in",
|
|
33
|
+
"source-out",
|
|
34
|
+
"source-atop",
|
|
35
|
+
"destination-over",
|
|
36
|
+
"destination-in",
|
|
37
|
+
"destination-out",
|
|
38
|
+
"destination-atop",
|
|
39
|
+
"lighter",
|
|
40
|
+
"copy",
|
|
41
|
+
"xor",
|
|
42
|
+
"multiply",
|
|
43
|
+
"screen",
|
|
44
|
+
"overlay",
|
|
45
|
+
"darken",
|
|
46
|
+
"lighten",
|
|
47
|
+
"color-dodge",
|
|
48
|
+
"color-burn",
|
|
49
|
+
"hard-light",
|
|
50
|
+
"soft-light",
|
|
51
|
+
"difference",
|
|
52
|
+
"exclusion",
|
|
53
|
+
"hue",
|
|
54
|
+
"saturation",
|
|
55
|
+
"color",
|
|
56
|
+
"luminosity"
|
|
57
|
+
];
|
|
58
|
+
for (const mode of MODES) {
|
|
59
|
+
BLENDING_MODES[mode] = mode;
|
|
60
|
+
}
|
|
61
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
62
|
+
0 && (module.exports = {
|
|
63
|
+
BLENDING_MODES
|
|
64
|
+
});
|
|
65
|
+
//# sourceMappingURL=blending.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/blending.ts"],"sourcesContent":["export const BLENDING_MODES: Record<string, GlobalCompositeOperation> = {\n\tnormal: \"source-over\",\n\tadditive: \"lighter\",\n};\n\nconst MODES = [\n\t\"source-over\",\n\t\"source-in\",\n\t\"source-out\",\n\t\"source-atop\",\n\t\"destination-over\",\n\t\"destination-in\",\n\t\"destination-out\",\n\t\"destination-atop\",\n\t\"lighter\",\n\t\"copy\",\n\t\"xor\",\n\t\"multiply\",\n\t\"screen\",\n\t\"overlay\",\n\t\"darken\",\n\t\"lighten\",\n\t\"color-dodge\",\n\t\"color-burn\",\n\t\"hard-light\",\n\t\"soft-light\",\n\t\"difference\",\n\t\"exclusion\",\n\t\"hue\",\n\t\"saturation\",\n\t\"color\",\n\t\"luminosity\",\n];\n\nfor (const mode of MODES) {\n\tBLENDING_MODES[mode] = mode as GlobalCompositeOperation;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;;;;AAAO,IAAMA,iBAA2D;EACvEC,QAAQ;EACRC,UAAU;AACX;AAEA,IAAMC,QAAQ;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAGD,WAAWC,QAAQD,OAAO;AACzBH,iBAAeI,IAAAA,IAAQA;AACxB;","names":["BLENDING_MODES","normal","additive","MODES","mode"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// src/blending.ts
|
|
2
|
+
var BLENDING_MODES = {
|
|
3
|
+
normal: "source-over",
|
|
4
|
+
additive: "lighter"
|
|
5
|
+
};
|
|
6
|
+
var MODES = [
|
|
7
|
+
"source-over",
|
|
8
|
+
"source-in",
|
|
9
|
+
"source-out",
|
|
10
|
+
"source-atop",
|
|
11
|
+
"destination-over",
|
|
12
|
+
"destination-in",
|
|
13
|
+
"destination-out",
|
|
14
|
+
"destination-atop",
|
|
15
|
+
"lighter",
|
|
16
|
+
"copy",
|
|
17
|
+
"xor",
|
|
18
|
+
"multiply",
|
|
19
|
+
"screen",
|
|
20
|
+
"overlay",
|
|
21
|
+
"darken",
|
|
22
|
+
"lighten",
|
|
23
|
+
"color-dodge",
|
|
24
|
+
"color-burn",
|
|
25
|
+
"hard-light",
|
|
26
|
+
"soft-light",
|
|
27
|
+
"difference",
|
|
28
|
+
"exclusion",
|
|
29
|
+
"hue",
|
|
30
|
+
"saturation",
|
|
31
|
+
"color",
|
|
32
|
+
"luminosity"
|
|
33
|
+
];
|
|
34
|
+
for (const mode of MODES) {
|
|
35
|
+
BLENDING_MODES[mode] = mode;
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
BLENDING_MODES
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=blending.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/blending.ts"],"sourcesContent":["export const BLENDING_MODES: Record<string, GlobalCompositeOperation> = {\n\tnormal: \"source-over\",\n\tadditive: \"lighter\",\n};\n\nconst MODES = [\n\t\"source-over\",\n\t\"source-in\",\n\t\"source-out\",\n\t\"source-atop\",\n\t\"destination-over\",\n\t\"destination-in\",\n\t\"destination-out\",\n\t\"destination-atop\",\n\t\"lighter\",\n\t\"copy\",\n\t\"xor\",\n\t\"multiply\",\n\t\"screen\",\n\t\"overlay\",\n\t\"darken\",\n\t\"lighten\",\n\t\"color-dodge\",\n\t\"color-burn\",\n\t\"hard-light\",\n\t\"soft-light\",\n\t\"difference\",\n\t\"exclusion\",\n\t\"hue\",\n\t\"saturation\",\n\t\"color\",\n\t\"luminosity\",\n];\n\nfor (const mode of MODES) {\n\tBLENDING_MODES[mode] = mode as GlobalCompositeOperation;\n}\n"],"mappings":";AAAO,IAAMA,iBAA2D;EACvEC,QAAQ;EACRC,UAAU;AACX;AAEA,IAAMC,QAAQ;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAGD,WAAWC,QAAQD,OAAO;AACzBH,iBAAeI,IAAAA,IAAQA;AACxB;","names":["BLENDING_MODES","normal","additive","MODES","mode"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Color management for Image class
|
|
3
|
+
* Handles color setting, pixel operations, and gradients
|
|
4
|
+
*/
|
|
5
|
+
declare function setColor(context: CanvasRenderingContext2D, color?: string): void;
|
|
6
|
+
declare function setLinearGradient(context: CanvasRenderingContext2D, x1: number, y1: number, x2: number, y2: number, c1: string, c2: string): void;
|
|
7
|
+
declare function setRadialGradient(context: CanvasRenderingContext2D, x: number, y: number, radius: number, c1: string, c2: string): void;
|
|
8
|
+
|
|
9
|
+
declare const color_setColor: typeof setColor;
|
|
10
|
+
declare const color_setLinearGradient: typeof setLinearGradient;
|
|
11
|
+
declare const color_setRadialGradient: typeof setRadialGradient;
|
|
12
|
+
declare namespace color {
|
|
13
|
+
export { color_setColor as setColor, color_setLinearGradient as setLinearGradient, color_setRadialGradient as setRadialGradient };
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { setLinearGradient as a, setRadialGradient as b, color as c, setColor as s };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Color management for Image class
|
|
3
|
+
* Handles color setting, pixel operations, and gradients
|
|
4
|
+
*/
|
|
5
|
+
declare function setColor(context: CanvasRenderingContext2D, color?: string): void;
|
|
6
|
+
declare function setLinearGradient(context: CanvasRenderingContext2D, x1: number, y1: number, x2: number, y2: number, c1: string, c2: string): void;
|
|
7
|
+
declare function setRadialGradient(context: CanvasRenderingContext2D, x: number, y: number, radius: number, c1: string, c2: string): void;
|
|
8
|
+
|
|
9
|
+
declare const color_setColor: typeof setColor;
|
|
10
|
+
declare const color_setLinearGradient: typeof setLinearGradient;
|
|
11
|
+
declare const color_setRadialGradient: typeof setRadialGradient;
|
|
12
|
+
declare namespace color {
|
|
13
|
+
export { color_setColor as setColor, color_setLinearGradient as setLinearGradient, color_setRadialGradient as setRadialGradient };
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { setLinearGradient as a, setRadialGradient as b, color as c, setColor as s };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { s as setColor, a as setLinearGradient, b as setRadialGradient } from '../color-DJyRSbpZ.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { s as setColor, a as setLinearGradient, b as setRadialGradient } from '../color-DJyRSbpZ.js';
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/core/color.ts
|
|
22
|
+
var color_exports = {};
|
|
23
|
+
__export(color_exports, {
|
|
24
|
+
setColor: () => setColor,
|
|
25
|
+
setLinearGradient: () => setLinearGradient,
|
|
26
|
+
setRadialGradient: () => setRadialGradient
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(color_exports);
|
|
29
|
+
function setColor(context, color) {
|
|
30
|
+
if (color == null) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (typeof color === "string") {
|
|
34
|
+
context.fillStyle = color;
|
|
35
|
+
context.strokeStyle = color;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
__name(setColor, "setColor");
|
|
39
|
+
function setLinearGradient(context, x1, y1, x2, y2, c1, c2) {
|
|
40
|
+
const grd = context.createLinearGradient(x1, y1, x2, y2);
|
|
41
|
+
grd.addColorStop(0, c1);
|
|
42
|
+
grd.addColorStop(1, c2);
|
|
43
|
+
context.fillStyle = grd;
|
|
44
|
+
context.strokeStyle = grd;
|
|
45
|
+
}
|
|
46
|
+
__name(setLinearGradient, "setLinearGradient");
|
|
47
|
+
function setRadialGradient(context, x, y, radius, c1, c2) {
|
|
48
|
+
const grd = context.createRadialGradient(x, y, 0, x, y, radius);
|
|
49
|
+
grd.addColorStop(0, c1);
|
|
50
|
+
grd.addColorStop(1, c2);
|
|
51
|
+
context.fillStyle = grd;
|
|
52
|
+
context.strokeStyle = grd;
|
|
53
|
+
}
|
|
54
|
+
__name(setRadialGradient, "setRadialGradient");
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
setColor,
|
|
58
|
+
setLinearGradient,
|
|
59
|
+
setRadialGradient
|
|
60
|
+
});
|
|
61
|
+
//# sourceMappingURL=color.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/core/color.ts"],"sourcesContent":["/**\n * Color management for Image class\n * Handles color setting, pixel operations, and gradients\n */\n\nexport function setColor(context: CanvasRenderingContext2D, color?: string): void {\n\tif (color == null) {\n\t\treturn;\n\t}\n\tif (typeof color === \"string\") {\n\t\tcontext.fillStyle = color;\n\t\tcontext.strokeStyle = color;\n\t}\n}\n\nexport function setLinearGradient(\n\tcontext: CanvasRenderingContext2D,\n\tx1: number,\n\ty1: number,\n\tx2: number,\n\ty2: number,\n\tc1: string,\n\tc2: string,\n): void {\n\tconst grd = context.createLinearGradient(x1, y1, x2, y2);\n\tgrd.addColorStop(0, c1);\n\tgrd.addColorStop(1, c2);\n\tcontext.fillStyle = grd;\n\tcontext.strokeStyle = grd;\n}\n\nexport function setRadialGradient(\n\tcontext: CanvasRenderingContext2D,\n\tx: number,\n\ty: number,\n\tradius: number,\n\tc1: string,\n\tc2: string,\n): void {\n\tconst grd = context.createRadialGradient(x, y, 0, x, y, radius);\n\tgrd.addColorStop(0, c1);\n\tgrd.addColorStop(1, c2);\n\tcontext.fillStyle = grd;\n\tcontext.strokeStyle = grd;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;AAKO,SAASA,SAASC,SAAmCC,OAAc;AACzE,MAAIA,SAAS,MAAM;AAClB;EACD;AACA,MAAI,OAAOA,UAAU,UAAU;AAC9BD,YAAQE,YAAYD;AACpBD,YAAQG,cAAcF;EACvB;AACD;AARgBF;AAUT,SAASK,kBACfJ,SACAK,IACAC,IACAC,IACAC,IACAC,IACAC,IAAU;AAEV,QAAMC,MAAMX,QAAQY,qBAAqBP,IAAIC,IAAIC,IAAIC,EAAAA;AACrDG,MAAIE,aAAa,GAAGJ,EAAAA;AACpBE,MAAIE,aAAa,GAAGH,EAAAA;AACpBV,UAAQE,YAAYS;AACpBX,UAAQG,cAAcQ;AACvB;AAdgBP;AAgBT,SAASU,kBACfd,SACAe,GACAC,GACAC,QACAR,IACAC,IAAU;AAEV,QAAMC,MAAMX,QAAQkB,qBAAqBH,GAAGC,GAAG,GAAGD,GAAGC,GAAGC,MAAAA;AACxDN,MAAIE,aAAa,GAAGJ,EAAAA;AACpBE,MAAIE,aAAa,GAAGH,EAAAA;AACpBV,UAAQE,YAAYS;AACpBX,UAAQG,cAAcQ;AACvB;AAbgBG;","names":["setColor","context","color","fillStyle","strokeStyle","setLinearGradient","x1","y1","x2","y2","c1","c2","grd","createLinearGradient","addColorStop","setRadialGradient","x","y","radius","createRadialGradient"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// src/core/color.ts
|
|
5
|
+
function setColor(context, color) {
|
|
6
|
+
if (color == null) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (typeof color === "string") {
|
|
10
|
+
context.fillStyle = color;
|
|
11
|
+
context.strokeStyle = color;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
__name(setColor, "setColor");
|
|
15
|
+
function setLinearGradient(context, x1, y1, x2, y2, c1, c2) {
|
|
16
|
+
const grd = context.createLinearGradient(x1, y1, x2, y2);
|
|
17
|
+
grd.addColorStop(0, c1);
|
|
18
|
+
grd.addColorStop(1, c2);
|
|
19
|
+
context.fillStyle = grd;
|
|
20
|
+
context.strokeStyle = grd;
|
|
21
|
+
}
|
|
22
|
+
__name(setLinearGradient, "setLinearGradient");
|
|
23
|
+
function setRadialGradient(context, x, y, radius, c1, c2) {
|
|
24
|
+
const grd = context.createRadialGradient(x, y, 0, x, y, radius);
|
|
25
|
+
grd.addColorStop(0, c1);
|
|
26
|
+
grd.addColorStop(1, c2);
|
|
27
|
+
context.fillStyle = grd;
|
|
28
|
+
context.strokeStyle = grd;
|
|
29
|
+
}
|
|
30
|
+
__name(setRadialGradient, "setRadialGradient");
|
|
31
|
+
export {
|
|
32
|
+
setColor,
|
|
33
|
+
setLinearGradient,
|
|
34
|
+
setRadialGradient
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=color.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/core/color.ts"],"sourcesContent":["/**\n * Color management for Image class\n * Handles color setting, pixel operations, and gradients\n */\n\nexport function setColor(context: CanvasRenderingContext2D, color?: string): void {\n\tif (color == null) {\n\t\treturn;\n\t}\n\tif (typeof color === \"string\") {\n\t\tcontext.fillStyle = color;\n\t\tcontext.strokeStyle = color;\n\t}\n}\n\nexport function setLinearGradient(\n\tcontext: CanvasRenderingContext2D,\n\tx1: number,\n\ty1: number,\n\tx2: number,\n\ty2: number,\n\tc1: string,\n\tc2: string,\n): void {\n\tconst grd = context.createLinearGradient(x1, y1, x2, y2);\n\tgrd.addColorStop(0, c1);\n\tgrd.addColorStop(1, c2);\n\tcontext.fillStyle = grd;\n\tcontext.strokeStyle = grd;\n}\n\nexport function setRadialGradient(\n\tcontext: CanvasRenderingContext2D,\n\tx: number,\n\ty: number,\n\tradius: number,\n\tc1: string,\n\tc2: string,\n): void {\n\tconst grd = context.createRadialGradient(x, y, 0, x, y, radius);\n\tgrd.addColorStop(0, c1);\n\tgrd.addColorStop(1, c2);\n\tcontext.fillStyle = grd;\n\tcontext.strokeStyle = grd;\n}\n"],"mappings":";;;;AAKO,SAASA,SAASC,SAAmCC,OAAc;AACzE,MAAIA,SAAS,MAAM;AAClB;EACD;AACA,MAAI,OAAOA,UAAU,UAAU;AAC9BD,YAAQE,YAAYD;AACpBD,YAAQG,cAAcF;EACvB;AACD;AARgBF;AAUT,SAASK,kBACfJ,SACAK,IACAC,IACAC,IACAC,IACAC,IACAC,IAAU;AAEV,QAAMC,MAAMX,QAAQY,qBAAqBP,IAAIC,IAAIC,IAAIC,EAAAA;AACrDG,MAAIE,aAAa,GAAGJ,EAAAA;AACpBE,MAAIE,aAAa,GAAGH,EAAAA;AACpBV,UAAQE,YAAYS;AACpBX,UAAQG,cAAcQ;AACvB;AAdgBP;AAgBT,SAASU,kBACfd,SACAe,GACAC,GACAC,QACAR,IACAC,IAAU;AAEV,QAAMC,MAAMX,QAAQkB,qBAAqBH,GAAGC,GAAG,GAAGD,GAAGC,GAAGC,MAAAA;AACxDN,MAAIE,aAAa,GAAGJ,EAAAA;AACpBE,MAAIE,aAAa,GAAGH,EAAAA;AACpBV,UAAQE,YAAYS;AACpBX,UAAQG,cAAcQ;AACvB;AAbgBG;","names":["setColor","context","color","fillStyle","strokeStyle","setLinearGradient","x1","y1","x2","y2","c1","c2","grd","createLinearGradient","addColorStop","setRadialGradient","x","y","radius","createRadialGradient"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context management for Image class
|
|
3
|
+
* Handles canvas context initialization and state management
|
|
4
|
+
*/
|
|
5
|
+
interface ImageContextState {
|
|
6
|
+
alpha: number;
|
|
7
|
+
pixelated: number;
|
|
8
|
+
line_width: number;
|
|
9
|
+
translation_x: number;
|
|
10
|
+
translation_y: number;
|
|
11
|
+
rotation: number;
|
|
12
|
+
scale_x: number;
|
|
13
|
+
scale_y: number;
|
|
14
|
+
image_transform: boolean;
|
|
15
|
+
anchor_x: number;
|
|
16
|
+
anchor_y: number;
|
|
17
|
+
object_rotation: number;
|
|
18
|
+
object_scale_x: number;
|
|
19
|
+
object_scale_y: number;
|
|
20
|
+
font: string;
|
|
21
|
+
}
|
|
22
|
+
declare function createDefaultContextState(centered: boolean): ImageContextState;
|
|
23
|
+
declare function updateImageTransform(state: ImageContextState): void;
|
|
24
|
+
|
|
25
|
+
export { type ImageContextState, createDefaultContextState, updateImageTransform };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context management for Image class
|
|
3
|
+
* Handles canvas context initialization and state management
|
|
4
|
+
*/
|
|
5
|
+
interface ImageContextState {
|
|
6
|
+
alpha: number;
|
|
7
|
+
pixelated: number;
|
|
8
|
+
line_width: number;
|
|
9
|
+
translation_x: number;
|
|
10
|
+
translation_y: number;
|
|
11
|
+
rotation: number;
|
|
12
|
+
scale_x: number;
|
|
13
|
+
scale_y: number;
|
|
14
|
+
image_transform: boolean;
|
|
15
|
+
anchor_x: number;
|
|
16
|
+
anchor_y: number;
|
|
17
|
+
object_rotation: number;
|
|
18
|
+
object_scale_x: number;
|
|
19
|
+
object_scale_y: number;
|
|
20
|
+
font: string;
|
|
21
|
+
}
|
|
22
|
+
declare function createDefaultContextState(centered: boolean): ImageContextState;
|
|
23
|
+
declare function updateImageTransform(state: ImageContextState): void;
|
|
24
|
+
|
|
25
|
+
export { type ImageContextState, createDefaultContextState, updateImageTransform };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/core/context.ts
|
|
22
|
+
var context_exports = {};
|
|
23
|
+
__export(context_exports, {
|
|
24
|
+
createDefaultContextState: () => createDefaultContextState,
|
|
25
|
+
updateImageTransform: () => updateImageTransform
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(context_exports);
|
|
28
|
+
function createDefaultContextState(centered) {
|
|
29
|
+
if (centered) {
|
|
30
|
+
return {
|
|
31
|
+
alpha: 1,
|
|
32
|
+
pixelated: 1,
|
|
33
|
+
line_width: 1,
|
|
34
|
+
translation_x: 0,
|
|
35
|
+
translation_y: 0,
|
|
36
|
+
rotation: 0,
|
|
37
|
+
scale_x: 1,
|
|
38
|
+
scale_y: -1,
|
|
39
|
+
image_transform: true,
|
|
40
|
+
anchor_x: 0,
|
|
41
|
+
anchor_y: 0,
|
|
42
|
+
object_rotation: 0,
|
|
43
|
+
object_scale_x: 1,
|
|
44
|
+
object_scale_y: -1,
|
|
45
|
+
font: "BitCell"
|
|
46
|
+
};
|
|
47
|
+
} else {
|
|
48
|
+
return {
|
|
49
|
+
alpha: 1,
|
|
50
|
+
pixelated: 1,
|
|
51
|
+
line_width: 1,
|
|
52
|
+
translation_x: 0,
|
|
53
|
+
translation_y: 0,
|
|
54
|
+
rotation: 0,
|
|
55
|
+
scale_x: 1,
|
|
56
|
+
scale_y: 1,
|
|
57
|
+
image_transform: false,
|
|
58
|
+
anchor_x: -1,
|
|
59
|
+
anchor_y: 1,
|
|
60
|
+
object_rotation: 0,
|
|
61
|
+
object_scale_x: 1,
|
|
62
|
+
object_scale_y: 1,
|
|
63
|
+
font: "BitCell"
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
__name(createDefaultContextState, "createDefaultContextState");
|
|
68
|
+
function updateImageTransform(state) {
|
|
69
|
+
state.image_transform = state.translation_x !== 0 || state.translation_y !== 0 || state.scale_x !== 1 || state.scale_y !== 1 || state.rotation !== 0;
|
|
70
|
+
}
|
|
71
|
+
__name(updateImageTransform, "updateImageTransform");
|
|
72
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
73
|
+
0 && (module.exports = {
|
|
74
|
+
createDefaultContextState,
|
|
75
|
+
updateImageTransform
|
|
76
|
+
});
|
|
77
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/core/context.ts"],"sourcesContent":["/**\n * Context management for Image class\n * Handles canvas context initialization and state management\n */\n\nexport interface ImageContextState {\n\talpha: number;\n\tpixelated: number;\n\tline_width: number;\n\ttranslation_x: number;\n\ttranslation_y: number;\n\trotation: number;\n\tscale_x: number;\n\tscale_y: number;\n\timage_transform: boolean;\n\tanchor_x: number;\n\tanchor_y: number;\n\tobject_rotation: number;\n\tobject_scale_x: number;\n\tobject_scale_y: number;\n\tfont: string;\n}\n\nexport function createDefaultContextState(centered: boolean): ImageContextState {\n\tif (centered) {\n\t\treturn {\n\t\t\talpha: 1,\n\t\t\tpixelated: 1,\n\t\t\tline_width: 1,\n\t\t\ttranslation_x: 0, // Will be set to width/2\n\t\t\ttranslation_y: 0, // Will be set to height/2\n\t\t\trotation: 0,\n\t\t\tscale_x: 1,\n\t\t\tscale_y: -1,\n\t\t\timage_transform: true,\n\t\t\tanchor_x: 0,\n\t\t\tanchor_y: 0,\n\t\t\tobject_rotation: 0,\n\t\t\tobject_scale_x: 1,\n\t\t\tobject_scale_y: -1,\n\t\t\tfont: \"BitCell\",\n\t\t};\n\t} else {\n\t\treturn {\n\t\t\talpha: 1,\n\t\t\tpixelated: 1,\n\t\t\tline_width: 1,\n\t\t\ttranslation_x: 0,\n\t\t\ttranslation_y: 0,\n\t\t\trotation: 0,\n\t\t\tscale_x: 1,\n\t\t\tscale_y: 1,\n\t\t\timage_transform: false,\n\t\t\tanchor_x: -1,\n\t\t\tanchor_y: 1,\n\t\t\tobject_rotation: 0,\n\t\t\tobject_scale_x: 1,\n\t\t\tobject_scale_y: 1,\n\t\t\tfont: \"BitCell\",\n\t\t};\n\t}\n}\n\nexport function updateImageTransform(state: ImageContextState): void {\n\tstate.image_transform =\n\t\tstate.translation_x !== 0 ||\n\t\tstate.translation_y !== 0 ||\n\t\tstate.scale_x !== 1 ||\n\t\tstate.scale_y !== 1 ||\n\t\tstate.rotation !== 0;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;AAuBO,SAASA,0BAA0BC,UAAiB;AAC1D,MAAIA,UAAU;AACb,WAAO;MACNC,OAAO;MACPC,WAAW;MACXC,YAAY;MACZC,eAAe;MACfC,eAAe;MACfC,UAAU;MACVC,SAAS;MACTC,SAAS;MACTC,iBAAiB;MACjBC,UAAU;MACVC,UAAU;MACVC,iBAAiB;MACjBC,gBAAgB;MAChBC,gBAAgB;MAChBC,MAAM;IACP;EACD,OAAO;AACN,WAAO;MACNd,OAAO;MACPC,WAAW;MACXC,YAAY;MACZC,eAAe;MACfC,eAAe;MACfC,UAAU;MACVC,SAAS;MACTC,SAAS;MACTC,iBAAiB;MACjBC,UAAU;MACVC,UAAU;MACVC,iBAAiB;MACjBC,gBAAgB;MAChBC,gBAAgB;MAChBC,MAAM;IACP;EACD;AACD;AAtCgBhB;AAwCT,SAASiB,qBAAqBC,OAAwB;AAC5DA,QAAMR,kBACLQ,MAAMb,kBAAkB,KACxBa,MAAMZ,kBAAkB,KACxBY,MAAMV,YAAY,KAClBU,MAAMT,YAAY,KAClBS,MAAMX,aAAa;AACrB;AAPgBU;","names":["createDefaultContextState","centered","alpha","pixelated","line_width","translation_x","translation_y","rotation","scale_x","scale_y","image_transform","anchor_x","anchor_y","object_rotation","object_scale_x","object_scale_y","font","updateImageTransform","state"]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// src/core/context.ts
|
|
5
|
+
function createDefaultContextState(centered) {
|
|
6
|
+
if (centered) {
|
|
7
|
+
return {
|
|
8
|
+
alpha: 1,
|
|
9
|
+
pixelated: 1,
|
|
10
|
+
line_width: 1,
|
|
11
|
+
translation_x: 0,
|
|
12
|
+
translation_y: 0,
|
|
13
|
+
rotation: 0,
|
|
14
|
+
scale_x: 1,
|
|
15
|
+
scale_y: -1,
|
|
16
|
+
image_transform: true,
|
|
17
|
+
anchor_x: 0,
|
|
18
|
+
anchor_y: 0,
|
|
19
|
+
object_rotation: 0,
|
|
20
|
+
object_scale_x: 1,
|
|
21
|
+
object_scale_y: -1,
|
|
22
|
+
font: "BitCell"
|
|
23
|
+
};
|
|
24
|
+
} else {
|
|
25
|
+
return {
|
|
26
|
+
alpha: 1,
|
|
27
|
+
pixelated: 1,
|
|
28
|
+
line_width: 1,
|
|
29
|
+
translation_x: 0,
|
|
30
|
+
translation_y: 0,
|
|
31
|
+
rotation: 0,
|
|
32
|
+
scale_x: 1,
|
|
33
|
+
scale_y: 1,
|
|
34
|
+
image_transform: false,
|
|
35
|
+
anchor_x: -1,
|
|
36
|
+
anchor_y: 1,
|
|
37
|
+
object_rotation: 0,
|
|
38
|
+
object_scale_x: 1,
|
|
39
|
+
object_scale_y: 1,
|
|
40
|
+
font: "BitCell"
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
__name(createDefaultContextState, "createDefaultContextState");
|
|
45
|
+
function updateImageTransform(state) {
|
|
46
|
+
state.image_transform = state.translation_x !== 0 || state.translation_y !== 0 || state.scale_x !== 1 || state.scale_y !== 1 || state.rotation !== 0;
|
|
47
|
+
}
|
|
48
|
+
__name(updateImageTransform, "updateImageTransform");
|
|
49
|
+
export {
|
|
50
|
+
createDefaultContextState,
|
|
51
|
+
updateImageTransform
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=context.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/core/context.ts"],"sourcesContent":["/**\n * Context management for Image class\n * Handles canvas context initialization and state management\n */\n\nexport interface ImageContextState {\n\talpha: number;\n\tpixelated: number;\n\tline_width: number;\n\ttranslation_x: number;\n\ttranslation_y: number;\n\trotation: number;\n\tscale_x: number;\n\tscale_y: number;\n\timage_transform: boolean;\n\tanchor_x: number;\n\tanchor_y: number;\n\tobject_rotation: number;\n\tobject_scale_x: number;\n\tobject_scale_y: number;\n\tfont: string;\n}\n\nexport function createDefaultContextState(centered: boolean): ImageContextState {\n\tif (centered) {\n\t\treturn {\n\t\t\talpha: 1,\n\t\t\tpixelated: 1,\n\t\t\tline_width: 1,\n\t\t\ttranslation_x: 0, // Will be set to width/2\n\t\t\ttranslation_y: 0, // Will be set to height/2\n\t\t\trotation: 0,\n\t\t\tscale_x: 1,\n\t\t\tscale_y: -1,\n\t\t\timage_transform: true,\n\t\t\tanchor_x: 0,\n\t\t\tanchor_y: 0,\n\t\t\tobject_rotation: 0,\n\t\t\tobject_scale_x: 1,\n\t\t\tobject_scale_y: -1,\n\t\t\tfont: \"BitCell\",\n\t\t};\n\t} else {\n\t\treturn {\n\t\t\talpha: 1,\n\t\t\tpixelated: 1,\n\t\t\tline_width: 1,\n\t\t\ttranslation_x: 0,\n\t\t\ttranslation_y: 0,\n\t\t\trotation: 0,\n\t\t\tscale_x: 1,\n\t\t\tscale_y: 1,\n\t\t\timage_transform: false,\n\t\t\tanchor_x: -1,\n\t\t\tanchor_y: 1,\n\t\t\tobject_rotation: 0,\n\t\t\tobject_scale_x: 1,\n\t\t\tobject_scale_y: 1,\n\t\t\tfont: \"BitCell\",\n\t\t};\n\t}\n}\n\nexport function updateImageTransform(state: ImageContextState): void {\n\tstate.image_transform =\n\t\tstate.translation_x !== 0 ||\n\t\tstate.translation_y !== 0 ||\n\t\tstate.scale_x !== 1 ||\n\t\tstate.scale_y !== 1 ||\n\t\tstate.rotation !== 0;\n}\n"],"mappings":";;;;AAuBO,SAASA,0BAA0BC,UAAiB;AAC1D,MAAIA,UAAU;AACb,WAAO;MACNC,OAAO;MACPC,WAAW;MACXC,YAAY;MACZC,eAAe;MACfC,eAAe;MACfC,UAAU;MACVC,SAAS;MACTC,SAAS;MACTC,iBAAiB;MACjBC,UAAU;MACVC,UAAU;MACVC,iBAAiB;MACjBC,gBAAgB;MAChBC,gBAAgB;MAChBC,MAAM;IACP;EACD,OAAO;AACN,WAAO;MACNd,OAAO;MACPC,WAAW;MACXC,YAAY;MACZC,eAAe;MACfC,eAAe;MACfC,UAAU;MACVC,SAAS;MACTC,SAAS;MACTC,iBAAiB;MACjBC,UAAU;MACVC,UAAU;MACVC,iBAAiB;MACjBC,gBAAgB;MAChBC,gBAAgB;MAChBC,MAAM;IACP;EACD;AACD;AAtCgBhB;AAwCT,SAASiB,qBAAqBC,OAAwB;AAC5DA,QAAMR,kBACLQ,MAAMb,kBAAkB,KACxBa,MAAMZ,kBAAkB,KACxBY,MAAMV,YAAY,KAClBU,MAAMT,YAAY,KAClBS,MAAMX,aAAa;AACrB;AAPgBU;","names":["createDefaultContextState","centered","alpha","pixelated","line_width","translation_x","translation_y","rotation","scale_x","scale_y","image_transform","anchor_x","anchor_y","object_rotation","object_scale_x","object_scale_y","font","updateImageTransform","state"]}
|