@pixerate/editor 0.226.0 → 0.227.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/dist/animation-editor/index.cjs +57 -57
- package/dist/animation-editor/index.js +3 -3
- package/dist/{brushstrokeRender-C3UU6GVC.js → brushstrokeRender-MAHOXL7K.js} +2 -2
- package/dist/{brushstrokeRender-EAJNE6WP.cjs → brushstrokeRender-WDTKD54B.cjs} +5 -5
- package/dist/canvas/index.cjs +8 -8
- package/dist/canvas/index.js +1 -1
- package/dist/{chunk-LCCMOWR7.cjs → chunk-ATKKG76G.cjs} +23 -23
- package/dist/{chunk-QAUIZPYI.cjs → chunk-BQE3Y6ZO.cjs} +2 -2
- package/dist/{chunk-G4E6RUPC.js → chunk-CDP2AKMA.js} +1 -1
- package/dist/{chunk-NDMXB4PR.js → chunk-CU6ANS5L.js} +1 -1
- package/dist/{chunk-ROVK6AXX.cjs → chunk-GNZI3KYK.cjs} +95 -23
- package/dist/{chunk-I7G3RSUJ.cjs → chunk-GXLZZVR5.cjs} +35 -35
- package/dist/{chunk-5YLOU7VF.js → chunk-KN3Y3FRY.js} +1 -1
- package/dist/{chunk-IWMDW7LB.cjs → chunk-MXJP77K4.cjs} +86 -86
- package/dist/{chunk-F7YA3MMC.js → chunk-TQOL6CF7.js} +76 -4
- package/dist/{chunk-ZMHPQ6HP.cjs → chunk-V3L7U63N.cjs} +1 -1
- package/dist/{chunk-DJBYJOHM.js → chunk-XSVUNSDJ.js} +1 -1
- package/dist/{chunk-BGOCAUXH.js → chunk-YMREOA67.js} +1 -1
- package/dist/image-editor/index.cjs +771 -771
- package/dist/image-editor/index.js +4 -4
- package/dist/paint-editor/controller.d.cts +54 -3
- package/dist/paint-editor/controller.d.ts +54 -3
- package/dist/paint-editor/dab-stroke.d.cts +3 -0
- package/dist/paint-editor/dab-stroke.d.ts +3 -0
- package/dist/paint-editor/effect-paint.d.cts +47 -0
- package/dist/paint-editor/effect-paint.d.ts +47 -0
- package/dist/paint-editor/effect-tools.d.cts +4 -2
- package/dist/paint-editor/effect-tools.d.ts +4 -2
- package/dist/paint-editor/effects.d.cts +3 -0
- package/dist/paint-editor/effects.d.ts +3 -0
- package/dist/paint-editor/engine.d.cts +4 -0
- package/dist/paint-editor/engine.d.ts +4 -0
- package/dist/paint-editor/index.cjs +536 -309
- package/dist/paint-editor/index.d.cts +1 -0
- package/dist/paint-editor/index.d.ts +1 -0
- package/dist/paint-editor/index.js +250 -23
- package/dist/paint-editor/procedural.d.cts +4 -0
- package/dist/paint-editor/procedural.d.ts +4 -0
- package/dist/paint-editor/stroke.d.cts +9 -0
- package/dist/paint-editor/stroke.d.ts +9 -0
- package/dist/paint-editor/strokes.d.cts +6 -2
- package/dist/paint-editor/strokes.d.ts +6 -2
- package/dist/vector/index.cjs +962 -962
- package/dist/vector/index.js +4 -4
- package/package.json +1 -1
- package/skills/pixerate-canvas/SKILL.md +2 -1
- package/skills/pixerate-paint-editor/SKILL.md +42 -6
- package/skills/pixerate-paint-sketch-to-finish/SKILL.md +7 -0
|
@@ -28,6 +28,58 @@ import {
|
|
|
28
28
|
tileKey
|
|
29
29
|
} from "./chunk-HVVR5PZW.js";
|
|
30
30
|
|
|
31
|
+
// src/paint-editor/effect-paint.ts
|
|
32
|
+
function effectPaintKey(p) {
|
|
33
|
+
return JSON.stringify({ type: "effect", effect: p.effect, provider: p.provider, values: p.values, time: p.time });
|
|
34
|
+
}
|
|
35
|
+
function isPaintEffectPaint(raw) {
|
|
36
|
+
return Boolean(raw) && typeof raw === "object" && raw.type === "effect";
|
|
37
|
+
}
|
|
38
|
+
function readPaintEffectPaint(raw) {
|
|
39
|
+
if (!isPaintEffectPaint(raw)) return null;
|
|
40
|
+
const r = raw;
|
|
41
|
+
if (typeof r.effect !== "string" || !r.effect || !r.values || typeof r.values !== "object" || Array.isArray(r.values)) return null;
|
|
42
|
+
return {
|
|
43
|
+
type: "effect",
|
|
44
|
+
effect: r.effect,
|
|
45
|
+
provider: typeof r.provider === "string" ? r.provider : "",
|
|
46
|
+
values: JSON.parse(JSON.stringify(r.values)),
|
|
47
|
+
time: typeof r.time === "number" && Number.isFinite(r.time) && r.time > 0 ? r.time : 0
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function sampleEffectField(img, rect, vals, field) {
|
|
51
|
+
const { width, height, data } = img;
|
|
52
|
+
for (let yy = 0, k = 0; yy < rect.height; yy++) {
|
|
53
|
+
const y = rect.y + yy;
|
|
54
|
+
const inY = y >= 0 && y < height;
|
|
55
|
+
for (let xx = 0; xx < rect.width; xx++, k++) {
|
|
56
|
+
const x = rect.x + xx;
|
|
57
|
+
const f = k * 3;
|
|
58
|
+
if (!inY || x < 0 || x >= width) {
|
|
59
|
+
vals[k] = 0;
|
|
60
|
+
field[f] = field[f + 1] = field[f + 2] = 0;
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
const i = (y * width + x) * 4;
|
|
64
|
+
const a = data[i + 3];
|
|
65
|
+
if (a < 255) vals[k] *= a / 255;
|
|
66
|
+
field[f] = data[i] / 255;
|
|
67
|
+
field[f + 1] = data[i + 1] / 255;
|
|
68
|
+
field[f + 2] = data[i + 2] / 255;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function sampleEffectAt(img, x, y, out) {
|
|
73
|
+
const px = Math.floor(x);
|
|
74
|
+
const py = Math.floor(y);
|
|
75
|
+
if (px < 0 || py < 0 || px >= img.width || py >= img.height) return 0;
|
|
76
|
+
const i = (py * img.width + px) * 4;
|
|
77
|
+
out[0] = img.data[i] / 255;
|
|
78
|
+
out[1] = img.data[i + 1] / 255;
|
|
79
|
+
out[2] = img.data[i + 2] / 255;
|
|
80
|
+
return img.data[i + 3] / 255;
|
|
81
|
+
}
|
|
82
|
+
|
|
31
83
|
// src/paint-editor/paper.ts
|
|
32
84
|
var PAPER_FAMILIES = ["watercolor", "drawing", "pastel", "canvas", "panel", "smooth"];
|
|
33
85
|
var unit = (v, d) => typeof v === "number" && Number.isFinite(v) ? Math.min(1, Math.max(0, v)) : d;
|
|
@@ -386,6 +438,7 @@ var DryStroke = class {
|
|
|
386
438
|
copies;
|
|
387
439
|
depth;
|
|
388
440
|
buf = new Float32Array(0);
|
|
441
|
+
field = new Float32Array(0);
|
|
389
442
|
lastRaw = null;
|
|
390
443
|
lastFed = null;
|
|
391
444
|
/** Feeds raw pen samples; returns the document rectangles the new dabs touched. */
|
|
@@ -426,7 +479,13 @@ var DryStroke = class {
|
|
|
426
479
|
}
|
|
427
480
|
}
|
|
428
481
|
}
|
|
429
|
-
|
|
482
|
+
let field = null;
|
|
483
|
+
if (this.options.effect) {
|
|
484
|
+
if (this.field.length < n * 3) this.field = new Float32Array(n * 3);
|
|
485
|
+
field = this.field.subarray(0, n * 3);
|
|
486
|
+
sampleEffectField(this.options.effect, rect, vals, field);
|
|
487
|
+
}
|
|
488
|
+
this.coverage.accumulate(rect, vals, d.opacity, null, field);
|
|
430
489
|
rects.push(rect);
|
|
431
490
|
this.dabCount++;
|
|
432
491
|
}
|
|
@@ -719,6 +778,7 @@ var MarkStroke = class {
|
|
|
719
778
|
walkers;
|
|
720
779
|
depth;
|
|
721
780
|
buf = new Float32Array(0);
|
|
781
|
+
field = new Float32Array(0);
|
|
722
782
|
lastRaw = null;
|
|
723
783
|
lastFed = null;
|
|
724
784
|
seed;
|
|
@@ -785,9 +845,16 @@ var MarkStroke = class {
|
|
|
785
845
|
for (let yy = 0, k = 0; yy < rect.height; yy++)
|
|
786
846
|
for (let xx = 0; xx < rect.width; xx++, k++) if (vals[k] > 0) vals[k] *= grainCatch(grain.at(rect.x + xx + 0.5, rect.y + yy + 0.5), this.depth, pressure);
|
|
787
847
|
}
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
848
|
+
if (this.options.effect) {
|
|
849
|
+
if (this.field.length < n * 3) this.field = new Float32Array(n * 3);
|
|
850
|
+
const field = this.field.subarray(0, n * 3);
|
|
851
|
+
sampleEffectField(this.options.effect, rect, vals, field);
|
|
852
|
+
this.coverage.accumulate(rect, vals, dab.opacity, null, field);
|
|
853
|
+
} else {
|
|
854
|
+
const color = this.markColor(x, y);
|
|
855
|
+
if (color && color.alpha < 1) for (let k = 0; k < n; k++) vals[k] *= color.alpha;
|
|
856
|
+
this.coverage.accumulate(rect, vals, dab.opacity, color ? color.rgb : null);
|
|
857
|
+
}
|
|
791
858
|
rects.push(rect);
|
|
792
859
|
this.dabCount++;
|
|
793
860
|
}
|
|
@@ -1782,6 +1849,11 @@ function parseBrushLibrary(raw, problems = []) {
|
|
|
1782
1849
|
}
|
|
1783
1850
|
|
|
1784
1851
|
export {
|
|
1852
|
+
effectPaintKey,
|
|
1853
|
+
isPaintEffectPaint,
|
|
1854
|
+
readPaintEffectPaint,
|
|
1855
|
+
sampleEffectField,
|
|
1856
|
+
sampleEffectAt,
|
|
1785
1857
|
PAPER_FAMILIES,
|
|
1786
1858
|
PAPER_LIBRARY,
|
|
1787
1859
|
DEFAULT_PAPER,
|
|
@@ -74,7 +74,7 @@ function profileAlongPolyline(points, values, count = 32) {
|
|
|
74
74
|
var round3 = (v) => Math.round(v * 1e3) / 1e3;
|
|
75
75
|
var loading = null;
|
|
76
76
|
function loadCanvasBrushstrokeRenderer() {
|
|
77
|
-
loading ??= Promise.resolve().then(() => _interopRequireWildcard(require("./brushstrokeRender-
|
|
77
|
+
loading ??= Promise.resolve().then(() => _interopRequireWildcard(require("./brushstrokeRender-WDTKD54B.cjs"))).catch((error) => {
|
|
78
78
|
loading = null;
|
|
79
79
|
throw error;
|
|
80
80
|
});
|