@pixerate/editor 0.267.0 → 0.268.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 +62 -62
- package/dist/animation-editor/index.js +6 -6
- package/dist/brushes/index.cjs +198 -72
- package/dist/brushes/index.d.cts +4 -3
- package/dist/brushes/index.d.ts +4 -3
- package/dist/brushes/index.js +136 -10
- package/dist/brushes/library.d.cts +27 -1
- package/dist/brushes/library.d.ts +27 -1
- package/dist/brushes/profiles.d.cts +4 -0
- package/dist/brushes/profiles.d.ts +4 -0
- package/dist/brushes/schema.d.cts +4 -0
- package/dist/brushes/schema.d.ts +4 -0
- package/dist/brushes/sources.d.cts +114 -0
- package/dist/brushes/sources.d.ts +114 -0
- package/dist/brushes/types.d.cts +37 -5
- package/dist/brushes/types.d.ts +37 -5
- package/dist/brushes/ui.d.cts +40 -4
- package/dist/brushes/ui.d.ts +40 -4
- package/dist/{brushstrokeRender-NLFPEBGI.js → brushstrokeRender-A727TTNQ.js} +6 -6
- package/dist/{brushstrokeRender-L7JYRR2R.cjs → brushstrokeRender-WR2N5HHY.cjs} +22 -22
- package/dist/canvas/index.cjs +13 -13
- package/dist/canvas/index.js +1 -1
- package/dist/{chunk-J2TNIZ55.cjs → chunk-2WOGXEDX.cjs} +1 -1
- package/dist/{chunk-JGWVZPT6.js → chunk-3XDSNIGF.js} +72 -5
- package/dist/{chunk-EXB2EGBE.cjs → chunk-62MFUHSI.cjs} +16 -16
- package/dist/{chunk-FGJHJIMN.js → chunk-74ODPZLX.js} +10 -10
- package/dist/{chunk-GCVFEPJG.js → chunk-ACTHSQOI.js} +182 -0
- package/dist/{chunk-LHPEG5AU.cjs → chunk-B3G7BKUV.cjs} +90 -90
- package/dist/{chunk-EF7LZAXQ.js → chunk-BAZMCFVL.js} +1 -1
- package/dist/{chunk-HIO6E7LC.cjs → chunk-BPJSI4NT.cjs} +2 -2
- package/dist/{chunk-XVOP3CGQ.cjs → chunk-EU2ZZA6L.cjs} +393 -62
- package/dist/{chunk-YIC6MAJ2.js → chunk-HFY5LG5J.js} +1 -1
- package/dist/{chunk-7UKFXXWL.js → chunk-HVO6XCI4.js} +1 -1
- package/dist/{chunk-OKHKA43L.cjs → chunk-JBB3GDBB.cjs} +330 -216
- package/dist/{chunk-AGNUD5BI.js → chunk-KZI3YWKW.js} +351 -20
- package/dist/{chunk-EYSHTYLG.js → chunk-LETF75CA.js} +1 -1
- package/dist/{chunk-FQPUF2W2.cjs → chunk-NIBFKXMD.cjs} +217 -35
- package/dist/{chunk-G7NHE2VD.cjs → chunk-NPWWSCWT.cjs} +35 -35
- package/dist/{chunk-OSEXT7JL.js → chunk-QNY7BDFP.js} +1 -1
- package/dist/{chunk-PXDIAYB6.cjs → chunk-STLTOISW.cjs} +34 -214
- package/dist/{chunk-4IDUYB45.js → chunk-UVTO3D4E.js} +130 -16
- package/dist/{chunk-TXFWZ5ZJ.js → chunk-W6JDUXP3.js} +4 -184
- package/dist/{chunk-LA5Y4ETA.cjs → chunk-YOVXQHA3.cjs} +23 -23
- package/dist/{chunk-DT4YQUGT.cjs → chunk-YXP6X3SY.cjs} +101 -34
- package/dist/image-editor/index.cjs +851 -851
- package/dist/image-editor/index.js +23 -23
- package/dist/paint/index.cjs +5 -5
- package/dist/paint/index.js +11 -11
- package/dist/paint-editor/brush-library-tools.d.cts +12 -2
- package/dist/paint-editor/brush-library-tools.d.ts +12 -2
- package/dist/paint-editor/brush-model.d.cts +29 -1
- package/dist/paint-editor/brush-model.d.ts +29 -1
- package/dist/paint-editor/brush-source-art.d.cts +32 -0
- package/dist/paint-editor/brush-source-art.d.ts +32 -0
- package/dist/paint-editor/controller.d.cts +6 -1
- package/dist/paint-editor/controller.d.ts +6 -1
- package/dist/paint-editor/dab-stroke.d.cts +2 -0
- package/dist/paint-editor/dab-stroke.d.ts +2 -0
- package/dist/paint-editor/engine.d.cts +11 -2
- package/dist/paint-editor/engine.d.ts +11 -2
- package/dist/paint-editor/index.cjs +576 -481
- package/dist/paint-editor/index.d.cts +3 -1
- package/dist/paint-editor/index.d.ts +3 -1
- package/dist/paint-editor/index.js +127 -32
- package/dist/paint-editor/stamp-tip.d.cts +8 -5
- package/dist/paint-editor/stamp-tip.d.ts +8 -5
- package/dist/paint-editor/thumbnails.d.cts +6 -0
- package/dist/paint-editor/thumbnails.d.ts +6 -0
- package/dist/paint-editor/tip-grain.d.cts +34 -0
- package/dist/paint-editor/tip-grain.d.ts +34 -0
- package/dist/raster/index.cjs +2 -2
- package/dist/raster/index.js +9 -9
- package/dist/vector/index.cjs +1002 -1002
- package/dist/vector/index.js +7 -7
- package/package.json +1 -1
- package/skills/pixerate-brushes/SKILL.md +35 -8
- package/skills/pixerate-brushes-design/SKILL.md +8 -1
- package/skills/pixerate-paint-editor/SKILL.md +6 -0
- package/skills/pixerate-paint-editor/references/brush-facets.md +3 -1
- package/skills/pixerate-paint-sketch-to-finish/SKILL.md +1 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var _chunkFQPUF2W2cjs = require('./chunk-FQPUF2W2.cjs');
|
|
14
13
|
|
|
15
14
|
|
|
15
|
+
var _chunkNIBFKXMDcjs = require('./chunk-NIBFKXMD.cjs');
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
var _chunk3K6HWEXZcjs = require('./chunk-3K6HWEXZ.cjs');
|
|
@@ -34,180 +34,6 @@ var _chunkW5M3J7PVcjs = require('./chunk-W5M3J7PV.cjs');
|
|
|
34
34
|
|
|
35
35
|
var _chunk474IQG74cjs = require('./chunk-474IQG74.cjs');
|
|
36
36
|
|
|
37
|
-
// src/paint/grain.ts
|
|
38
|
-
var GRAIN_PATTERNS = ["smooth", "cold-pressed", "hot-pressed", "rough", "vellum", "laid", "ingres", "sanded", "canvas", "linen", "gesso"];
|
|
39
|
-
var GRAIN_TILE = 256;
|
|
40
|
-
var clamp01 = (v) => v < 0 ? 0 : v > 1 ? 1 : v;
|
|
41
|
-
function patternHeights(pattern, n, seed) {
|
|
42
|
-
const out = new Float32Array(n * n);
|
|
43
|
-
const salt = Math.imul(seed | 0, 2654435761) + 17;
|
|
44
|
-
if (pattern === "smooth") return out.fill(1);
|
|
45
|
-
const noise = (cx, cy, oct, s = 0) => new (0, _chunk3K6HWEXZcjs.TileableNoise)(n, cx, cy, oct, salt + s);
|
|
46
|
-
const k = n / GRAIN_TILE;
|
|
47
|
-
switch (pattern) {
|
|
48
|
-
case "cold-pressed": {
|
|
49
|
-
const base = noise(20 * k, 20 * k, 4);
|
|
50
|
-
const fine = noise(64 * k, 64 * k, 2, 3);
|
|
51
|
-
for (let y = 0; y < n; y++)
|
|
52
|
-
for (let x = 0; x < n; x++) out[y * n + x] = clamp01((base.at(x, y) - 0.5) * 1.8 + 0.5 + (fine.at(x, y) - 0.5) * 0.5 + (_chunk3K6HWEXZcjs.hash2.call(void 0, x, y, salt) - 0.5) * 0.12);
|
|
53
|
-
break;
|
|
54
|
-
}
|
|
55
|
-
case "hot-pressed": {
|
|
56
|
-
const base = noise(40 * k, 40 * k, 3);
|
|
57
|
-
for (let y = 0; y < n; y++) for (let x = 0; x < n; x++) out[y * n + x] = clamp01((base.at(x, y) - 0.5) * 1.1 + 0.6 + (_chunk3K6HWEXZcjs.hash2.call(void 0, x, y, salt) - 0.5) * 0.08);
|
|
58
|
-
break;
|
|
59
|
-
}
|
|
60
|
-
case "rough": {
|
|
61
|
-
const base = noise(10 * k, 10 * k, 5);
|
|
62
|
-
const blot = noise(28 * k, 28 * k, 2, 5);
|
|
63
|
-
for (let y = 0; y < n; y++)
|
|
64
|
-
for (let x = 0; x < n; x++) out[y * n + x] = clamp01((base.at(x, y) - 0.5) * 2.4 + 0.5 + (blot.at(x, y) - 0.5) * 0.7 + (_chunk3K6HWEXZcjs.hash2.call(void 0, x, y, salt) - 0.5) * 0.15);
|
|
65
|
-
break;
|
|
66
|
-
}
|
|
67
|
-
case "vellum": {
|
|
68
|
-
const base = noise(40 * k, 40 * k, 3);
|
|
69
|
-
for (let y = 0; y < n; y++) for (let x = 0; x < n; x++) out[y * n + x] = clamp01((base.at(x, y) - 0.5) * 1.6 + 0.55 + (_chunk3K6HWEXZcjs.hash2.call(void 0, x, y, salt) - 0.5) * 0.2);
|
|
70
|
-
break;
|
|
71
|
-
}
|
|
72
|
-
case "laid": {
|
|
73
|
-
const pulp = noise(32 * k, 32 * k, 3);
|
|
74
|
-
const chain = n / 8;
|
|
75
|
-
for (let y = 0; y < n; y++) {
|
|
76
|
-
const laid = 0.5 + 0.5 * Math.cos(2 * Math.PI * y / 4);
|
|
77
|
-
for (let x = 0; x < n; x++) {
|
|
78
|
-
const c = Math.abs((x + 0.5) % chain - chain / 2) / (chain / 2);
|
|
79
|
-
const chainLine = c > 0.94 ? -0.35 : 0;
|
|
80
|
-
out[y * n + x] = clamp01(0.3 + 0.5 * laid + chainLine + (pulp.at(x, y) - 0.5) * 0.6);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
case "ingres": {
|
|
86
|
-
const fibres = noise(64 * k, 12 * k, 3);
|
|
87
|
-
const base = noise(16 * k, 16 * k, 3, 7);
|
|
88
|
-
for (let y = 0; y < n; y++)
|
|
89
|
-
for (let x = 0; x < n; x++) {
|
|
90
|
-
const g = _chunk3K6HWEXZcjs.hash2.call(void 0, x, y, salt ^ 85);
|
|
91
|
-
out[y * n + x] = clamp01((fibres.at(x, y) - 0.5) * 1.5 + (base.at(x, y) - 0.5) * 0.7 + 0.55 + (g < 0.1 ? -0.3 : 0));
|
|
92
|
-
}
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
case "sanded": {
|
|
96
|
-
const grit = noise(96 * k, 96 * k, 2);
|
|
97
|
-
for (let y = 0; y < n; y++)
|
|
98
|
-
for (let x = 0; x < n; x++) {
|
|
99
|
-
const h = _chunk3K6HWEXZcjs.hash2.call(void 0, x, y, salt);
|
|
100
|
-
out[y * n + x] = clamp01((grit.at(x, y) - 0.5) * 2.4 + 0.5 + (h - 0.5) * 0.7);
|
|
101
|
-
}
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
case "canvas":
|
|
105
|
-
case "linen": {
|
|
106
|
-
const period = (pattern === "canvas" ? 8 : 5) * k;
|
|
107
|
-
const threads = Math.max(2, 2 * Math.round(n / period / 2));
|
|
108
|
-
const p = n / threads;
|
|
109
|
-
const slub = noise(threads, threads, 2, 11);
|
|
110
|
-
for (let y = 0; y < n; y++)
|
|
111
|
-
for (let x = 0; x < n; x++) {
|
|
112
|
-
const fx = (x + 0.5) / p;
|
|
113
|
-
const fy = (y + 0.5) / p;
|
|
114
|
-
const cx = Math.floor(fx);
|
|
115
|
-
const cy = Math.floor(fy);
|
|
116
|
-
const warp = Math.sin(Math.PI * (fx - cx));
|
|
117
|
-
const weft = Math.sin(Math.PI * (fy - cy));
|
|
118
|
-
const top = (cx + cy) % 2 === 0 ? warp : weft;
|
|
119
|
-
const irregular = pattern === "linen" ? (slub.at(x, y) - 0.5) * 0.5 : 0;
|
|
120
|
-
out[y * n + x] = clamp01(0.2 + 0.7 * top + irregular + (_chunk3K6HWEXZcjs.hash2.call(void 0, x, y, salt) - 0.5) * 0.15);
|
|
121
|
-
}
|
|
122
|
-
break;
|
|
123
|
-
}
|
|
124
|
-
case "gesso": {
|
|
125
|
-
const streaks = noise(2 * k, 28 * k, 3);
|
|
126
|
-
const tooth = noise(64 * k, 64 * k, 2, 13);
|
|
127
|
-
for (let y = 0; y < n; y++)
|
|
128
|
-
for (let x = 0; x < n; x++) out[y * n + x] = clamp01((streaks.at(x, y) - 0.5) * 1.8 + (tooth.at(x, y) - 0.5) * 0.9 + 0.55);
|
|
129
|
-
break;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
return out;
|
|
133
|
-
}
|
|
134
|
-
var rawCache = /* @__PURE__ */ new Map();
|
|
135
|
-
function grainHeights(pattern, seed, size = GRAIN_TILE) {
|
|
136
|
-
const key = `${pattern}:${seed}:${size}`;
|
|
137
|
-
let h = rawCache.get(key);
|
|
138
|
-
if (!h) {
|
|
139
|
-
h = patternHeights(pattern, size, seed);
|
|
140
|
-
if (rawCache.size > 32) rawCache.delete(rawCache.keys().next().value);
|
|
141
|
-
rawCache.set(key, h);
|
|
142
|
-
}
|
|
143
|
-
return h;
|
|
144
|
-
}
|
|
145
|
-
var PaperGrain = (_class = class {
|
|
146
|
-
__init() {this.size = GRAIN_TILE}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
constructor(paper, media = "dry") {;_class.prototype.__init.call(this);
|
|
154
|
-
const raw = grainHeights(paper.pattern, paper.seed);
|
|
155
|
-
const t = paper[media];
|
|
156
|
-
this.flat = paper.pattern === "smooth";
|
|
157
|
-
if (t.contrast === 1 && !t.invert) this.heights = raw;
|
|
158
|
-
else {
|
|
159
|
-
const out = new Float32Array(raw.length);
|
|
160
|
-
for (let i = 0; i < raw.length; i++) {
|
|
161
|
-
const v = clamp01((raw[i] - 0.5) * t.contrast + 0.5);
|
|
162
|
-
out[i] = t.invert ? 1 - v : v;
|
|
163
|
-
}
|
|
164
|
-
this.heights = out;
|
|
165
|
-
}
|
|
166
|
-
this.scale = paper.scale;
|
|
167
|
-
this.mirror = paper.tiling === "mirror";
|
|
168
|
-
this.ox = _nullishCoalesce(_optionalChain([paper, 'access', _ => _.offset, 'optionalAccess', _2 => _2.x]), () => ( 0));
|
|
169
|
-
this.oy = _nullishCoalesce(_optionalChain([paper, 'access', _3 => _3.offset, 'optionalAccess', _4 => _4.y]), () => ( 0));
|
|
170
|
-
}
|
|
171
|
-
/** Tile cell index for a coordinate in grain pixels (mirrored on odd tiles when mirroring). */
|
|
172
|
-
wrap(v) {
|
|
173
|
-
const n = this.size;
|
|
174
|
-
if (!this.mirror) return (v % n + n) % n;
|
|
175
|
-
const p = (v % (2 * n) + 2 * n) % (2 * n);
|
|
176
|
-
return p < n ? p : 2 * n - 1 - p;
|
|
177
|
-
}
|
|
178
|
-
/** Height 0..1 at document position (x, y). */
|
|
179
|
-
at(x, y) {
|
|
180
|
-
const u = (x - this.ox) / this.scale - 0.5;
|
|
181
|
-
const v = (y - this.oy) / this.scale - 0.5;
|
|
182
|
-
const x0 = Math.floor(u);
|
|
183
|
-
const y0 = Math.floor(v);
|
|
184
|
-
const fx = u - x0;
|
|
185
|
-
const fy = v - y0;
|
|
186
|
-
const n = this.size;
|
|
187
|
-
const h = this.heights;
|
|
188
|
-
const a = this.wrap(x0);
|
|
189
|
-
const b = this.wrap(x0 + 1);
|
|
190
|
-
const c = this.wrap(y0) * n;
|
|
191
|
-
const d = this.wrap(y0 + 1) * n;
|
|
192
|
-
const top = h[c + a] + (h[c + b] - h[c + a]) * fx;
|
|
193
|
-
const bot = h[d + a] + (h[d + b] - h[d + a]) * fx;
|
|
194
|
-
return top + (bot - top) * fy;
|
|
195
|
-
}
|
|
196
|
-
}, _class);
|
|
197
|
-
function grainCatch(h, depth, pressure) {
|
|
198
|
-
if (depth <= 0) return 1;
|
|
199
|
-
const t = depth * (0.75 - 0.65 * Math.min(1, Math.max(0, pressure)));
|
|
200
|
-
const u = clamp01((h - t + 0.18) / 0.36);
|
|
201
|
-
return 1 - depth + depth * u * u * (3 - 2 * u);
|
|
202
|
-
}
|
|
203
|
-
function strokeGrainCatch(h, depth, pressure) {
|
|
204
|
-
if (depth <= 0) return 1;
|
|
205
|
-
const p = Math.min(1, Math.max(0, pressure));
|
|
206
|
-
const amount = Math.min(1, depth * (1.4 - 0.6 * p));
|
|
207
|
-
const u = clamp01((h - 0.2 - 0.25 * (1 - p)) / 0.5);
|
|
208
|
-
return 1 - amount + amount * u * u * (3 - 2 * u);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
37
|
// src/paint/path-stroke.ts
|
|
212
38
|
var JITTER_SIZE = 1;
|
|
213
39
|
var JITTER_ANGLE = 2;
|
|
@@ -228,16 +54,16 @@ function lean(s) {
|
|
|
228
54
|
return null;
|
|
229
55
|
}
|
|
230
56
|
function pathStrokeDabs(samples, options) {
|
|
231
|
-
const brush =
|
|
57
|
+
const brush = _chunkNIBFKXMDcjs.normalizeBrush.call(void 0, options.brush);
|
|
232
58
|
const pts = options.closed && samples.length > 2 ? [...samples, samples[0]] : [...samples];
|
|
233
59
|
if (!pts.length) return [];
|
|
234
60
|
const tilt = _nullishCoalesce(options.tilt, () => ( {}));
|
|
235
61
|
const minSize = Math.min(1, Math.max(0, _nullishCoalesce(options.minSize, () => ( 0))));
|
|
236
62
|
let index = 0;
|
|
237
|
-
const t0 = _nullishCoalesce(_optionalChain([pts, 'access',
|
|
63
|
+
const t0 = _nullishCoalesce(_optionalChain([pts, 'access', _ => _.find, 'call', _2 => _2((s) => typeof s.t === "number" && Number.isFinite(s.t)), 'optionalAccess', _3 => _3.t]), () => ( null));
|
|
238
64
|
const dab = (x, y, p, l, dir, travel = 0, time = null, speed = null) => {
|
|
239
65
|
const pr = Math.min(1, Math.max(0, p));
|
|
240
|
-
const lean0 = _nullishCoalesce(_optionalChain([l, 'optionalAccess',
|
|
66
|
+
const lean0 = _nullishCoalesce(_optionalChain([l, 'optionalAccess', _4 => _4.amount]), () => ( 0));
|
|
241
67
|
const size = brush.size * (brush.pressureSize ? minSize + (1 - minSize) * pr : 1) * (1 + 1.5 * (_nullishCoalesce(tilt.size, () => ( 0))) * lean0);
|
|
242
68
|
let angle = brush.angle * Math.PI / 180;
|
|
243
69
|
if (options.followPath) angle += dir;
|
|
@@ -301,24 +127,24 @@ function pathStrokeDabs(samples, options) {
|
|
|
301
127
|
return out;
|
|
302
128
|
}
|
|
303
129
|
function pathStrokeCoverage(samples, options) {
|
|
304
|
-
const brush =
|
|
305
|
-
const coverage = new (0,
|
|
130
|
+
const brush = _chunkNIBFKXMDcjs.normalizeBrush.call(void 0, options.brush);
|
|
131
|
+
const coverage = new (0, _chunkNIBFKXMDcjs.CoverageMap)();
|
|
306
132
|
const dabs = pathStrokeDabs(samples, options);
|
|
307
|
-
const g = _optionalChain([options, 'access',
|
|
308
|
-
const sampler = g ? new (0,
|
|
309
|
-
const tipTable = _optionalChain([sampler, 'optionalAccess',
|
|
133
|
+
const g = _optionalChain([options, 'access', _5 => _5.gradient, 'optionalAccess', _6 => _6.paint, 'access', _7 => _7.type]) === "gradient" ? options.gradient : null;
|
|
134
|
+
const sampler = g ? new (0, _chunkNIBFKXMDcjs.PaintGradientSampler)(_chunkNIBFKXMDcjs.resolvePaintGradient.call(void 0, g.paint, _nullishCoalesce(g.colors, () => ( { paint: "#000000", secondary: "#ffffff" }))), _nullishCoalesce(g.seed, () => ( 0))) : null;
|
|
135
|
+
const tipTable = _optionalChain([sampler, 'optionalAccess', _8 => _8.acrossTip]) ? sampler.tipTable(_chunkNIBFKXMDcjs.TIP_GRADIENT_STEPS) : null;
|
|
310
136
|
const scratch = { field: new Float32Array(0), sample: { rgb: [0, 0, 0], alpha: 1 } };
|
|
311
137
|
let buf = new Float32Array(0);
|
|
312
138
|
let bounds = null;
|
|
313
139
|
for (const d of dabs) {
|
|
314
|
-
const rect =
|
|
140
|
+
const rect = _chunkNIBFKXMDcjs.dabRect.call(void 0, d, brush.hardness);
|
|
315
141
|
const n = rect.width * rect.height;
|
|
316
142
|
if (n <= 0) continue;
|
|
317
143
|
if (buf.length < n) buf = new Float32Array(n);
|
|
318
144
|
const vals = buf.subarray(0, n);
|
|
319
|
-
|
|
145
|
+
_chunkNIBFKXMDcjs.rasterizeDab.call(void 0, d, brush.hardness, rect, vals);
|
|
320
146
|
if (sampler) {
|
|
321
|
-
const { color, field } =
|
|
147
|
+
const { color, field } = _chunkNIBFKXMDcjs.gradientDabColor.call(void 0, sampler, tipTable, d, d.params, rect, vals, scratch);
|
|
322
148
|
coverage.accumulate(rect, vals, d.opacity, color, field);
|
|
323
149
|
} else coverage.accumulate(rect, vals, d.opacity);
|
|
324
150
|
if (!bounds) bounds = { ...rect };
|
|
@@ -330,12 +156,12 @@ function pathStrokeCoverage(samples, options) {
|
|
|
330
156
|
}
|
|
331
157
|
const grain = options.grain;
|
|
332
158
|
if (grain && grain.depth > 0 && dabs.length) {
|
|
333
|
-
const pressure = dabs.reduce((sum, d) => sum + (_nullishCoalesce(_optionalChain([d, 'access',
|
|
159
|
+
const pressure = dabs.reduce((sum, d) => sum + (_nullishCoalesce(_optionalChain([d, 'access', _9 => _9.params, 'optionalAccess', _10 => _10.pressure]), () => ( 1))), 0) / dabs.length;
|
|
334
160
|
for (const [key, t] of coverage.tiles) {
|
|
335
161
|
const { tx, ty } = _chunk474IQG74cjs.tileCoord.call(void 0, key);
|
|
336
162
|
for (let y = 0, k = 0; y < _chunk474IQG74cjs.TILE; y++) {
|
|
337
163
|
const gy = ty * _chunk474IQG74cjs.TILE + y + 0.5;
|
|
338
|
-
for (let x = 0; x < _chunk474IQG74cjs.TILE; x++, k++) if (t[k] > 0) t[k] *= strokeGrainCatch(grain.at(tx * _chunk474IQG74cjs.TILE + x + 0.5, gy), grain.depth, pressure);
|
|
164
|
+
for (let x = 0; x < _chunk474IQG74cjs.TILE; x++, k++) if (t[k] > 0) t[k] *= _chunkNIBFKXMDcjs.strokeGrainCatch.call(void 0, grain.at(tx * _chunk474IQG74cjs.TILE + x + 0.5, gy), grain.depth, pressure);
|
|
339
165
|
}
|
|
340
166
|
}
|
|
341
167
|
}
|
|
@@ -343,14 +169,14 @@ function pathStrokeCoverage(samples, options) {
|
|
|
343
169
|
}
|
|
344
170
|
function paintPathStroke(surface, samples, options) {
|
|
345
171
|
if (surface.channels !== 4) throw new Error("paintPathStroke paints RGBA surfaces (4 channels).");
|
|
346
|
-
const brush =
|
|
172
|
+
const brush = _chunkNIBFKXMDcjs.normalizeBrush.call(void 0, options.brush);
|
|
347
173
|
const hex = (c) => "#" + [0, 1, 2].map((i) => Math.round(Math.min(255, Math.max(0, c[i]))).toString(16).padStart(2, "0")).join("");
|
|
348
174
|
let color = options.color;
|
|
349
|
-
if (_optionalChain([options, 'access',
|
|
350
|
-
const rgb =
|
|
175
|
+
if (_optionalChain([options, 'access', _11 => _11.paint, 'optionalAccess', _12 => _12.paint, 'access', _13 => _13.type]) === "color") {
|
|
176
|
+
const rgb = _chunkNIBFKXMDcjs.hexToPaintRgb.call(void 0, options.paint.paint.color).map((v) => Math.round(v * 255));
|
|
351
177
|
color = [rgb[0], rgb[1], rgb[2], color[3]];
|
|
352
178
|
}
|
|
353
|
-
const gradient = _optionalChain([options, 'access',
|
|
179
|
+
const gradient = _optionalChain([options, 'access', _14 => _14.paint, 'optionalAccess', _15 => _15.paint, 'access', _16 => _16.type]) === "gradient" ? { ...options.paint, colors: _nullishCoalesce(options.paint.colors, () => ( { paint: hex(color), secondary: "#ffffff" })) } : null;
|
|
354
180
|
const { coverage, bounds, dabs } = pathStrokeCoverage(samples, { ...options, gradient });
|
|
355
181
|
if (!bounds) return { surface, bounds: null, dabs };
|
|
356
182
|
const offset = _nullishCoalesce(options.offset, () => ( { x: 0, y: 0 }));
|
|
@@ -367,9 +193,9 @@ function paintPathStroke(surface, samples, options) {
|
|
|
367
193
|
const tiles = new Map(surface.tiles);
|
|
368
194
|
for (const { tx, ty } of _chunk474IQG74cjs.tilesInRect.call(void 0, { x: bounds.x - offset.x, y: bounds.y - offset.y, width: bounds.width, height: bounds.height })) {
|
|
369
195
|
const key = _chunk474IQG74cjs.tileKey.call(void 0, tx, ty);
|
|
370
|
-
const src = _optionalChain([surface, 'access',
|
|
196
|
+
const src = _optionalChain([surface, 'access', _17 => _17.tiles, 'access', _18 => _18.get, 'call', _19 => _19(key), 'optionalAccess', _20 => _20.data]);
|
|
371
197
|
const base = src && src.length === _chunk474IQG74cjs.TILE * _chunk474IQG74cjs.TILE * 4 ? src : new Uint8ClampedArray(_chunk474IQG74cjs.TILE * _chunk474IQG74cjs.TILE * 4);
|
|
372
|
-
const t = _chunk474IQG74cjs.finishTile.call(void 0,
|
|
198
|
+
const t = _chunk474IQG74cjs.finishTile.call(void 0, _chunkNIBFKXMDcjs.applyStrokeToTile.call(void 0, coverage, base, 4, tx, ty, apply), 4, surface.defaultValue);
|
|
373
199
|
if (t) tiles.set(key, t);
|
|
374
200
|
else tiles.delete(key);
|
|
375
201
|
}
|
|
@@ -413,7 +239,7 @@ var REFUSED_ENGINES = {
|
|
|
413
239
|
};
|
|
414
240
|
function brushstrokeStrokeOptions(brush) {
|
|
415
241
|
if (!brush || typeof brush !== "object") throw new Error("A brushstroke needs a brush: tip settings ({ size, hardness, \u2026 }) or a paint brush preset.");
|
|
416
|
-
if (!("tip" in brush) || !brush.tip) return { brush:
|
|
242
|
+
if (!("tip" in brush) || !brush.tip) return { brush: _chunkNIBFKXMDcjs.normalizeBrush.call(void 0, brush) };
|
|
417
243
|
const engine = _nullishCoalesce(brush.engine, () => ( "dab"));
|
|
418
244
|
if (engine !== "dab") {
|
|
419
245
|
const label = _nullishCoalesce(_nullishCoalesce(brush.name, () => ( brush.id)), () => ( "This brush"));
|
|
@@ -423,7 +249,7 @@ function brushstrokeStrokeOptions(brush) {
|
|
|
423
249
|
const d = _nullishCoalesce(brush.dynamics, () => ( {}));
|
|
424
250
|
const tilt = { size: _nullishCoalesce(d.tiltSize, () => ( 0)), roundness: _nullishCoalesce(d.tiltRoundness, () => ( 0)) };
|
|
425
251
|
return {
|
|
426
|
-
brush:
|
|
252
|
+
brush: _chunkNIBFKXMDcjs.normalizeBrush.call(void 0, brush.tip),
|
|
427
253
|
followPath: brush.rotation === "stroke",
|
|
428
254
|
minSize: _nullishCoalesce(d.minSize, () => ( 0)),
|
|
429
255
|
...tilt.size || tilt.roundness ? { tilt } : {}
|
|
@@ -447,7 +273,7 @@ function paperGrain(paper) {
|
|
|
447
273
|
const key = `${pattern}:${seed}:${scale}`;
|
|
448
274
|
let g = papers.get(key);
|
|
449
275
|
if (!g) {
|
|
450
|
-
g = new PaperGrain({ pattern, seed, scale, tiling: "mirror", dry: { contrast: 1, invert: false }, wet: { contrast: 1, invert: false } });
|
|
276
|
+
g = new (0, _chunkNIBFKXMDcjs.PaperGrain)({ pattern, seed, scale, tiling: "mirror", dry: { contrast: 1, invert: false }, wet: { contrast: 1, invert: false } });
|
|
451
277
|
if (papers.size > 16) papers.delete(papers.keys().next().value);
|
|
452
278
|
papers.set(key, g);
|
|
453
279
|
}
|
|
@@ -463,7 +289,7 @@ function renderBrushstroke(input, brush, options = {}) {
|
|
|
463
289
|
let scale = finite(options.scale) && options.scale > 0 ? Math.min(_chunkYQGCPL5Xcjs.BRUSHSTROKE_MAX_SCALE, Math.max(_chunkYQGCPL5Xcjs.BRUSHSTROKE_MIN_SCALE, options.scale)) : 1;
|
|
464
290
|
if (!samples.length) return { image: { width: 0, height: 0, data: new Uint8ClampedArray(0) }, bounds: null, scale, dabs: 0 };
|
|
465
291
|
const tip = strokeOptions.brush;
|
|
466
|
-
const reach = tip.size * (1 + 1.5 * (_nullishCoalesce(_optionalChain([strokeOptions, 'access',
|
|
292
|
+
const reach = tip.size * (1 + 1.5 * (_nullishCoalesce(_optionalChain([strokeOptions, 'access', _21 => _21.tilt, 'optionalAccess', _22 => _22.size]), () => ( 0)))) + 4;
|
|
467
293
|
let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;
|
|
468
294
|
for (const s of samples) {
|
|
469
295
|
x0 = Math.min(x0, s.x);
|
|
@@ -486,8 +312,8 @@ function renderBrushstroke(input, brush, options = {}) {
|
|
|
486
312
|
let grain;
|
|
487
313
|
if (paper && depth > 0) {
|
|
488
314
|
const g = paperGrain(paper);
|
|
489
|
-
const ox = _nullishCoalesce(_optionalChain([ch, 'access',
|
|
490
|
-
const oy = _nullishCoalesce(_optionalChain([ch, 'access',
|
|
315
|
+
const ox = _nullishCoalesce(_optionalChain([ch, 'access', _23 => _23.origin, 'optionalAccess', _24 => _24.x]), () => ( 0));
|
|
316
|
+
const oy = _nullishCoalesce(_optionalChain([ch, 'access', _25 => _25.origin, 'optionalAccess', _26 => _26.y]), () => ( 0));
|
|
491
317
|
const k = (finite(ch.unit) && ch.unit > 0 ? ch.unit : 1) / scale;
|
|
492
318
|
grain = { depth, at: (x, y) => g.at(ox + x * k, oy + y * k) };
|
|
493
319
|
}
|
|
@@ -500,7 +326,7 @@ function renderBrushstroke(input, brush, options = {}) {
|
|
|
500
326
|
closed: _nullishCoalesce(options.closed, () => ( strokeOptions.closed)),
|
|
501
327
|
color,
|
|
502
328
|
// Gradient lengths are in path units: scale them with the image.
|
|
503
|
-
...source ? { paint: { paint: source.type === "gradient" ?
|
|
329
|
+
...source ? { paint: { paint: source.type === "gradient" ? _chunkNIBFKXMDcjs.scalePaintGradient.call(void 0, source, scale) : source, seed: _nullishCoalesce(options.seed, () => ( 0)) } } : {}
|
|
504
330
|
});
|
|
505
331
|
if (!bounds) return { image: { width: 0, height: 0, data: new Uint8ClampedArray(0) }, bounds: null, scale, dabs };
|
|
506
332
|
const rect = bounds;
|
|
@@ -542,14 +368,14 @@ function brushstrokeKey(input, brush, options = {}) {
|
|
|
542
368
|
const scale = finite(options.scale) ? options.scale : 1;
|
|
543
369
|
return `${hashString(path).toString(16)}:${path.length}:${hashString(rest2).toString(16)}:${scale}`;
|
|
544
370
|
}
|
|
545
|
-
var BrushstrokeCache = (
|
|
546
|
-
constructor(capacity = 64) {;
|
|
371
|
+
var BrushstrokeCache = (_class = class {
|
|
372
|
+
constructor(capacity = 64) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);
|
|
547
373
|
this.capacity = capacity;
|
|
548
374
|
}
|
|
549
375
|
|
|
550
|
-
|
|
376
|
+
__init() {this.entries = /* @__PURE__ */ new Map()}
|
|
551
377
|
/** Renders that missed the cache (for tests and stats). */
|
|
552
|
-
|
|
378
|
+
__init2() {this.misses = 0}
|
|
553
379
|
get size() {
|
|
554
380
|
return this.entries.size;
|
|
555
381
|
}
|
|
@@ -571,13 +397,7 @@ var BrushstrokeCache = (_class2 = class {
|
|
|
571
397
|
clear() {
|
|
572
398
|
this.entries.clear();
|
|
573
399
|
}
|
|
574
|
-
},
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
400
|
+
}, _class);
|
|
581
401
|
|
|
582
402
|
|
|
583
403
|
|
|
@@ -591,4 +411,4 @@ var BrushstrokeCache = (_class2 = class {
|
|
|
591
411
|
|
|
592
412
|
|
|
593
413
|
|
|
594
|
-
exports.
|
|
414
|
+
exports.pathStrokeDabs = pathStrokeDabs; exports.pathStrokeCoverage = pathStrokeCoverage; exports.paintPathStroke = paintPathStroke; exports.brushstrokeSamples = brushstrokeSamples; exports.brushstrokeStrokeOptions = brushstrokeStrokeOptions; exports.isBrushstrokeBrush = isBrushstrokeBrush; exports.renderBrushstroke = renderBrushstroke; exports.brushstrokeDataUrl = brushstrokeDataUrl; exports.brushstrokeToCanvas = brushstrokeToCanvas; exports.brushstrokeKey = brushstrokeKey; exports.BrushstrokeCache = BrushstrokeCache;
|