@pixerate/editor 0.267.0 → 0.268.1

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.
Files changed (83) hide show
  1. package/dist/animation-editor/index.cjs +62 -62
  2. package/dist/animation-editor/index.js +6 -6
  3. package/dist/brushes/index.cjs +198 -72
  4. package/dist/brushes/index.d.cts +4 -3
  5. package/dist/brushes/index.d.ts +4 -3
  6. package/dist/brushes/index.js +136 -10
  7. package/dist/brushes/library.d.cts +27 -1
  8. package/dist/brushes/library.d.ts +27 -1
  9. package/dist/brushes/profiles.d.cts +4 -0
  10. package/dist/brushes/profiles.d.ts +4 -0
  11. package/dist/brushes/schema.d.cts +4 -0
  12. package/dist/brushes/schema.d.ts +4 -0
  13. package/dist/brushes/sources.d.cts +114 -0
  14. package/dist/brushes/sources.d.ts +114 -0
  15. package/dist/brushes/types.d.cts +37 -5
  16. package/dist/brushes/types.d.ts +37 -5
  17. package/dist/brushes/ui.d.cts +40 -4
  18. package/dist/brushes/ui.d.ts +40 -4
  19. package/dist/{brushstrokeRender-NLFPEBGI.js → brushstrokeRender-A727TTNQ.js} +6 -6
  20. package/dist/{brushstrokeRender-L7JYRR2R.cjs → brushstrokeRender-WR2N5HHY.cjs} +22 -22
  21. package/dist/canvas/index.cjs +13 -13
  22. package/dist/canvas/index.js +1 -1
  23. package/dist/{chunk-J2TNIZ55.cjs → chunk-2WOGXEDX.cjs} +1 -1
  24. package/dist/{chunk-JGWVZPT6.js → chunk-3XDSNIGF.js} +72 -5
  25. package/dist/{chunk-EXB2EGBE.cjs → chunk-62MFUHSI.cjs} +16 -16
  26. package/dist/{chunk-GCVFEPJG.js → chunk-ACTHSQOI.js} +182 -0
  27. package/dist/{chunk-EF7LZAXQ.js → chunk-BAZMCFVL.js} +1 -1
  28. package/dist/{chunk-HIO6E7LC.cjs → chunk-BPJSI4NT.cjs} +2 -2
  29. package/dist/{chunk-XVOP3CGQ.cjs → chunk-EU2ZZA6L.cjs} +393 -62
  30. package/dist/{chunk-YIC6MAJ2.js → chunk-HFY5LG5J.js} +1 -1
  31. package/dist/{chunk-7UKFXXWL.js → chunk-HVO6XCI4.js} +1 -1
  32. package/dist/{chunk-LHPEG5AU.cjs → chunk-J4GXP53R.cjs} +140 -91
  33. package/dist/{chunk-OKHKA43L.cjs → chunk-JBB3GDBB.cjs} +330 -216
  34. package/dist/{chunk-AGNUD5BI.js → chunk-KZI3YWKW.js} +351 -20
  35. package/dist/{chunk-FGJHJIMN.js → chunk-LDOD7VCT.js} +59 -10
  36. package/dist/{chunk-EYSHTYLG.js → chunk-LETF75CA.js} +1 -1
  37. package/dist/{chunk-FQPUF2W2.cjs → chunk-NIBFKXMD.cjs} +217 -35
  38. package/dist/{chunk-G7NHE2VD.cjs → chunk-NPWWSCWT.cjs} +35 -35
  39. package/dist/{chunk-OSEXT7JL.js → chunk-QNY7BDFP.js} +1 -1
  40. package/dist/{chunk-PXDIAYB6.cjs → chunk-STLTOISW.cjs} +34 -214
  41. package/dist/{chunk-4IDUYB45.js → chunk-UVTO3D4E.js} +130 -16
  42. package/dist/{chunk-TXFWZ5ZJ.js → chunk-W6JDUXP3.js} +4 -184
  43. package/dist/{chunk-LA5Y4ETA.cjs → chunk-YOVXQHA3.cjs} +23 -23
  44. package/dist/{chunk-DT4YQUGT.cjs → chunk-YXP6X3SY.cjs} +101 -34
  45. package/dist/image-editor/adjustment-layers.d.cts +8 -0
  46. package/dist/image-editor/adjustment-layers.d.ts +8 -0
  47. package/dist/image-editor/index.cjs +857 -853
  48. package/dist/image-editor/index.js +30 -26
  49. package/dist/paint/index.cjs +5 -5
  50. package/dist/paint/index.js +11 -11
  51. package/dist/paint-editor/brush-library-tools.d.cts +12 -2
  52. package/dist/paint-editor/brush-library-tools.d.ts +12 -2
  53. package/dist/paint-editor/brush-model.d.cts +29 -1
  54. package/dist/paint-editor/brush-model.d.ts +29 -1
  55. package/dist/paint-editor/brush-source-art.d.cts +32 -0
  56. package/dist/paint-editor/brush-source-art.d.ts +32 -0
  57. package/dist/paint-editor/controller.d.cts +6 -1
  58. package/dist/paint-editor/controller.d.ts +6 -1
  59. package/dist/paint-editor/dab-stroke.d.cts +2 -0
  60. package/dist/paint-editor/dab-stroke.d.ts +2 -0
  61. package/dist/paint-editor/engine.d.cts +11 -2
  62. package/dist/paint-editor/engine.d.ts +11 -2
  63. package/dist/paint-editor/index.cjs +576 -481
  64. package/dist/paint-editor/index.d.cts +3 -1
  65. package/dist/paint-editor/index.d.ts +3 -1
  66. package/dist/paint-editor/index.js +127 -32
  67. package/dist/paint-editor/stamp-tip.d.cts +8 -5
  68. package/dist/paint-editor/stamp-tip.d.ts +8 -5
  69. package/dist/paint-editor/thumbnails.d.cts +6 -0
  70. package/dist/paint-editor/thumbnails.d.ts +6 -0
  71. package/dist/paint-editor/tip-grain.d.cts +34 -0
  72. package/dist/paint-editor/tip-grain.d.ts +34 -0
  73. package/dist/raster/index.cjs +2 -2
  74. package/dist/raster/index.js +9 -9
  75. package/dist/vector/index.cjs +1002 -1002
  76. package/dist/vector/index.js +7 -7
  77. package/package.json +110 -1
  78. package/skills/pixerate-brushes/SKILL.md +35 -8
  79. package/skills/pixerate-brushes-design/SKILL.md +8 -1
  80. package/skills/pixerate-image-editor/SKILL.md +1 -1
  81. package/skills/pixerate-paint-editor/SKILL.md +6 -0
  82. package/skills/pixerate-paint-editor/references/brush-facets.md +3 -1
  83. package/skills/pixerate-paint-sketch-to-finish/SKILL.md +1 -0
@@ -115,7 +115,7 @@ import {
115
115
  transformTextRect,
116
116
  translateMatrix,
117
117
  warpPresetMesh
118
- } from "./chunk-4IDUYB45.js";
118
+ } from "./chunk-UVTO3D4E.js";
119
119
  import {
120
120
  bezierPathBounds,
121
121
  outlineStroke,
@@ -129,15 +129,7 @@ import {
129
129
  } from "./chunk-DVPQFMH6.js";
130
130
  import {
131
131
  MAX_BRUSH_SIZE
132
- } from "./chunk-GCVFEPJG.js";
133
- import {
134
- base64ToBytes,
135
- bytesToBase64,
136
- decodePng,
137
- encodePng,
138
- parseDataUrl,
139
- pngDataUrl
140
- } from "./chunk-OTTT5N3K.js";
132
+ } from "./chunk-ACTHSQOI.js";
141
133
  import {
142
134
  BLEND_MODES,
143
135
  blendRgb,
@@ -150,6 +142,14 @@ import {
150
142
  surfaceFromDeepPixels,
151
143
  writeDeepRegion
152
144
  } from "./chunk-IRSTHLQQ.js";
145
+ import {
146
+ base64ToBytes,
147
+ bytesToBase64,
148
+ decodePng,
149
+ encodePng,
150
+ parseDataUrl,
151
+ pngDataUrl
152
+ } from "./chunk-OTTT5N3K.js";
153
153
  import {
154
154
  TILE,
155
155
  TiledSurface,
@@ -1038,6 +1038,54 @@ function normParams(kind, raw) {
1038
1038
  return {};
1039
1039
  }
1040
1040
  }
1041
+ function describeParamShape(template) {
1042
+ if (Array.isArray(template)) return `[${describeParamShape(template[0])}]`;
1043
+ if (template && typeof template === "object") {
1044
+ const fields = Object.entries(template).map(([k, v]) => v && typeof v === "object" ? `${k}: ${describeParamShape(v)}` : k);
1045
+ return `{${fields.join(", ")}}`;
1046
+ }
1047
+ return typeof template === "number" ? "number" : "value";
1048
+ }
1049
+ function checkParamShape(value, template, path, unknown, invalid) {
1050
+ if (Array.isArray(template)) {
1051
+ if (!Array.isArray(value)) invalid.push(`${path} must be an array`);
1052
+ else value.forEach((item, i) => item !== null && checkParamShape(item, template[0], `${path}.${i}`, unknown, invalid));
1053
+ } else if (template && typeof template === "object") {
1054
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
1055
+ if (path) invalid.push(`${path} must be an object`);
1056
+ return;
1057
+ }
1058
+ for (const [key, item] of Object.entries(value)) {
1059
+ const at = path ? `${path}.${key}` : key;
1060
+ if (Object.hasOwn(template, key)) checkParamShape(item, template[key], at, unknown, invalid);
1061
+ else unknown.push(at);
1062
+ }
1063
+ } else if (typeof template === "string" || template === null) {
1064
+ if (!(template === null && value === null) && !(typeof value === "string" && HEX.test(value))) {
1065
+ invalid.push(`${path} must be a #rrggbb colour${template === null ? " or null" : ""}`);
1066
+ }
1067
+ } else if (typeof value !== typeof template || typeof value === "number" && !Number.isFinite(value)) {
1068
+ invalid.push(`${path} must be a ${typeof template}`);
1069
+ }
1070
+ }
1071
+ function assertAdjustmentParams(kind, params) {
1072
+ if (params === void 0) return;
1073
+ const template = defaultAdjustmentParams(kind);
1074
+ const unknown = [];
1075
+ const invalid = [];
1076
+ if (!params || typeof params !== "object" || Array.isArray(params)) invalid.push("params must be an object");
1077
+ else checkParamShape(params, template, "", unknown, invalid);
1078
+ if (!unknown.length && !invalid.length) return;
1079
+ const problems = [];
1080
+ if (unknown.length) problems.push(`Unknown params key(s) for a ${kind} layer: ${unknown.join(", ")}.`);
1081
+ if (invalid.length) problems.push(`Invalid params for a ${kind} layer: ${invalid.join("; ")}.`);
1082
+ if (unknown.some((key) => key.includes("."))) {
1083
+ problems.push('Nest parameters as objects and arrays: dotted control ids only work in set_adjustments ("layers.<layerId>.<controlId>").');
1084
+ }
1085
+ const accepted = describeParamShape(template);
1086
+ problems.push(accepted === "{}" ? `This ${kind} layer takes no params.` : `Accepted: ${accepted}.`);
1087
+ throw new Error(problems.join(" "));
1088
+ }
1041
1089
  function normalizeAdjustmentLayer(raw) {
1042
1090
  if (!raw || typeof raw !== "object") return null;
1043
1091
  const r = raw;
@@ -12959,6 +13007,7 @@ export {
12959
13007
  identityLevels,
12960
13008
  defaultAdjustmentParams,
12961
13009
  createAdjustmentLayer,
13010
+ assertAdjustmentParams,
12962
13011
  normalizeAdjustmentLayer,
12963
13012
  normalizeAdjustmentLayers,
12964
13013
  curveLutFromLevels,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  PAINT_PROFILE
3
- } from "./chunk-AGNUD5BI.js";
3
+ } from "./chunk-KZI3YWKW.js";
4
4
  import {
5
5
  brushColourHex
6
6
  } from "./chunk-DVPQFMH6.js";
@@ -1,4 +1,6 @@
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; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7;
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; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8;
2
+
3
+
2
4
 
3
5
  var _chunk3K6HWEXZcjs = require('./chunk-3K6HWEXZ.cjs');
4
6
 
@@ -1078,6 +1080,180 @@ function coverageTileCoord(key) {
1078
1080
  return _chunk474IQG74cjs.tileCoord.call(void 0, key);
1079
1081
  }
1080
1082
 
1083
+ // src/paint/grain.ts
1084
+ var GRAIN_PATTERNS = ["smooth", "cold-pressed", "hot-pressed", "rough", "vellum", "laid", "ingres", "sanded", "canvas", "linen", "gesso"];
1085
+ var GRAIN_TILE = 256;
1086
+ var clamp01 = (v) => v < 0 ? 0 : v > 1 ? 1 : v;
1087
+ function patternHeights(pattern, n, seed) {
1088
+ const out = new Float32Array(n * n);
1089
+ const salt = Math.imul(seed | 0, 2654435761) + 17;
1090
+ if (pattern === "smooth") return out.fill(1);
1091
+ const noise = (cx, cy, oct, s = 0) => new (0, _chunk3K6HWEXZcjs.TileableNoise)(n, cx, cy, oct, salt + s);
1092
+ const k = n / GRAIN_TILE;
1093
+ switch (pattern) {
1094
+ case "cold-pressed": {
1095
+ const base = noise(20 * k, 20 * k, 4);
1096
+ const fine = noise(64 * k, 64 * k, 2, 3);
1097
+ for (let y = 0; y < n; y++)
1098
+ 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);
1099
+ break;
1100
+ }
1101
+ case "hot-pressed": {
1102
+ const base = noise(40 * k, 40 * k, 3);
1103
+ 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);
1104
+ break;
1105
+ }
1106
+ case "rough": {
1107
+ const base = noise(10 * k, 10 * k, 5);
1108
+ const blot = noise(28 * k, 28 * k, 2, 5);
1109
+ for (let y = 0; y < n; y++)
1110
+ 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);
1111
+ break;
1112
+ }
1113
+ case "vellum": {
1114
+ const base = noise(40 * k, 40 * k, 3);
1115
+ 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);
1116
+ break;
1117
+ }
1118
+ case "laid": {
1119
+ const pulp = noise(32 * k, 32 * k, 3);
1120
+ const chain = n / 8;
1121
+ for (let y = 0; y < n; y++) {
1122
+ const laid = 0.5 + 0.5 * Math.cos(2 * Math.PI * y / 4);
1123
+ for (let x = 0; x < n; x++) {
1124
+ const c = Math.abs((x + 0.5) % chain - chain / 2) / (chain / 2);
1125
+ const chainLine = c > 0.94 ? -0.35 : 0;
1126
+ out[y * n + x] = clamp01(0.3 + 0.5 * laid + chainLine + (pulp.at(x, y) - 0.5) * 0.6);
1127
+ }
1128
+ }
1129
+ break;
1130
+ }
1131
+ case "ingres": {
1132
+ const fibres = noise(64 * k, 12 * k, 3);
1133
+ const base = noise(16 * k, 16 * k, 3, 7);
1134
+ for (let y = 0; y < n; y++)
1135
+ for (let x = 0; x < n; x++) {
1136
+ const g = _chunk3K6HWEXZcjs.hash2.call(void 0, x, y, salt ^ 85);
1137
+ 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));
1138
+ }
1139
+ break;
1140
+ }
1141
+ case "sanded": {
1142
+ const grit = noise(96 * k, 96 * k, 2);
1143
+ for (let y = 0; y < n; y++)
1144
+ for (let x = 0; x < n; x++) {
1145
+ const h = _chunk3K6HWEXZcjs.hash2.call(void 0, x, y, salt);
1146
+ out[y * n + x] = clamp01((grit.at(x, y) - 0.5) * 2.4 + 0.5 + (h - 0.5) * 0.7);
1147
+ }
1148
+ break;
1149
+ }
1150
+ case "canvas":
1151
+ case "linen": {
1152
+ const period = (pattern === "canvas" ? 8 : 5) * k;
1153
+ const threads = Math.max(2, 2 * Math.round(n / period / 2));
1154
+ const p = n / threads;
1155
+ const slub = noise(threads, threads, 2, 11);
1156
+ for (let y = 0; y < n; y++)
1157
+ for (let x = 0; x < n; x++) {
1158
+ const fx = (x + 0.5) / p;
1159
+ const fy = (y + 0.5) / p;
1160
+ const cx = Math.floor(fx);
1161
+ const cy = Math.floor(fy);
1162
+ const warp = Math.sin(Math.PI * (fx - cx));
1163
+ const weft = Math.sin(Math.PI * (fy - cy));
1164
+ const top = (cx + cy) % 2 === 0 ? warp : weft;
1165
+ const irregular = pattern === "linen" ? (slub.at(x, y) - 0.5) * 0.5 : 0;
1166
+ out[y * n + x] = clamp01(0.2 + 0.7 * top + irregular + (_chunk3K6HWEXZcjs.hash2.call(void 0, x, y, salt) - 0.5) * 0.15);
1167
+ }
1168
+ break;
1169
+ }
1170
+ case "gesso": {
1171
+ const streaks = noise(2 * k, 28 * k, 3);
1172
+ const tooth = noise(64 * k, 64 * k, 2, 13);
1173
+ for (let y = 0; y < n; y++)
1174
+ 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);
1175
+ break;
1176
+ }
1177
+ }
1178
+ return out;
1179
+ }
1180
+ var rawCache = /* @__PURE__ */ new Map();
1181
+ function grainHeights(pattern, seed, size = GRAIN_TILE) {
1182
+ const key = `${pattern}:${seed}:${size}`;
1183
+ let h = rawCache.get(key);
1184
+ if (!h) {
1185
+ h = patternHeights(pattern, size, seed);
1186
+ if (rawCache.size > 32) rawCache.delete(rawCache.keys().next().value);
1187
+ rawCache.set(key, h);
1188
+ }
1189
+ return h;
1190
+ }
1191
+ var PaperGrain = (_class4 = class {
1192
+ __init21() {this.size = GRAIN_TILE}
1193
+
1194
+
1195
+
1196
+
1197
+
1198
+
1199
+ constructor(paper, media = "dry") {;_class4.prototype.__init21.call(this);
1200
+ const raw = grainHeights(paper.pattern, paper.seed);
1201
+ const t = paper[media];
1202
+ this.flat = paper.pattern === "smooth";
1203
+ if (t.contrast === 1 && !t.invert) this.heights = raw;
1204
+ else {
1205
+ const out = new Float32Array(raw.length);
1206
+ for (let i = 0; i < raw.length; i++) {
1207
+ const v = clamp01((raw[i] - 0.5) * t.contrast + 0.5);
1208
+ out[i] = t.invert ? 1 - v : v;
1209
+ }
1210
+ this.heights = out;
1211
+ }
1212
+ this.scale = paper.scale;
1213
+ this.mirror = paper.tiling === "mirror";
1214
+ this.ox = _nullishCoalesce(_optionalChain([paper, 'access', _5 => _5.offset, 'optionalAccess', _6 => _6.x]), () => ( 0));
1215
+ this.oy = _nullishCoalesce(_optionalChain([paper, 'access', _7 => _7.offset, 'optionalAccess', _8 => _8.y]), () => ( 0));
1216
+ }
1217
+ /** Tile cell index for a coordinate in grain pixels (mirrored on odd tiles when mirroring). */
1218
+ wrap(v) {
1219
+ const n = this.size;
1220
+ if (!this.mirror) return (v % n + n) % n;
1221
+ const p = (v % (2 * n) + 2 * n) % (2 * n);
1222
+ return p < n ? p : 2 * n - 1 - p;
1223
+ }
1224
+ /** Height 0..1 at document position (x, y). */
1225
+ at(x, y) {
1226
+ const u = (x - this.ox) / this.scale - 0.5;
1227
+ const v = (y - this.oy) / this.scale - 0.5;
1228
+ const x0 = Math.floor(u);
1229
+ const y0 = Math.floor(v);
1230
+ const fx = u - x0;
1231
+ const fy = v - y0;
1232
+ const n = this.size;
1233
+ const h = this.heights;
1234
+ const a = this.wrap(x0);
1235
+ const b = this.wrap(x0 + 1);
1236
+ const c = this.wrap(y0) * n;
1237
+ const d = this.wrap(y0 + 1) * n;
1238
+ const top = h[c + a] + (h[c + b] - h[c + a]) * fx;
1239
+ const bot = h[d + a] + (h[d + b] - h[d + a]) * fx;
1240
+ return top + (bot - top) * fy;
1241
+ }
1242
+ }, _class4);
1243
+ function grainCatch(h, depth, pressure) {
1244
+ if (depth <= 0) return 1;
1245
+ const t = depth * (0.75 - 0.65 * Math.min(1, Math.max(0, pressure)));
1246
+ const u = clamp01((h - t + 0.18) / 0.36);
1247
+ return 1 - depth + depth * u * u * (3 - 2 * u);
1248
+ }
1249
+ function strokeGrainCatch(h, depth, pressure) {
1250
+ if (depth <= 0) return 1;
1251
+ const p = Math.min(1, Math.max(0, pressure));
1252
+ const amount = Math.min(1, depth * (1.4 - 0.6 * p));
1253
+ const u = clamp01((h - 0.2 - 0.25 * (1 - p)) / 0.5);
1254
+ return 1 - amount + amount * u * u * (3 - 2 * u);
1255
+ }
1256
+
1081
1257
  // src/paint/exchange.ts
1082
1258
  var MIXING_MODELS = ["rgb", "pigment"];
1083
1259
  var EMPTY_MIXER_LOAD = { reservoir: null, amount: 0, pickup: null };
@@ -1086,8 +1262,8 @@ var MIXER_DRAIN = 0.08;
1086
1262
  function exchangeRates(pickup, mix, load, mixing) {
1087
1263
  return { pickup: MIXER_PICKUP_RATE * pickup, mix: mix * pickup, drain: MIXER_DRAIN * (1 - load), mixing };
1088
1264
  }
1089
- var PaintExchange = (_class4 = class {
1090
- constructor(rates, load) {;_class4.prototype.__init21.call(this);
1265
+ var PaintExchange = (_class5 = class {
1266
+ constructor(rates, load) {;_class5.prototype.__init22.call(this);
1091
1267
  this.rates = rates;
1092
1268
  this.reservoir = load.reservoir ? [load.reservoir[0], load.reservoir[1], load.reservoir[2]] : null;
1093
1269
  this.amount = this.reservoir ? Math.min(1, Math.max(0, load.amount)) : 0;
@@ -1099,7 +1275,7 @@ var PaintExchange = (_class4 = class {
1099
1275
 
1100
1276
 
1101
1277
 
1102
- __init21() {this.out = [0, 0, 0]}
1278
+ __init22() {this.out = [0, 0, 0]}
1103
1279
  /** What the brush carries now. */
1104
1280
  get load() {
1105
1281
  return { reservoir: this.reservoir ? [...this.reservoir] : null, amount: this.amount, pickup: this.well ? [...this.well] : null };
@@ -1110,7 +1286,7 @@ var PaintExchange = (_class4 = class {
1110
1286
  }
1111
1287
  /** The prepared pigment of the last `paint` colour (pigment mixing only), for `deposit`. */
1112
1288
  get paintPigment() {
1113
- return _nullishCoalesce(_optionalChain([this, 'access', _5 => _5.pig, 'optionalAccess', _6 => _6.paint]), () => ( null));
1289
+ return _nullishCoalesce(_optionalChain([this, 'access', _9 => _9.pig, 'optionalAccess', _10 => _10.paint]), () => ( null));
1114
1290
  }
1115
1291
  /** Recolours the reservoir without refilling it (a multi-coloured brush, per dab). */
1116
1292
  setReservoirColor(r, g, b) {
@@ -1147,7 +1323,7 @@ var PaintExchange = (_class4 = class {
1147
1323
  if (!this.well) this.well = [sample.rgb[0], sample.rgb[1], sample.rgb[2]];
1148
1324
  else {
1149
1325
  if (pig) _chunk2VX55NFMcjs.setPigmentColor.call(void 0, pig.canvas, sample.rgb[0], sample.rgb[1], sample.rgb[2]);
1150
- const o = this.mix(this.well, _nullishCoalesce(_optionalChain([pig, 'optionalAccess', _7 => _7.well]), () => ( null)), sample.rgb, _nullishCoalesce(_optionalChain([pig, 'optionalAccess', _8 => _8.canvas]), () => ( null)), this.rates.pickup * sample.contact);
1326
+ const o = this.mix(this.well, _nullishCoalesce(_optionalChain([pig, 'optionalAccess', _11 => _11.well]), () => ( null)), sample.rgb, _nullishCoalesce(_optionalChain([pig, 'optionalAccess', _12 => _12.canvas]), () => ( null)), this.rates.pickup * sample.contact);
1151
1327
  this.well = [o[0], o[1], o[2]];
1152
1328
  }
1153
1329
  if (pig) _chunk2VX55NFMcjs.setPigmentColor.call(void 0, pig.well, this.well[0], this.well[1], this.well[2]);
@@ -1165,7 +1341,7 @@ var PaintExchange = (_class4 = class {
1165
1341
  if (!(total > 1e-6)) return 0;
1166
1342
  const pig = this.pig;
1167
1343
  if (res && this.well) {
1168
- const m = this.mix(res, _nullishCoalesce(_optionalChain([pig, 'optionalAccess', _9 => _9.res]), () => ( null)), this.well, _nullishCoalesce(_optionalChain([pig, 'optionalAccess', _10 => _10.well]), () => ( null)), wp / total);
1344
+ const m = this.mix(res, _nullishCoalesce(_optionalChain([pig, 'optionalAccess', _13 => _13.res]), () => ( null)), this.well, _nullishCoalesce(_optionalChain([pig, 'optionalAccess', _14 => _14.well]), () => ( null)), wp / total);
1169
1345
  out[0] = m[0];
1170
1346
  out[1] = m[1];
1171
1347
  out[2] = m[2];
@@ -1182,29 +1358,29 @@ var PaintExchange = (_class4 = class {
1182
1358
  drain() {
1183
1359
  this.amount *= 1 - this.rates.drain;
1184
1360
  }
1185
- }, _class4);
1361
+ }, _class5);
1186
1362
  function put255(px, i, v) {
1187
1363
  if (px instanceof Float32Array) px[i] = v > 0 ? v * 255 : 0;
1188
1364
  else px[i] = Math.round(v * 255);
1189
1365
  }
1190
- var TileMedium = (_class5 = class {
1191
- constructor(target, options = {}) {;_class5.prototype.__init22.call(this);_class5.prototype.__init23.call(this);_class5.prototype.__init24.call(this);_class5.prototype.__init25.call(this);_class5.prototype.__init26.call(this);_class5.prototype.__init27.call(this);_class5.prototype.__init28.call(this);_class5.prototype.__init29.call(this);_class5.prototype.__init30.call(this);_class5.prototype.__init31.call(this);
1366
+ var TileMedium = (_class6 = class {
1367
+ constructor(target, options = {}) {;_class6.prototype.__init23.call(this);_class6.prototype.__init24.call(this);_class6.prototype.__init25.call(this);_class6.prototype.__init26.call(this);_class6.prototype.__init27.call(this);_class6.prototype.__init28.call(this);_class6.prototype.__init29.call(this);_class6.prototype.__init30.call(this);_class6.prototype.__init31.call(this);_class6.prototype.__init32.call(this);
1192
1368
  this.target = target;
1193
1369
  this.options = options;
1194
1370
  }
1195
1371
 
1196
1372
 
1197
1373
  // The tile last looked up by `locate` (and whether it came from `writeTile`).
1198
- __init22() {this.tx = NaN}
1199
- __init23() {this.ty = NaN}
1200
- __init24() {this.tile = null}
1201
- __init25() {this.writable = false}
1202
- __init26() {this.canvasPig = _chunk2VX55NFMcjs.createPigment.call(void 0, [0, 0, 0])}
1203
- __init27() {this.paintPig = _chunk2VX55NFMcjs.createPigment.call(void 0, [0, 0, 0])}
1204
- __init28() {this.paintKey = -1}
1205
- __init29() {this.cb = [0, 0, 0, 0]}
1206
- __init30() {this.src = [0, 0, 0, 1]}
1207
- __init31() {this.o = [0, 0, 0]}
1374
+ __init23() {this.tx = NaN}
1375
+ __init24() {this.ty = NaN}
1376
+ __init25() {this.tile = null}
1377
+ __init26() {this.writable = false}
1378
+ __init27() {this.canvasPig = _chunk2VX55NFMcjs.createPigment.call(void 0, [0, 0, 0])}
1379
+ __init28() {this.paintPig = _chunk2VX55NFMcjs.createPigment.call(void 0, [0, 0, 0])}
1380
+ __init29() {this.paintKey = -1}
1381
+ __init30() {this.cb = [0, 0, 0, 0]}
1382
+ __init31() {this.src = [0, 0, 0, 1]}
1383
+ __init32() {this.o = [0, 0, 0]}
1208
1384
  /** Forgets the cached tile (call when another writer may have replaced tiles). */
1209
1385
  reset() {
1210
1386
  this.tx = NaN;
@@ -1349,7 +1525,7 @@ var TileMedium = (_class5 = class {
1349
1525
  }
1350
1526
  }
1351
1527
  }
1352
- }, _class5);
1528
+ }, _class6);
1353
1529
 
1354
1530
  // src/paint/blending.ts
1355
1531
  var DEFAULT_BLENDER = { strength: 0.5, distance: 0.35, mixing: "pigment" };
@@ -1465,8 +1641,8 @@ function blenderDab(medium, rect, cov, opacity, radius, settings, scratch) {
1465
1641
  }
1466
1642
  }
1467
1643
  }
1468
- var SmudgeTip = (_class6 = class {
1469
- constructor(settings, diameter) {;_class6.prototype.__init32.call(this);_class6.prototype.__init33.call(this);
1644
+ var SmudgeTip = (_class7 = class {
1645
+ constructor(settings, diameter) {;_class7.prototype.__init33.call(this);_class7.prototype.__init34.call(this);
1470
1646
  this.settings = settings;
1471
1647
  this.size = Math.max(2, Math.min(512, Math.ceil(diameter)));
1472
1648
  this.patch = new Float32Array(this.size * this.size * 4);
@@ -1474,8 +1650,8 @@ var SmudgeTip = (_class6 = class {
1474
1650
 
1475
1651
 
1476
1652
 
1477
- __init32() {this.loaded = false}
1478
- __init33() {this.out = [0, 0, 0]}
1653
+ __init33() {this.loaded = false}
1654
+ __init34() {this.out = [0, 0, 0]}
1479
1655
  cell(d, px, py) {
1480
1656
  const s = this.size;
1481
1657
  const r = Math.max(0.5, d.radius);
@@ -1586,7 +1762,7 @@ var SmudgeTip = (_class6 = class {
1586
1762
  }
1587
1763
  }
1588
1764
  }
1589
- }, _class6);
1765
+ }, _class7);
1590
1766
 
1591
1767
  // src/paint/mixer.ts
1592
1768
  var DEFAULT_MIXER = {
@@ -1619,22 +1795,22 @@ function loadMixer(load, color) {
1619
1795
  function cleanMixer(load) {
1620
1796
  return { reservoir: load.reservoir, amount: load.amount, pickup: null };
1621
1797
  }
1622
- var MixerStroke = (_class7 = class {
1623
- constructor(brush, settings, load, target) {;_class7.prototype.__init34.call(this);_class7.prototype.__init35.call(this);_class7.prototype.__init36.call(this);_class7.prototype.__init37.call(this);_class7.prototype.__init38.call(this);
1798
+ var MixerStroke = (_class8 = class {
1799
+ constructor(brush, settings, load, target) {;_class8.prototype.__init35.call(this);_class8.prototype.__init36.call(this);_class8.prototype.__init37.call(this);_class8.prototype.__init38.call(this);_class8.prototype.__init39.call(this);
1624
1800
  this.brush = brush;
1625
1801
  this.walker = new DabWalker(brush);
1626
1802
  this.exchange = new PaintExchange(mixerRates(normalizeMixer(settings)), load);
1627
1803
  this.medium = new TileMedium(target);
1628
1804
  }
1629
1805
 
1630
- __init34() {this.dabCount = 0}
1631
- __init35() {this.bounds = null}
1806
+ __init35() {this.dabCount = 0}
1807
+ __init36() {this.bounds = null}
1632
1808
 
1633
- __init36() {this.smoothPos = null}
1634
- __init37() {this.buf = new Float32Array(0)}
1809
+ __init37() {this.smoothPos = null}
1810
+ __init38() {this.buf = new Float32Array(0)}
1635
1811
 
1636
1812
 
1637
- __init38() {this.paintColor = [0, 0, 0]}
1813
+ __init39() {this.paintColor = [0, 0, 0]}
1638
1814
  /** The brush load after the dabs so far. */
1639
1815
  get load() {
1640
1816
  return this.exchange.load;
@@ -1682,7 +1858,7 @@ var MixerStroke = (_class7 = class {
1682
1858
  }
1683
1859
  ex.drain();
1684
1860
  }
1685
- }, _class7);
1861
+ }, _class8);
1686
1862
  function union(a, b) {
1687
1863
  if (!a) return { ...b };
1688
1864
  const x = Math.min(a.x, b.x);
@@ -1763,4 +1939,10 @@ function union(a, b) {
1763
1939
 
1764
1940
 
1765
1941
 
1766
- exports.PAINT_GRADIENT_SPACES = PAINT_GRADIENT_SPACES; exports.PAINT_GRADIENT_REPEATS = PAINT_GRADIENT_REPEATS; exports.PAINT_GRADIENT_MAPPINGS = PAINT_GRADIENT_MAPPINGS; exports.DEFAULT_PAINT_GRADIENT_MAPPING = DEFAULT_PAINT_GRADIENT_MAPPING; exports.PAINT_GRADIENT_FULL_SPEED = PAINT_GRADIENT_FULL_SPEED; exports.PaintSourceError = PaintSourceError; exports.normalizeHexColor = normalizeHexColor; exports.hexToPaintRgb = hexToPaintRgb; exports.parsePaintSource = parsePaintSource; exports.readPaintSource = readPaintSource; exports.resolvePaintGradient = resolvePaintGradient; exports.scalePaintGradient = scalePaintGradient; exports.solidPaint = solidPaint; exports.isGradientPaint = isGradientPaint; exports.paintSourceColor = paintSourceColor; exports.paintSourceCss = paintSourceCss; exports.PaintGradientSampler = PaintGradientSampler; exports.PAINT_GRADIENT_JSON_SCHEMA = PAINT_GRADIENT_JSON_SCHEMA; exports.PAINT_COLOR_JSON_SCHEMA = PAINT_COLOR_JSON_SCHEMA; exports.PAINT_SOURCE_JSON_SCHEMA = PAINT_SOURCE_JSON_SCHEMA; exports.PAINT_GRADIENT_MAPPING_LABELS = PAINT_GRADIENT_MAPPING_LABELS; exports.PAINT_GRADIENT_SPACE_LABELS = PAINT_GRADIENT_SPACE_LABELS; exports.PAINT_GRADIENT_REPEAT_LABELS = PAINT_GRADIENT_REPEAT_LABELS; exports.DEFAULT_PAINT_GRADIENT = DEFAULT_PAINT_GRADIENT; exports.PAINT_GRADIENT_PRESETS = PAINT_GRADIENT_PRESETS; exports.addPaintGradientStop = addPaintGradientStop; exports.removePaintGradientStop = removePaintGradientStop; exports.updatePaintGradientStop = updatePaintGradientStop; exports.reversePaintGradient = reversePaintGradient; exports.paintGradientMappingFor = paintGradientMappingFor; exports.PAINT_GRADIENT_KIT = PAINT_GRADIENT_KIT; exports.DEFAULT_BRUSH = DEFAULT_BRUSH; exports.MAX_BRUSH_SIZE = MAX_BRUSH_SIZE; exports.normalizeBrush = normalizeBrush; exports.tipShape = tipShape; exports.tipFalloff = tipFalloff; exports.tipReach = tipReach; exports.dabCoverage = dabCoverage; exports.smoothPoints = smoothPoints; exports.DabWalker = DabWalker; exports.walkDabs = walkDabs; exports.dabRect = dabRect; exports.rasterizeDab = rasterizeDab; exports.CoverageMap = CoverageMap; exports.StrokeCoverage = StrokeCoverage; exports.TIP_GRADIENT_STEPS = TIP_GRADIENT_STEPS; exports.gradientDabColor = gradientDabColor; exports.applyStrokeToTile = applyStrokeToTile; exports.applyStrokeToDeepTile = applyStrokeToDeepTile; exports.coverageTileCoord = coverageTileCoord; exports.MIXING_MODELS = MIXING_MODELS; exports.EMPTY_MIXER_LOAD = EMPTY_MIXER_LOAD; exports.MIXER_PICKUP_RATE = MIXER_PICKUP_RATE; exports.MIXER_DRAIN = MIXER_DRAIN; exports.exchangeRates = exchangeRates; exports.PaintExchange = PaintExchange; exports.put255 = put255; exports.TileMedium = TileMedium; exports.DEFAULT_BLENDER = DEFAULT_BLENDER; exports.DEFAULT_SMUDGE = DEFAULT_SMUDGE; exports.normalizeBlender = normalizeBlender; exports.normalizeSmudge = normalizeSmudge; exports.blendRadius = blendRadius; exports.createBlenderScratch = createBlenderScratch; exports.blenderDab = blenderDab; exports.SmudgeTip = SmudgeTip; exports.DEFAULT_MIXER = DEFAULT_MIXER; exports.normalizeMixer = normalizeMixer; exports.mixerRates = mixerRates; exports.loadMixer = loadMixer; exports.cleanMixer = cleanMixer; exports.MixerStroke = MixerStroke;
1942
+
1943
+
1944
+
1945
+
1946
+
1947
+
1948
+ exports.PAINT_GRADIENT_SPACES = PAINT_GRADIENT_SPACES; exports.PAINT_GRADIENT_REPEATS = PAINT_GRADIENT_REPEATS; exports.PAINT_GRADIENT_MAPPINGS = PAINT_GRADIENT_MAPPINGS; exports.DEFAULT_PAINT_GRADIENT_MAPPING = DEFAULT_PAINT_GRADIENT_MAPPING; exports.PAINT_GRADIENT_FULL_SPEED = PAINT_GRADIENT_FULL_SPEED; exports.PaintSourceError = PaintSourceError; exports.normalizeHexColor = normalizeHexColor; exports.hexToPaintRgb = hexToPaintRgb; exports.parsePaintSource = parsePaintSource; exports.readPaintSource = readPaintSource; exports.resolvePaintGradient = resolvePaintGradient; exports.scalePaintGradient = scalePaintGradient; exports.solidPaint = solidPaint; exports.isGradientPaint = isGradientPaint; exports.paintSourceColor = paintSourceColor; exports.paintSourceCss = paintSourceCss; exports.PaintGradientSampler = PaintGradientSampler; exports.PAINT_GRADIENT_JSON_SCHEMA = PAINT_GRADIENT_JSON_SCHEMA; exports.PAINT_COLOR_JSON_SCHEMA = PAINT_COLOR_JSON_SCHEMA; exports.PAINT_SOURCE_JSON_SCHEMA = PAINT_SOURCE_JSON_SCHEMA; exports.PAINT_GRADIENT_MAPPING_LABELS = PAINT_GRADIENT_MAPPING_LABELS; exports.PAINT_GRADIENT_SPACE_LABELS = PAINT_GRADIENT_SPACE_LABELS; exports.PAINT_GRADIENT_REPEAT_LABELS = PAINT_GRADIENT_REPEAT_LABELS; exports.DEFAULT_PAINT_GRADIENT = DEFAULT_PAINT_GRADIENT; exports.PAINT_GRADIENT_PRESETS = PAINT_GRADIENT_PRESETS; exports.addPaintGradientStop = addPaintGradientStop; exports.removePaintGradientStop = removePaintGradientStop; exports.updatePaintGradientStop = updatePaintGradientStop; exports.reversePaintGradient = reversePaintGradient; exports.paintGradientMappingFor = paintGradientMappingFor; exports.PAINT_GRADIENT_KIT = PAINT_GRADIENT_KIT; exports.DEFAULT_BRUSH = DEFAULT_BRUSH; exports.MAX_BRUSH_SIZE = MAX_BRUSH_SIZE; exports.normalizeBrush = normalizeBrush; exports.tipShape = tipShape; exports.tipFalloff = tipFalloff; exports.tipReach = tipReach; exports.dabCoverage = dabCoverage; exports.smoothPoints = smoothPoints; exports.DabWalker = DabWalker; exports.walkDabs = walkDabs; exports.dabRect = dabRect; exports.rasterizeDab = rasterizeDab; exports.CoverageMap = CoverageMap; exports.StrokeCoverage = StrokeCoverage; exports.TIP_GRADIENT_STEPS = TIP_GRADIENT_STEPS; exports.gradientDabColor = gradientDabColor; exports.applyStrokeToTile = applyStrokeToTile; exports.applyStrokeToDeepTile = applyStrokeToDeepTile; exports.coverageTileCoord = coverageTileCoord; exports.GRAIN_PATTERNS = GRAIN_PATTERNS; exports.GRAIN_TILE = GRAIN_TILE; exports.grainHeights = grainHeights; exports.PaperGrain = PaperGrain; exports.grainCatch = grainCatch; exports.strokeGrainCatch = strokeGrainCatch; exports.MIXING_MODELS = MIXING_MODELS; exports.EMPTY_MIXER_LOAD = EMPTY_MIXER_LOAD; exports.MIXER_PICKUP_RATE = MIXER_PICKUP_RATE; exports.MIXER_DRAIN = MIXER_DRAIN; exports.exchangeRates = exchangeRates; exports.PaintExchange = PaintExchange; exports.put255 = put255; exports.TileMedium = TileMedium; exports.DEFAULT_BLENDER = DEFAULT_BLENDER; exports.DEFAULT_SMUDGE = DEFAULT_SMUDGE; exports.normalizeBlender = normalizeBlender; exports.normalizeSmudge = normalizeSmudge; exports.blendRadius = blendRadius; exports.createBlenderScratch = createBlenderScratch; exports.blenderDab = blenderDab; exports.SmudgeTip = SmudgeTip; exports.DEFAULT_MIXER = DEFAULT_MIXER; exports.normalizeMixer = normalizeMixer; exports.mixerRates = mixerRates; exports.loadMixer = loadMixer; exports.cleanMixer = cleanMixer; exports.MixerStroke = MixerStroke;