@pixerate/editor 0.137.0 → 0.139.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/agent/index.cjs +2 -2
- package/dist/agent/index.d.cts +3 -3
- package/dist/agent/index.d.ts +3 -3
- package/dist/agent/index.js +1 -1
- package/dist/animation-editor/index.cjs +57 -57
- package/dist/animation-editor/index.d.cts +6 -5
- package/dist/animation-editor/index.d.ts +6 -5
- package/dist/animation-editor/index.js +4 -4
- package/dist/{arrange-CKXK_hf7.d.cts → arrange-j_mLiFMO.d.cts} +1 -1
- package/dist/{arrange-BUREmgD9.d.ts → arrange-q5HQvnnB.d.ts} +1 -1
- package/dist/{bezier-Dywv3Bw8.d.ts → bezier-B6cK8SR6.d.ts} +2 -2
- package/dist/{bezier-CZ2AhjID.d.cts → bezier-CEJ8Uw4O.d.cts} +2 -2
- package/dist/{brushTypes-C7N3EBK7.d.cts → brushTypes-MX5UVs_m.d.cts} +27 -2
- package/dist/{brushTypes-C7N3EBK7.d.ts → brushTypes-MX5UVs_m.d.ts} +27 -2
- package/dist/{brushes-DJmUbIgz.d.ts → brushes-CQpL7_Lc.d.ts} +2 -107
- package/dist/{brushes-CnvZSYYU.d.cts → brushes-aEnjqoji.d.cts} +2 -107
- package/dist/{brushstrokeRender-IMFY3FF6.cjs → brushstrokeRender-PP6NTF6M.cjs} +52 -24
- package/dist/brushstrokeRender-PP6NTF6M.cjs.map +1 -0
- package/dist/{brushstrokeRender-2FAXA3XC.js → brushstrokeRender-QGEYJ4OZ.js} +40 -12
- package/dist/brushstrokeRender-QGEYJ4OZ.js.map +1 -0
- package/dist/{builtins-Cc-bH-3U.d.cts → builtins-BakDiKWf.d.cts} +3 -2
- package/dist/{builtins-ZU1GJnUA.d.ts → builtins-CE33vyv2.d.ts} +3 -2
- package/dist/canvas/index.cjs +16 -9
- package/dist/canvas/index.cjs.map +1 -1
- package/dist/canvas/index.d.cts +60 -14
- package/dist/canvas/index.d.ts +60 -14
- package/dist/canvas/index.js +10 -3
- package/dist/canvas/index.js.map +1 -1
- package/dist/{chunk-PRSRYHQD.cjs → chunk-3QHPFSQM.cjs} +36 -36
- package/dist/{chunk-PRSRYHQD.cjs.map → chunk-3QHPFSQM.cjs.map} +1 -1
- package/dist/{chunk-QBWEH3IM.cjs → chunk-3T5O225T.cjs} +391 -76
- package/dist/chunk-3T5O225T.cjs.map +1 -0
- package/dist/{chunk-EQQMGO42.js → chunk-C2J7GOMJ.js} +18 -5
- package/dist/chunk-C2J7GOMJ.js.map +1 -0
- package/dist/{chunk-2XS6LTUP.cjs → chunk-C46AZEBE.cjs} +104 -339
- package/dist/chunk-C46AZEBE.cjs.map +1 -0
- package/dist/{chunk-HUO3TI4C.js → chunk-CPSMARTX.js} +6 -241
- package/dist/chunk-CPSMARTX.js.map +1 -0
- package/dist/{chunk-KEENUAFN.cjs → chunk-DLLUOVQX.cjs} +18 -5
- package/dist/chunk-DLLUOVQX.cjs.map +1 -0
- package/dist/{chunk-LSXXAJG3.js → chunk-J7DSKTKB.js} +5 -4
- package/dist/chunk-J7DSKTKB.js.map +1 -0
- package/dist/{chunk-6S6362D2.js → chunk-NI6RORDS.js} +2 -2
- package/dist/{chunk-XN2NBLV5.cjs → chunk-PMEHFHSP.cjs} +82 -82
- package/dist/{chunk-XN2NBLV5.cjs.map → chunk-PMEHFHSP.cjs.map} +1 -1
- package/dist/{chunk-5FSRTP6E.js → chunk-PQFVLOMR.js} +319 -4
- package/dist/chunk-PQFVLOMR.js.map +1 -0
- package/dist/{chunk-OIBIRXRG.js → chunk-PSPLRQL6.js} +2 -2
- package/dist/{chunk-SYT2TLQF.js → chunk-QEIN6JQO.js} +2 -2
- package/dist/{chunk-3D77LOBM.js → chunk-TJBYBSTN.js} +51 -6
- package/dist/chunk-TJBYBSTN.js.map +1 -0
- package/dist/{chunk-DFSZO2B5.cjs → chunk-UFL5N4DK.cjs} +5 -4
- package/dist/chunk-UFL5N4DK.cjs.map +1 -0
- package/dist/{chunk-TLCTTQFF.cjs → chunk-VEHVXRJU.cjs} +17 -17
- package/dist/{chunk-TLCTTQFF.cjs.map → chunk-VEHVXRJU.cjs.map} +1 -1
- package/dist/{chunk-5OOIUXNJ.cjs → chunk-XFXHA5MU.cjs} +55 -10
- package/dist/chunk-XFXHA5MU.cjs.map +1 -0
- package/dist/commands/index.cjs +2 -2
- package/dist/commands/index.d.cts +3 -3
- package/dist/commands/index.d.ts +3 -3
- package/dist/commands/index.js +1 -1
- package/dist/effects/index.d.cts +5 -4
- package/dist/effects/index.d.ts +5 -4
- package/dist/{export-DwnZ_hvQ.d.ts → export-0ZaTK__4.d.ts} +4 -4
- package/dist/{export-41rL6Cne.d.ts → export-C45v6MYq.d.ts} +1 -1
- package/dist/{export-CyJdfP_Z.d.cts → export-D-7WCDJ9.d.cts} +4 -4
- package/dist/{export-D9mXp05Q.d.cts → export-DSdCfd6O.d.cts} +1 -1
- package/dist/grain-BWmGZxP4.d.cts +58 -0
- package/dist/grain-BWmGZxP4.d.ts +58 -0
- package/dist/{helpers-v6GMazzg.d.cts → helpers-Cavy1TB7.d.cts} +21 -1
- package/dist/{helpers-C-RgeyvH.d.ts → helpers-LZQ4cpg4.d.ts} +21 -1
- package/dist/image-editor/index.cjs +695 -677
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +12 -11
- package/dist/image-editor/index.d.ts +12 -11
- package/dist/image-editor/index.js +23 -5
- package/dist/image-editor/index.js.map +1 -1
- package/dist/{opentype-KR_jj6b_.d.cts → opentype-BpIJhGpj.d.cts} +1 -1
- package/dist/{opentype-a1KAW-qs.d.ts → opentype-CyxDScVz.d.ts} +1 -1
- package/dist/paint/index.cjs +21 -3
- package/dist/paint/index.cjs.map +1 -1
- package/dist/paint/index.d.cts +72 -5
- package/dist/paint/index.d.ts +72 -5
- package/dist/paint/index.js +20 -2
- package/dist/paint-editor/index.cjs +171 -171
- package/dist/paint-editor/index.cjs.map +1 -1
- package/dist/paint-editor/index.d.cts +77 -29
- package/dist/paint-editor/index.d.ts +77 -29
- package/dist/paint-editor/index.js +12 -12
- package/dist/{pathfinder-BHS4vQNm.d.cts → pathfinder-BMQEcS0k.d.cts} +2 -2
- package/dist/{pathfinder-BVvTIBMo.d.ts → pathfinder-CQIxubuP.d.ts} +2 -2
- package/dist/{pool-CZQOrSXZ.d.ts → pool-Cynuj89K.d.ts} +1 -1
- package/dist/{pool-FjZZmZ80.d.cts → pool-DedjxDKo.d.cts} +1 -1
- package/dist/{rand-8xbUb6ur.d.ts → rand-COS4_E1g.d.ts} +17 -1
- package/dist/{rand-Cw9VLrVC.d.cts → rand-D1JqpR-p.d.cts} +17 -1
- package/dist/{svg-DTb40ICU.d.cts → svg-RcixtBFR.d.cts} +2 -2
- package/dist/{svg-CSz3mzkw.d.ts → svg-nWBJEpnk.d.ts} +2 -2
- package/dist/{tools-Ca0kI1qo.d.cts → tools-CL82d7nw.d.cts} +1 -1
- package/dist/{tools-B0wXP5cF.d.ts → tools-DrxgDnXY.d.ts} +1 -1
- package/dist/vector/index.cjs +995 -955
- package/dist/vector/index.cjs.map +1 -1
- package/dist/vector/index.d.cts +44 -18
- package/dist/vector/index.d.ts +44 -18
- package/dist/vector/index.js +55 -15
- package/dist/vector/index.js.map +1 -1
- package/dist/video-editor/index.d.cts +5 -4
- package/dist/video-editor/index.d.ts +5 -4
- package/dist/{warp-DTOp0lON.d.cts → warp-CHi_P_G6.d.cts} +1 -1
- package/dist/{warp-pd7hrH4T.d.ts → warp-CPaHULUL.d.ts} +1 -1
- package/package.json +1 -1
- package/skills/pixerate-canvas/SKILL.md +12 -5
- package/skills/pixerate-vector/SKILL.md +4 -2
- package/dist/brushstrokeRender-2FAXA3XC.js.map +0 -1
- package/dist/brushstrokeRender-IMFY3FF6.cjs.map +0 -1
- package/dist/chunk-2XS6LTUP.cjs.map +0 -1
- package/dist/chunk-3D77LOBM.js.map +0 -1
- package/dist/chunk-5FSRTP6E.js.map +0 -1
- package/dist/chunk-5OOIUXNJ.cjs.map +0 -1
- package/dist/chunk-DFSZO2B5.cjs.map +0 -1
- package/dist/chunk-EQQMGO42.js.map +0 -1
- package/dist/chunk-HUO3TI4C.js.map +0 -1
- package/dist/chunk-KEENUAFN.cjs.map +0 -1
- package/dist/chunk-LSXXAJG3.js.map +0 -1
- package/dist/chunk-QBWEH3IM.cjs.map +0 -1
- /package/dist/{chunk-6S6362D2.js.map → chunk-NI6RORDS.js.map} +0 -0
- /package/dist/{chunk-OIBIRXRG.js.map → chunk-PSPLRQL6.js.map} +0 -0
- /package/dist/{chunk-SYT2TLQF.js.map → chunk-QEIN6JQO.js.map} +0 -0
|
@@ -4,20 +4,23 @@ import {
|
|
|
4
4
|
DEFAULT_BRUSH,
|
|
5
5
|
DEFAULT_MIXER,
|
|
6
6
|
DEFAULT_SMUDGE,
|
|
7
|
+
GRAIN_PATTERNS,
|
|
7
8
|
PaintGradientSampler,
|
|
9
|
+
PaperGrain,
|
|
8
10
|
TIP_GRADIENT_STEPS,
|
|
9
11
|
TileMedium,
|
|
10
12
|
dabRect,
|
|
13
|
+
grainCatch,
|
|
11
14
|
hash2,
|
|
12
|
-
mix32,
|
|
13
15
|
normalizeBlender,
|
|
14
16
|
normalizeBrush,
|
|
15
17
|
normalizeMixer,
|
|
16
18
|
normalizeSmudge,
|
|
17
19
|
rand01,
|
|
20
|
+
randSigned,
|
|
18
21
|
rasterizeDab,
|
|
19
22
|
readPaintSource
|
|
20
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-PQFVLOMR.js";
|
|
21
24
|
import {
|
|
22
25
|
TILE,
|
|
23
26
|
TiledSurface,
|
|
@@ -25,79 +28,8 @@ import {
|
|
|
25
28
|
tileKey
|
|
26
29
|
} from "./chunk-3G6J7UFV.js";
|
|
27
30
|
|
|
28
|
-
// src/paint-editor/noise.ts
|
|
29
|
-
function randSigned(seed, index, stream) {
|
|
30
|
-
return rand01(seed, index, stream) * 2 - 1;
|
|
31
|
-
}
|
|
32
|
-
function seedFromString(text) {
|
|
33
|
-
let h = 2166136261;
|
|
34
|
-
for (let i = 0; i < text.length; i++) {
|
|
35
|
-
h ^= text.charCodeAt(i);
|
|
36
|
-
h = Math.imul(h, 16777619);
|
|
37
|
-
}
|
|
38
|
-
return mix32(h >>> 0);
|
|
39
|
-
}
|
|
40
|
-
var smooth = (t) => t * t * (3 - 2 * t);
|
|
41
|
-
var Lattice = class {
|
|
42
|
-
constructor(px, py, salt) {
|
|
43
|
-
this.px = px;
|
|
44
|
-
this.py = py;
|
|
45
|
-
this.values = new Float32Array(px * py);
|
|
46
|
-
for (let j = 0; j < py; j++) for (let i = 0; i < px; i++) this.values[j * px + i] = hash2(i, j, salt);
|
|
47
|
-
}
|
|
48
|
-
px;
|
|
49
|
-
py;
|
|
50
|
-
values;
|
|
51
|
-
/** Value noise at (x, y) in lattice cells; wraps every `px` / `py` cells. */
|
|
52
|
-
at(x, y) {
|
|
53
|
-
const { px, py } = this;
|
|
54
|
-
const x0 = Math.floor(x);
|
|
55
|
-
const y0 = Math.floor(y);
|
|
56
|
-
const tx = smooth(x - x0);
|
|
57
|
-
const ty = smooth(y - y0);
|
|
58
|
-
const i0 = (x0 % px + px) % px;
|
|
59
|
-
const j0 = (y0 % py + py) % py;
|
|
60
|
-
const i1 = (i0 + 1) % px;
|
|
61
|
-
const j1 = (j0 + 1) % py;
|
|
62
|
-
const v = this.values;
|
|
63
|
-
const a = v[j0 * px + i0] + (v[j0 * px + i1] - v[j0 * px + i0]) * tx;
|
|
64
|
-
const b = v[j1 * px + i0] + (v[j1 * px + i1] - v[j1 * px + i0]) * tx;
|
|
65
|
-
return a + (b - a) * ty;
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
var TileableNoise = class {
|
|
69
|
-
constructor(size, cellsX, cellsY, octaves, salt) {
|
|
70
|
-
this.size = size;
|
|
71
|
-
let cx = Math.max(1, Math.round(cellsX));
|
|
72
|
-
let cy = Math.max(1, Math.round(cellsY));
|
|
73
|
-
for (let o = 0; o < octaves; o++) {
|
|
74
|
-
this.octaves.push(new Lattice(cx, cy, salt + o * 7919 | 0));
|
|
75
|
-
cx *= 2;
|
|
76
|
-
cy *= 2;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
size;
|
|
80
|
-
octaves = [];
|
|
81
|
-
/** Fractal noise at pixel (x, y). */
|
|
82
|
-
at(x, y) {
|
|
83
|
-
let sum = 0;
|
|
84
|
-
let amp = 1;
|
|
85
|
-
let norm = 0;
|
|
86
|
-
const u = x / this.size;
|
|
87
|
-
const v = y / this.size;
|
|
88
|
-
for (const l of this.octaves) {
|
|
89
|
-
sum += l.at(u * l.px, v * l.py) * amp;
|
|
90
|
-
norm += amp;
|
|
91
|
-
amp *= 0.5;
|
|
92
|
-
}
|
|
93
|
-
return norm > 0 ? sum / norm : 0.5;
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
|
|
97
31
|
// src/paint-editor/paper.ts
|
|
98
|
-
var GRAIN_PATTERNS = ["smooth", "cold-pressed", "hot-pressed", "rough", "vellum", "laid", "ingres", "sanded", "canvas", "linen", "gesso"];
|
|
99
32
|
var PAPER_FAMILIES = ["watercolor", "drawing", "pastel", "canvas", "panel", "smooth"];
|
|
100
|
-
var GRAIN_TILE = 256;
|
|
101
33
|
var unit = (v, d) => typeof v === "number" && Number.isFinite(v) ? Math.min(1, Math.max(0, v)) : d;
|
|
102
34
|
var clampNum = (v, lo, hi, d) => typeof v === "number" && Number.isFinite(v) ? Math.min(hi, Math.max(lo, v)) : d;
|
|
103
35
|
var HEX = /^#[0-9a-f]{6}$/i;
|
|
@@ -169,165 +101,6 @@ function normalizePaper(raw = {}, base) {
|
|
|
169
101
|
...unit(r.metallic, b.metallic ?? 0) > 0 ? { metallic: unit(r.metallic, b.metallic ?? 0) } : {}
|
|
170
102
|
};
|
|
171
103
|
}
|
|
172
|
-
var clamp01 = (v) => v < 0 ? 0 : v > 1 ? 1 : v;
|
|
173
|
-
function patternHeights(pattern, n, seed) {
|
|
174
|
-
const out = new Float32Array(n * n);
|
|
175
|
-
const salt = Math.imul(seed | 0, 2654435761) + 17;
|
|
176
|
-
if (pattern === "smooth") return out.fill(1);
|
|
177
|
-
const noise = (cx, cy, oct, s = 0) => new TileableNoise(n, cx, cy, oct, salt + s);
|
|
178
|
-
const k = n / GRAIN_TILE;
|
|
179
|
-
switch (pattern) {
|
|
180
|
-
case "cold-pressed": {
|
|
181
|
-
const base = noise(20 * k, 20 * k, 4);
|
|
182
|
-
const fine = noise(64 * k, 64 * k, 2, 3);
|
|
183
|
-
for (let y = 0; y < n; y++)
|
|
184
|
-
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 + (hash2(x, y, salt) - 0.5) * 0.12);
|
|
185
|
-
break;
|
|
186
|
-
}
|
|
187
|
-
case "hot-pressed": {
|
|
188
|
-
const base = noise(40 * k, 40 * k, 3);
|
|
189
|
-
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 + (hash2(x, y, salt) - 0.5) * 0.08);
|
|
190
|
-
break;
|
|
191
|
-
}
|
|
192
|
-
case "rough": {
|
|
193
|
-
const base = noise(10 * k, 10 * k, 5);
|
|
194
|
-
const blot = noise(28 * k, 28 * k, 2, 5);
|
|
195
|
-
for (let y = 0; y < n; y++)
|
|
196
|
-
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 + (hash2(x, y, salt) - 0.5) * 0.15);
|
|
197
|
-
break;
|
|
198
|
-
}
|
|
199
|
-
case "vellum": {
|
|
200
|
-
const base = noise(40 * k, 40 * k, 3);
|
|
201
|
-
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 + (hash2(x, y, salt) - 0.5) * 0.2);
|
|
202
|
-
break;
|
|
203
|
-
}
|
|
204
|
-
case "laid": {
|
|
205
|
-
const pulp = noise(32 * k, 32 * k, 3);
|
|
206
|
-
const chain = n / 8;
|
|
207
|
-
for (let y = 0; y < n; y++) {
|
|
208
|
-
const laid = 0.5 + 0.5 * Math.cos(2 * Math.PI * y / 4);
|
|
209
|
-
for (let x = 0; x < n; x++) {
|
|
210
|
-
const c = Math.abs((x + 0.5) % chain - chain / 2) / (chain / 2);
|
|
211
|
-
const chainLine = c > 0.94 ? -0.35 : 0;
|
|
212
|
-
out[y * n + x] = clamp01(0.3 + 0.5 * laid + chainLine + (pulp.at(x, y) - 0.5) * 0.6);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
break;
|
|
216
|
-
}
|
|
217
|
-
case "ingres": {
|
|
218
|
-
const fibres = noise(64 * k, 12 * k, 3);
|
|
219
|
-
const base = noise(16 * k, 16 * k, 3, 7);
|
|
220
|
-
for (let y = 0; y < n; y++)
|
|
221
|
-
for (let x = 0; x < n; x++) {
|
|
222
|
-
const g = hash2(x, y, salt ^ 85);
|
|
223
|
-
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));
|
|
224
|
-
}
|
|
225
|
-
break;
|
|
226
|
-
}
|
|
227
|
-
case "sanded": {
|
|
228
|
-
const grit = noise(96 * k, 96 * k, 2);
|
|
229
|
-
for (let y = 0; y < n; y++)
|
|
230
|
-
for (let x = 0; x < n; x++) {
|
|
231
|
-
const h = hash2(x, y, salt);
|
|
232
|
-
out[y * n + x] = clamp01((grit.at(x, y) - 0.5) * 2.4 + 0.5 + (h - 0.5) * 0.7);
|
|
233
|
-
}
|
|
234
|
-
break;
|
|
235
|
-
}
|
|
236
|
-
case "canvas":
|
|
237
|
-
case "linen": {
|
|
238
|
-
const period = (pattern === "canvas" ? 8 : 5) * k;
|
|
239
|
-
const threads = Math.max(2, 2 * Math.round(n / period / 2));
|
|
240
|
-
const p = n / threads;
|
|
241
|
-
const slub = noise(threads, threads, 2, 11);
|
|
242
|
-
for (let y = 0; y < n; y++)
|
|
243
|
-
for (let x = 0; x < n; x++) {
|
|
244
|
-
const fx = (x + 0.5) / p;
|
|
245
|
-
const fy = (y + 0.5) / p;
|
|
246
|
-
const cx = Math.floor(fx);
|
|
247
|
-
const cy = Math.floor(fy);
|
|
248
|
-
const warp = Math.sin(Math.PI * (fx - cx));
|
|
249
|
-
const weft = Math.sin(Math.PI * (fy - cy));
|
|
250
|
-
const top = (cx + cy) % 2 === 0 ? warp : weft;
|
|
251
|
-
const irregular = pattern === "linen" ? (slub.at(x, y) - 0.5) * 0.5 : 0;
|
|
252
|
-
out[y * n + x] = clamp01(0.2 + 0.7 * top + irregular + (hash2(x, y, salt) - 0.5) * 0.15);
|
|
253
|
-
}
|
|
254
|
-
break;
|
|
255
|
-
}
|
|
256
|
-
case "gesso": {
|
|
257
|
-
const streaks = noise(2 * k, 28 * k, 3);
|
|
258
|
-
const tooth = noise(64 * k, 64 * k, 2, 13);
|
|
259
|
-
for (let y = 0; y < n; y++)
|
|
260
|
-
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);
|
|
261
|
-
break;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
return out;
|
|
265
|
-
}
|
|
266
|
-
var rawCache = /* @__PURE__ */ new Map();
|
|
267
|
-
function grainHeights(pattern, seed, size = GRAIN_TILE) {
|
|
268
|
-
const key = `${pattern}:${seed}:${size}`;
|
|
269
|
-
let h = rawCache.get(key);
|
|
270
|
-
if (!h) {
|
|
271
|
-
h = patternHeights(pattern, size, seed);
|
|
272
|
-
if (rawCache.size > 32) rawCache.delete(rawCache.keys().next().value);
|
|
273
|
-
rawCache.set(key, h);
|
|
274
|
-
}
|
|
275
|
-
return h;
|
|
276
|
-
}
|
|
277
|
-
var PaperGrain = class {
|
|
278
|
-
size = GRAIN_TILE;
|
|
279
|
-
heights;
|
|
280
|
-
scale;
|
|
281
|
-
mirror;
|
|
282
|
-
flat;
|
|
283
|
-
constructor(paper, media = "dry") {
|
|
284
|
-
const raw = grainHeights(paper.pattern, paper.seed);
|
|
285
|
-
const t = paper[media];
|
|
286
|
-
this.flat = paper.pattern === "smooth";
|
|
287
|
-
if (t.contrast === 1 && !t.invert) this.heights = raw;
|
|
288
|
-
else {
|
|
289
|
-
const out = new Float32Array(raw.length);
|
|
290
|
-
for (let i = 0; i < raw.length; i++) {
|
|
291
|
-
const v = clamp01((raw[i] - 0.5) * t.contrast + 0.5);
|
|
292
|
-
out[i] = t.invert ? 1 - v : v;
|
|
293
|
-
}
|
|
294
|
-
this.heights = out;
|
|
295
|
-
}
|
|
296
|
-
this.scale = paper.scale;
|
|
297
|
-
this.mirror = paper.tiling === "mirror";
|
|
298
|
-
}
|
|
299
|
-
/** Tile cell index for a coordinate in grain pixels (mirrored on odd tiles when mirroring). */
|
|
300
|
-
wrap(v) {
|
|
301
|
-
const n = this.size;
|
|
302
|
-
if (!this.mirror) return (v % n + n) % n;
|
|
303
|
-
const p = (v % (2 * n) + 2 * n) % (2 * n);
|
|
304
|
-
return p < n ? p : 2 * n - 1 - p;
|
|
305
|
-
}
|
|
306
|
-
/** Height 0..1 at document position (x, y). */
|
|
307
|
-
at(x, y) {
|
|
308
|
-
const u = x / this.scale - 0.5;
|
|
309
|
-
const v = y / this.scale - 0.5;
|
|
310
|
-
const x0 = Math.floor(u);
|
|
311
|
-
const y0 = Math.floor(v);
|
|
312
|
-
const fx = u - x0;
|
|
313
|
-
const fy = v - y0;
|
|
314
|
-
const n = this.size;
|
|
315
|
-
const h = this.heights;
|
|
316
|
-
const a = this.wrap(x0);
|
|
317
|
-
const b = this.wrap(x0 + 1);
|
|
318
|
-
const c = this.wrap(y0) * n;
|
|
319
|
-
const d = this.wrap(y0 + 1) * n;
|
|
320
|
-
const top = h[c + a] + (h[c + b] - h[c + a]) * fx;
|
|
321
|
-
const bot = h[d + a] + (h[d + b] - h[d + a]) * fx;
|
|
322
|
-
return top + (bot - top) * fy;
|
|
323
|
-
}
|
|
324
|
-
};
|
|
325
|
-
function grainCatch(h, depth, pressure) {
|
|
326
|
-
if (depth <= 0) return 1;
|
|
327
|
-
const t = depth * (0.75 - 0.65 * Math.min(1, Math.max(0, pressure)));
|
|
328
|
-
const u = clamp01((h - t + 0.18) / 0.36);
|
|
329
|
-
return 1 - depth + depth * u * u * (3 - 2 * u);
|
|
330
|
-
}
|
|
331
104
|
function hexToRgb8(hex) {
|
|
332
105
|
const n = parseInt(hex.slice(1, 7), 16);
|
|
333
106
|
return [n >> 16 & 255, n >> 8 & 255, n & 255];
|
|
@@ -2001,20 +1774,12 @@ function parseBrushLibrary(raw, problems = []) {
|
|
|
2001
1774
|
}
|
|
2002
1775
|
|
|
2003
1776
|
export {
|
|
2004
|
-
randSigned,
|
|
2005
|
-
seedFromString,
|
|
2006
|
-
TileableNoise,
|
|
2007
|
-
GRAIN_PATTERNS,
|
|
2008
1777
|
PAPER_FAMILIES,
|
|
2009
|
-
GRAIN_TILE,
|
|
2010
1778
|
PAPER_LIBRARY,
|
|
2011
1779
|
DEFAULT_PAPER,
|
|
2012
1780
|
paperPreset,
|
|
2013
1781
|
clonePaper,
|
|
2014
1782
|
normalizePaper,
|
|
2015
|
-
grainHeights,
|
|
2016
|
-
PaperGrain,
|
|
2017
|
-
grainCatch,
|
|
2018
1783
|
hexToRgb8,
|
|
2019
1784
|
renderPaper,
|
|
2020
1785
|
penOrientation,
|
|
@@ -2073,4 +1838,4 @@ export {
|
|
|
2073
1838
|
brushToJSON,
|
|
2074
1839
|
parseBrushLibrary
|
|
2075
1840
|
};
|
|
2076
|
-
//# sourceMappingURL=chunk-
|
|
1841
|
+
//# sourceMappingURL=chunk-CPSMARTX.js.map
|