@pixerate/editor 0.275.0 → 0.276.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 +81 -70
- package/dist/brushes/index.js +17 -6
- package/dist/brushes/patch.d.cts +1 -1
- package/dist/brushes/patch.d.ts +1 -1
- package/dist/brushes/profiles.d.cts +2 -0
- package/dist/brushes/profiles.d.ts +2 -0
- package/dist/brushes/schema.d.cts +1 -0
- package/dist/brushes/schema.d.ts +1 -0
- package/dist/brushes/types.d.cts +22 -1
- package/dist/brushes/types.d.ts +22 -1
- package/dist/{brushstrokeRender-WGY4DZHF.js → brushstrokeRender-FK3ASUUJ.js} +5 -5
- package/dist/{brushstrokeRender-2RQL46WB.cjs → brushstrokeRender-I6MYFCOU.cjs} +21 -21
- package/dist/canvas/index.cjs +13 -13
- package/dist/canvas/index.js +1 -1
- package/dist/chart/contract.d.cts +3 -1
- package/dist/chart/contract.d.ts +3 -1
- package/dist/{chunk-Y2ISSVPH.js → chunk-4EM5NGCL.js} +167 -9
- package/dist/{chunk-Y354ETAE.cjs → chunk-5HR5CSLC.cjs} +49 -49
- package/dist/{chunk-LMG57L5A.js → chunk-CTHWXW5M.js} +121 -8
- package/dist/{chunk-43XJC3PP.js → chunk-CVBTJVRN.js} +1 -1
- package/dist/{chunk-RJGW3RQS.js → chunk-GHYJAMMS.js} +1 -1
- package/dist/{chunk-NIBFKXMD.cjs → chunk-IFWLZZCW.cjs} +619 -2
- package/dist/{chunk-G5TCMKX5.js → chunk-IJ6NSWKM.js} +2 -2
- package/dist/{chunk-C6VB7CPY.cjs → chunk-ISCAJBPQ.cjs} +1 -1
- package/dist/{chunk-W6JDUXP3.js → chunk-J23JOHPR.js} +1 -1
- package/dist/{chunk-IEEY5RJV.js → chunk-JNMNM3SL.js} +1 -1
- package/dist/{chunk-HVO6XCI4.js → chunk-JPB65KQ6.js} +1 -1
- package/dist/{chunk-ACTHSQOI.js → chunk-LDZOXESA.js} +618 -1
- package/dist/{chunk-DHC4E2DU.cjs → chunk-MITQGHN3.cjs} +121 -8
- package/dist/{chunk-STLTOISW.cjs → chunk-NPPMKMCU.cjs} +17 -17
- package/dist/{chunk-75SYKUOT.js → chunk-OS6OG7DN.js} +1 -1
- package/dist/{chunk-OLZXXAER.cjs → chunk-OY24XRYF.cjs} +408 -250
- package/dist/{chunk-6QNDGMK7.cjs → chunk-Q33V5PEF.cjs} +123 -42
- package/dist/{chunk-JDXWLCXF.cjs → chunk-QNNZA3V5.cjs} +2 -2
- package/dist/{chunk-T6KNJVBP.cjs → chunk-U26LUXCJ.cjs} +35 -35
- package/dist/{chunk-62MFUHSI.cjs → chunk-UQXULAMQ.cjs} +16 -16
- package/dist/{chunk-RAPNRK4R.cjs → chunk-X7XBEX3O.cjs} +88 -88
- package/dist/{chunk-MSWLJI4G.js → chunk-XMSH66VU.js} +2 -2
- package/dist/{chunk-ZM7IKQ4X.js → chunk-XVPQNX7O.js} +89 -8
- package/dist/{chunk-YYZC2EQO.cjs → chunk-ZIE6EJGR.cjs} +23 -23
- package/dist/image-editor/index.cjs +880 -852
- package/dist/image-editor/index.js +36 -8
- package/dist/paint/index.cjs +33 -5
- package/dist/paint/index.d.cts +1 -0
- package/dist/paint/index.d.ts +1 -0
- package/dist/paint/index.js +32 -4
- package/dist/paint/live-patterns.d.cts +149 -0
- package/dist/paint/live-patterns.d.ts +149 -0
- package/dist/paint/wet/world.d.cts +13 -0
- package/dist/paint/wet/world.d.ts +13 -0
- package/dist/paint-editor/brush-model.d.cts +7 -1
- package/dist/paint-editor/brush-model.d.ts +7 -1
- package/dist/paint-editor/controller.d.cts +52 -0
- package/dist/paint-editor/controller.d.ts +52 -0
- package/dist/paint-editor/index.cjs +850 -510
- package/dist/paint-editor/index.js +355 -15
- package/dist/paint-editor/ui.d.cts +5 -1
- package/dist/paint-editor/ui.d.ts +5 -1
- package/dist/paint-editor/wet-tools.d.cts +42 -0
- package/dist/paint-editor/wet-tools.d.ts +42 -0
- package/dist/paint-editor/wet.d.cts +22 -1
- package/dist/paint-editor/wet.d.ts +22 -1
- 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 +1 -0
- package/skills/pixerate-paint-editor/SKILL.md +7 -1
- package/skills/pixerate-paint-editor/references/brush-facets.md +1 -0
- package/skills/pixerate-paint-editor/references/live-patterns.md +41 -0
- package/skills/pixerate-paint-watercolour/SKILL.md +8 -0
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } 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; var _class2; var _class3;
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
var _chunkIFWLZZCWcjs = require('./chunk-IFWLZZCW.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
4
8
|
|
|
5
9
|
|
|
6
10
|
var _chunk474IQG74cjs = require('./chunk-474IQG74.cjs');
|
|
@@ -852,10 +856,30 @@ var noLight = () => new (0, _chunk474IQG74cjs.TiledSurface)(1, /* @__PURE__ */ n
|
|
|
852
856
|
function cloneGhost(g) {
|
|
853
857
|
return g ? { pigment: [...g.pigment], remaining: g.remaining, total: g.total, linger: g.linger, ...g.trigger === "agent" ? { trigger: "agent" } : {} } : null;
|
|
854
858
|
}
|
|
855
|
-
function newLane(id, index, params, flow, flowStrength, base, light, ghost) {
|
|
859
|
+
function newLane(id, index, params, flow, flowStrength, base, light, width, height, ghost, livePatterns) {
|
|
856
860
|
const l = _nullishCoalesce(light, () => ( noLight()));
|
|
857
861
|
const g = cloneGhost(ghost);
|
|
858
|
-
return {
|
|
862
|
+
return {
|
|
863
|
+
id,
|
|
864
|
+
index,
|
|
865
|
+
params,
|
|
866
|
+
flow,
|
|
867
|
+
flowStrength,
|
|
868
|
+
base,
|
|
869
|
+
shaded: /* @__PURE__ */ new Map(),
|
|
870
|
+
urgent: /* @__PURE__ */ new Set(),
|
|
871
|
+
stamp: 1,
|
|
872
|
+
display: null,
|
|
873
|
+
shadedVersion: 0,
|
|
874
|
+
displayKey: "",
|
|
875
|
+
light: l,
|
|
876
|
+
lit: !g && l.tiles.size > 0,
|
|
877
|
+
ghost: g,
|
|
878
|
+
lightShaded: /* @__PURE__ */ new Map(),
|
|
879
|
+
lightDisplay: null,
|
|
880
|
+
lightKey: "",
|
|
881
|
+
livePatterns: _nullishCoalesce(livePatterns, () => ( new (0, _chunkIFWLZZCWcjs.LivePatternField)(width, height)))
|
|
882
|
+
};
|
|
859
883
|
}
|
|
860
884
|
var WetWorldError = class extends Error {
|
|
861
885
|
constructor(message) {
|
|
@@ -1016,12 +1040,28 @@ var WetWorld = (_class = class {
|
|
|
1016
1040
|
if (options.params) this.setParams(id, options.params);
|
|
1017
1041
|
if (options.base) this.setBase(id, options.base);
|
|
1018
1042
|
if (options.light) this.setLight(id, options.light);
|
|
1043
|
+
if (options.livePatterns && existing.livePatterns !== options.livePatterns) {
|
|
1044
|
+
existing.livePatterns = options.livePatterns;
|
|
1045
|
+
this.touchAll(existing);
|
|
1046
|
+
}
|
|
1019
1047
|
if (options.ghost !== void 0) this.setGhost(id, options.ghost);
|
|
1020
1048
|
return;
|
|
1021
1049
|
}
|
|
1022
1050
|
const index = this.lanes.indexOf(null);
|
|
1023
1051
|
if (index < 0) throw new WetWorldError(`At most ${MAX_WET_LANES} layers can hold wet paint at once; dry one (dry_paint) first.`);
|
|
1024
|
-
this.lanes[index] = newLane(
|
|
1052
|
+
this.lanes[index] = newLane(
|
|
1053
|
+
id,
|
|
1054
|
+
index,
|
|
1055
|
+
normalizeWetParams(_nullishCoalesce(options.params, () => ( {})), DEFAULT_WET_PARAMS),
|
|
1056
|
+
_nullishCoalesce(options.flow, () => ( null)),
|
|
1057
|
+
options.flow ? _nullishCoalesce(options.flowStrength, () => ( 1)) : 0,
|
|
1058
|
+
_nullishCoalesce(options.base, () => ( new (0, _chunk474IQG74cjs.TiledSurface)(4, /* @__PURE__ */ new Map(), 0))),
|
|
1059
|
+
options.light,
|
|
1060
|
+
this.width,
|
|
1061
|
+
this.height,
|
|
1062
|
+
options.ghost,
|
|
1063
|
+
options.livePatterns
|
|
1064
|
+
);
|
|
1025
1065
|
this.pack(this.lanes[index]);
|
|
1026
1066
|
}
|
|
1027
1067
|
/** Drops a wet layer and its wet paint (nothing is baked). */
|
|
@@ -1041,6 +1081,52 @@ var WetWorld = (_class = class {
|
|
|
1041
1081
|
this.pack(lane);
|
|
1042
1082
|
return { ...lane.params };
|
|
1043
1083
|
}
|
|
1084
|
+
getLivePatterns(id) {
|
|
1085
|
+
return { ...this.laneOf(id).livePatterns.settings };
|
|
1086
|
+
}
|
|
1087
|
+
hasLivePatterns(id) {
|
|
1088
|
+
const lane = this.laneOf(id);
|
|
1089
|
+
return lane.livePatterns.enabled;
|
|
1090
|
+
}
|
|
1091
|
+
livePatternField(id) {
|
|
1092
|
+
return this.laneOf(id).livePatterns;
|
|
1093
|
+
}
|
|
1094
|
+
setLivePatterns(id, settings) {
|
|
1095
|
+
this.requireIdle();
|
|
1096
|
+
const lane = this.laneOf(id);
|
|
1097
|
+
const next = lane.livePatterns.configure(settings);
|
|
1098
|
+
this.touchAll(lane);
|
|
1099
|
+
return next;
|
|
1100
|
+
}
|
|
1101
|
+
seedLivePatterns(id, cx, cy, radius, seed = 1, strength = 1, settings) {
|
|
1102
|
+
this.requireIdle();
|
|
1103
|
+
const lane = this.laneOf(id);
|
|
1104
|
+
if (settings) lane.livePatterns.configure(settings);
|
|
1105
|
+
const count = lane.livePatterns.seedDisc(cx, cy, radius, seed, strength);
|
|
1106
|
+
if (count > 0) this.touchAll(lane);
|
|
1107
|
+
return count;
|
|
1108
|
+
}
|
|
1109
|
+
livePatternStats(id) {
|
|
1110
|
+
const lane = this.laneOf(id);
|
|
1111
|
+
return lane.livePatterns.stats((tx, ty, lx, ly) => this.isPatternCellWet(lane, tx, ty, lx, ly));
|
|
1112
|
+
}
|
|
1113
|
+
isPatternCellWet(lane, tx, ty, lx, ly) {
|
|
1114
|
+
const { tilesX, tilesY, perLane } = this.layout;
|
|
1115
|
+
if (tx < 0 || ty < 0 || tx >= tilesX || ty >= tilesY) return false;
|
|
1116
|
+
const slot = this.slotOf(lane.index * perLane + ty * tilesX + tx);
|
|
1117
|
+
if (slot < 0) return false;
|
|
1118
|
+
const cur = this.slotBase(slot) + this.parity * SET_PLANES * PLANE;
|
|
1119
|
+
const x0 = lx * 2 + 1;
|
|
1120
|
+
const y0 = ly * 2 + 1;
|
|
1121
|
+
const c00 = y0 * S2 + x0;
|
|
1122
|
+
const c10 = c00 + 1;
|
|
1123
|
+
const c01 = c00 + S2;
|
|
1124
|
+
const c11 = c01 + 1;
|
|
1125
|
+
const rhoBase = cur + P_RHO * PLANE;
|
|
1126
|
+
const swBase = cur + P_SW * PLANE;
|
|
1127
|
+
const f = this.f32;
|
|
1128
|
+
return f[rhoBase + c00] + f[swBase + c00] > DRY_EPS || f[rhoBase + c10] + f[swBase + c10] > DRY_EPS || f[rhoBase + c01] + f[swBase + c01] > DRY_EPS || f[rhoBase + c11] + f[swBase + c11] > DRY_EPS;
|
|
1129
|
+
}
|
|
1044
1130
|
getTilt() {
|
|
1045
1131
|
return { ...this.tilt };
|
|
1046
1132
|
}
|
|
@@ -1378,6 +1464,14 @@ var WetWorld = (_class = class {
|
|
|
1378
1464
|
const flagsBase = l.flags >> 2;
|
|
1379
1465
|
const lastBase = l.last >> 2;
|
|
1380
1466
|
const { tilesX, tilesY, perLane } = l;
|
|
1467
|
+
for (const lane of this.lanes) {
|
|
1468
|
+
if (!lane || !lane.livePatterns.enabled || lane.livePatterns.tiles.size === 0) continue;
|
|
1469
|
+
lane.livePatterns.step(
|
|
1470
|
+
n,
|
|
1471
|
+
(tx, ty, lx, ly) => this.isPatternCellWet(lane, tx, ty, lx, ly),
|
|
1472
|
+
(tx, ty) => this.slotOf(lane.index * perLane + ty * tilesX + tx) >= 0
|
|
1473
|
+
);
|
|
1474
|
+
}
|
|
1381
1475
|
const wakeups = [];
|
|
1382
1476
|
for (const key of this.active) {
|
|
1383
1477
|
const fl = this.u32[flagsBase + key];
|
|
@@ -2051,6 +2145,7 @@ var WetWorld = (_class = class {
|
|
|
2051
2145
|
}
|
|
2052
2146
|
const src = _nullishCoalesce(_optionalChain([lane, 'access', _22 => _22.base, 'access', _23 => _23.tiles, 'access', _24 => _24.get, 'call', _25 => _25(tk), 'optionalAccess', _26 => _26.data]), () => ( null));
|
|
2053
2147
|
const out = this.shadeSlot(key, src, all ? "bake-all" : "bake");
|
|
2148
|
+
if (lane.livePatterns.enabled) lane.livePatterns.markBaked(tx, ty);
|
|
2054
2149
|
if (!out) return lightChanged;
|
|
2055
2150
|
const tiles = new Map(lane.base.tiles);
|
|
2056
2151
|
const t = _chunk474IQG74cjs.finishTile.call(void 0, out, 4, 0);
|
|
@@ -2086,7 +2181,7 @@ var WetWorld = (_class = class {
|
|
|
2086
2181
|
const h = Math.min(WET_TILE, this.height - ty * WET_TILE);
|
|
2087
2182
|
const lane = this.lanes[this.laneIndexOf(key)];
|
|
2088
2183
|
const lit = lane.lit && !lane.ghost;
|
|
2089
|
-
|
|
2184
|
+
let changed = shadeTile(
|
|
2090
2185
|
this.f32,
|
|
2091
2186
|
PLANE,
|
|
2092
2187
|
S2,
|
|
@@ -2103,6 +2198,9 @@ var WetWorld = (_class = class {
|
|
|
2103
2198
|
lit ? b + P_DL * PLANE : -1,
|
|
2104
2199
|
lit && mode !== "bake" ? cur + P_L * PLANE : -1
|
|
2105
2200
|
);
|
|
2201
|
+
if (lane.livePatterns.enabled && lane.livePatterns.tiles.size > 0) {
|
|
2202
|
+
changed = lane.livePatterns.shadeTile(tx, ty, out, w, h) || changed;
|
|
2203
|
+
}
|
|
2106
2204
|
return changed ? out : null;
|
|
2107
2205
|
}
|
|
2108
2206
|
/** The layer's pixels with all its wet paint dried where it is (the bake of "dry on save"); changes nothing. */
|
|
@@ -2550,7 +2648,11 @@ var WetWorld = (_class = class {
|
|
|
2550
2648
|
slots.set(key, { planes, last: this.u32[(this.layout.last >> 2) + key] });
|
|
2551
2649
|
bytes += planes.byteLength;
|
|
2552
2650
|
}
|
|
2553
|
-
const lanes = this.lanes.filter((l) => Boolean(l)).map((l) =>
|
|
2651
|
+
const lanes = this.lanes.filter((l) => Boolean(l)).map((l) => {
|
|
2652
|
+
const lp = l.livePatterns.snapshot();
|
|
2653
|
+
bytes += lp.bytes;
|
|
2654
|
+
return { id: l.id, index: l.index, params: { ...l.params }, flow: l.flow, flowStrength: l.flowStrength, base: l.base, light: l.light, lit: l.lit, ghost: cloneGhost(l.ghost), livePatterns: lp };
|
|
2655
|
+
});
|
|
2554
2656
|
return { clock: this.clock, tilt: { ...this.tilt }, lanes, slots, bytes };
|
|
2555
2657
|
}
|
|
2556
2658
|
/** Puts a snapshot back exactly (the simulation then continues as it would have). */
|
|
@@ -2560,8 +2662,9 @@ var WetWorld = (_class = class {
|
|
|
2560
2662
|
this.lanes.fill(null);
|
|
2561
2663
|
this.tilt = { ...snap.tilt };
|
|
2562
2664
|
for (const l of snap.lanes) {
|
|
2563
|
-
const lane = newLane(l.id, l.index, { ...l.params }, l.flow, l.flowStrength, l.base, l.light, l.ghost);
|
|
2665
|
+
const lane = newLane(l.id, l.index, { ...l.params }, l.flow, l.flowStrength, l.base, l.light, this.width, this.height, l.ghost);
|
|
2564
2666
|
lane.lit = !lane.ghost && (lane.lit || Boolean(l.lit));
|
|
2667
|
+
if (l.livePatterns) lane.livePatterns.restore(l.livePatterns);
|
|
2565
2668
|
this.lanes[l.index] = lane;
|
|
2566
2669
|
this.pack(this.lanes[l.index]);
|
|
2567
2670
|
}
|
|
@@ -2619,9 +2722,19 @@ function moveWetSnapshot(snap, from, to, dx, dy, lane = () => ({})) {
|
|
|
2619
2722
|
}
|
|
2620
2723
|
const lanes = snap.lanes.map((l) => {
|
|
2621
2724
|
const moved = lane(l);
|
|
2622
|
-
|
|
2725
|
+
const lp = l.livePatterns ? _chunkIFWLZZCWcjs.moveLivePatternSnapshot.call(void 0, l.livePatterns, to, tx0, ty0) : void 0;
|
|
2726
|
+
if (lp) bytes += lp.bytes;
|
|
2727
|
+
return { ...l, base: _nullishCoalesce(moved.base, () => ( l.base)), light: _nullishCoalesce(moved.light, () => ( l.light)), flow: moved.flow === void 0 ? l.flow : moved.flow, ...lp ? { livePatterns: lp } : {} };
|
|
2623
2728
|
});
|
|
2624
|
-
|
|
2729
|
+
let patterns;
|
|
2730
|
+
if (snap.patterns) {
|
|
2731
|
+
patterns = /* @__PURE__ */ new Map();
|
|
2732
|
+
for (const [id, p] of snap.patterns) {
|
|
2733
|
+
const mp = _chunkIFWLZZCWcjs.moveLivePatternSnapshot.call(void 0, p, to, tx0, ty0);
|
|
2734
|
+
patterns.set(id, mp);
|
|
2735
|
+
}
|
|
2736
|
+
}
|
|
2737
|
+
return { clock: snap.clock, tilt: { ...snap.tilt }, lanes, slots, ...patterns ? { patterns } : {}, bytes };
|
|
2625
2738
|
}
|
|
2626
2739
|
function unionRect(a, b) {
|
|
2627
2740
|
if (!a) return { ...b };
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunkIFWLZZCWcjs = require('./chunk-IFWLZZCW.cjs');
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
var _chunk3K6HWEXZcjs = require('./chunk-3K6HWEXZ.cjs');
|
|
@@ -54,7 +54,7 @@ function lean(s) {
|
|
|
54
54
|
return null;
|
|
55
55
|
}
|
|
56
56
|
function pathStrokeDabs(samples, options) {
|
|
57
|
-
const brush =
|
|
57
|
+
const brush = _chunkIFWLZZCWcjs.normalizeBrush.call(void 0, options.brush);
|
|
58
58
|
const pts = options.closed && samples.length > 2 ? [...samples, samples[0]] : [...samples];
|
|
59
59
|
if (!pts.length) return [];
|
|
60
60
|
const tilt = _nullishCoalesce(options.tilt, () => ( {}));
|
|
@@ -127,24 +127,24 @@ function pathStrokeDabs(samples, options) {
|
|
|
127
127
|
return out;
|
|
128
128
|
}
|
|
129
129
|
function pathStrokeCoverage(samples, options) {
|
|
130
|
-
const brush =
|
|
131
|
-
const coverage = new (0,
|
|
130
|
+
const brush = _chunkIFWLZZCWcjs.normalizeBrush.call(void 0, options.brush);
|
|
131
|
+
const coverage = new (0, _chunkIFWLZZCWcjs.CoverageMap)();
|
|
132
132
|
const dabs = pathStrokeDabs(samples, options);
|
|
133
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,
|
|
135
|
-
const tipTable = _optionalChain([sampler, 'optionalAccess', _8 => _8.acrossTip]) ? sampler.tipTable(
|
|
134
|
+
const sampler = g ? new (0, _chunkIFWLZZCWcjs.PaintGradientSampler)(_chunkIFWLZZCWcjs.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(_chunkIFWLZZCWcjs.TIP_GRADIENT_STEPS) : null;
|
|
136
136
|
const scratch = { field: new Float32Array(0), sample: { rgb: [0, 0, 0], alpha: 1 } };
|
|
137
137
|
let buf = new Float32Array(0);
|
|
138
138
|
let bounds = null;
|
|
139
139
|
for (const d of dabs) {
|
|
140
|
-
const rect =
|
|
140
|
+
const rect = _chunkIFWLZZCWcjs.dabRect.call(void 0, d, brush.hardness);
|
|
141
141
|
const n = rect.width * rect.height;
|
|
142
142
|
if (n <= 0) continue;
|
|
143
143
|
if (buf.length < n) buf = new Float32Array(n);
|
|
144
144
|
const vals = buf.subarray(0, n);
|
|
145
|
-
|
|
145
|
+
_chunkIFWLZZCWcjs.rasterizeDab.call(void 0, d, brush.hardness, rect, vals);
|
|
146
146
|
if (sampler) {
|
|
147
|
-
const { color, field } =
|
|
147
|
+
const { color, field } = _chunkIFWLZZCWcjs.gradientDabColor.call(void 0, sampler, tipTable, d, d.params, rect, vals, scratch);
|
|
148
148
|
coverage.accumulate(rect, vals, d.opacity, color, field);
|
|
149
149
|
} else coverage.accumulate(rect, vals, d.opacity);
|
|
150
150
|
if (!bounds) bounds = { ...rect };
|
|
@@ -161,7 +161,7 @@ function pathStrokeCoverage(samples, options) {
|
|
|
161
161
|
const { tx, ty } = _chunk474IQG74cjs.tileCoord.call(void 0, key);
|
|
162
162
|
for (let y = 0, k = 0; y < _chunk474IQG74cjs.TILE; y++) {
|
|
163
163
|
const gy = ty * _chunk474IQG74cjs.TILE + y + 0.5;
|
|
164
|
-
for (let x = 0; x < _chunk474IQG74cjs.TILE; x++, k++) if (t[k] > 0) t[k] *=
|
|
164
|
+
for (let x = 0; x < _chunk474IQG74cjs.TILE; x++, k++) if (t[k] > 0) t[k] *= _chunkIFWLZZCWcjs.strokeGrainCatch.call(void 0, grain.at(tx * _chunk474IQG74cjs.TILE + x + 0.5, gy), grain.depth, pressure);
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
167
|
}
|
|
@@ -169,11 +169,11 @@ function pathStrokeCoverage(samples, options) {
|
|
|
169
169
|
}
|
|
170
170
|
function paintPathStroke(surface, samples, options) {
|
|
171
171
|
if (surface.channels !== 4) throw new Error("paintPathStroke paints RGBA surfaces (4 channels).");
|
|
172
|
-
const brush =
|
|
172
|
+
const brush = _chunkIFWLZZCWcjs.normalizeBrush.call(void 0, options.brush);
|
|
173
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("");
|
|
174
174
|
let color = options.color;
|
|
175
175
|
if (_optionalChain([options, 'access', _11 => _11.paint, 'optionalAccess', _12 => _12.paint, 'access', _13 => _13.type]) === "color") {
|
|
176
|
-
const rgb =
|
|
176
|
+
const rgb = _chunkIFWLZZCWcjs.hexToPaintRgb.call(void 0, options.paint.paint.color).map((v) => Math.round(v * 255));
|
|
177
177
|
color = [rgb[0], rgb[1], rgb[2], color[3]];
|
|
178
178
|
}
|
|
179
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;
|
|
@@ -195,7 +195,7 @@ function paintPathStroke(surface, samples, options) {
|
|
|
195
195
|
const key = _chunk474IQG74cjs.tileKey.call(void 0, tx, ty);
|
|
196
196
|
const src = _optionalChain([surface, 'access', _17 => _17.tiles, 'access', _18 => _18.get, 'call', _19 => _19(key), 'optionalAccess', _20 => _20.data]);
|
|
197
197
|
const base = src && src.length === _chunk474IQG74cjs.TILE * _chunk474IQG74cjs.TILE * 4 ? src : new Uint8ClampedArray(_chunk474IQG74cjs.TILE * _chunk474IQG74cjs.TILE * 4);
|
|
198
|
-
const t = _chunk474IQG74cjs.finishTile.call(void 0,
|
|
198
|
+
const t = _chunk474IQG74cjs.finishTile.call(void 0, _chunkIFWLZZCWcjs.applyStrokeToTile.call(void 0, coverage, base, 4, tx, ty, apply), 4, surface.defaultValue);
|
|
199
199
|
if (t) tiles.set(key, t);
|
|
200
200
|
else tiles.delete(key);
|
|
201
201
|
}
|
|
@@ -239,7 +239,7 @@ var REFUSED_ENGINES = {
|
|
|
239
239
|
};
|
|
240
240
|
function brushstrokeStrokeOptions(brush) {
|
|
241
241
|
if (!brush || typeof brush !== "object") throw new Error("A brushstroke needs a brush: tip settings ({ size, hardness, \u2026 }) or a paint brush preset.");
|
|
242
|
-
if (!("tip" in brush) || !brush.tip) return { brush:
|
|
242
|
+
if (!("tip" in brush) || !brush.tip) return { brush: _chunkIFWLZZCWcjs.normalizeBrush.call(void 0, brush) };
|
|
243
243
|
const engine = _nullishCoalesce(brush.engine, () => ( "dab"));
|
|
244
244
|
if (engine !== "dab") {
|
|
245
245
|
const label = _nullishCoalesce(_nullishCoalesce(brush.name, () => ( brush.id)), () => ( "This brush"));
|
|
@@ -249,7 +249,7 @@ function brushstrokeStrokeOptions(brush) {
|
|
|
249
249
|
const d = _nullishCoalesce(brush.dynamics, () => ( {}));
|
|
250
250
|
const tilt = { size: _nullishCoalesce(d.tiltSize, () => ( 0)), roundness: _nullishCoalesce(d.tiltRoundness, () => ( 0)) };
|
|
251
251
|
return {
|
|
252
|
-
brush:
|
|
252
|
+
brush: _chunkIFWLZZCWcjs.normalizeBrush.call(void 0, brush.tip),
|
|
253
253
|
followPath: brush.rotation === "stroke",
|
|
254
254
|
minSize: _nullishCoalesce(d.minSize, () => ( 0)),
|
|
255
255
|
...tilt.size || tilt.roundness ? { tilt } : {}
|
|
@@ -273,7 +273,7 @@ function paperGrain(paper) {
|
|
|
273
273
|
const key = `${pattern}:${seed}:${scale}`;
|
|
274
274
|
let g = papers.get(key);
|
|
275
275
|
if (!g) {
|
|
276
|
-
g = new (0,
|
|
276
|
+
g = new (0, _chunkIFWLZZCWcjs.PaperGrain)({ pattern, seed, scale, tiling: "mirror", dry: { contrast: 1, invert: false }, wet: { contrast: 1, invert: false } });
|
|
277
277
|
if (papers.size > 16) papers.delete(papers.keys().next().value);
|
|
278
278
|
papers.set(key, g);
|
|
279
279
|
}
|
|
@@ -326,7 +326,7 @@ function renderBrushstroke(input, brush, options = {}) {
|
|
|
326
326
|
closed: _nullishCoalesce(options.closed, () => ( strokeOptions.closed)),
|
|
327
327
|
color,
|
|
328
328
|
// Gradient lengths are in path units: scale them with the image.
|
|
329
|
-
...source ? { paint: { paint: source.type === "gradient" ?
|
|
329
|
+
...source ? { paint: { paint: source.type === "gradient" ? _chunkIFWLZZCWcjs.scalePaintGradient.call(void 0, source, scale) : source, seed: _nullishCoalesce(options.seed, () => ( 0)) } } : {}
|
|
330
330
|
});
|
|
331
331
|
if (!bounds) return { image: { width: 0, height: 0, data: new Uint8ClampedArray(0) }, bounds: null, scale, dabs };
|
|
332
332
|
const rect = bounds;
|