@pixerate/editor 0.207.0 → 0.209.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.
Files changed (72) hide show
  1. package/dist/animation-editor/index.cjs +60 -59
  2. package/dist/animation-editor/index.js +6 -5
  3. package/dist/{brushstrokeRender-7LXCU7PD.js → brushstrokeRender-C3UU6GVC.js} +5 -4
  4. package/dist/{brushstrokeRender-VO4ZTWVA.cjs → brushstrokeRender-EAJNE6WP.cjs} +12 -11
  5. package/dist/canvas/index.cjs +8 -8
  6. package/dist/canvas/index.js +1 -1
  7. package/dist/{chunk-2N2QPO3H.js → chunk-2PBZBRP5.js} +9 -7
  8. package/dist/{chunk-7NW46N7I.cjs → chunk-3EHPLDFQ.cjs} +54 -52
  9. package/dist/{chunk-H367YTXI.js → chunk-42TWUPNJ.js} +13 -387
  10. package/dist/chunk-474IQG74.cjs +384 -0
  11. package/dist/{chunk-MLC7HUHO.js → chunk-BGOCAUXH.js} +1 -1
  12. package/dist/chunk-DWYQPL2A.js +2010 -0
  13. package/dist/{chunk-YXKLVD56.js → chunk-F7YA3MMC.js} +2 -2
  14. package/dist/{chunk-ZZGPYNS2.js → chunk-G4E6RUPC.js} +1 -1
  15. package/dist/chunk-HVVR5PZW.js +384 -0
  16. package/dist/{chunk-FR2Q2LVF.cjs → chunk-I7G3RSUJ.cjs} +35 -35
  17. package/dist/chunk-K6PXS6DO.cjs +102 -0
  18. package/dist/{chunk-ZIDUPSP4.js → chunk-KFIOEOCQ.js} +24 -761
  19. package/dist/{chunk-V7GWZIZK.cjs → chunk-KWNMBMKG.cjs} +23 -21
  20. package/dist/chunk-L3G23N5Y.js +763 -0
  21. package/dist/{chunk-GHCXLQ47.js → chunk-NDMXB4PR.js} +2 -2
  22. package/dist/{chunk-CWM3CUUX.cjs → chunk-OLNIPTB3.cjs} +39 -413
  23. package/dist/{chunk-EBDCRTZI.cjs → chunk-PQ3H2AAN.cjs} +92 -90
  24. package/dist/{chunk-BRKVNXDZ.cjs → chunk-QAUIZPYI.cjs} +7 -7
  25. package/dist/{chunk-UYXL6ZWQ.cjs → chunk-QE7D7TZR.cjs} +494 -1231
  26. package/dist/chunk-QYLWG22N.cjs +763 -0
  27. package/dist/{chunk-YQ5C5BVK.cjs → chunk-ROVK6AXX.cjs} +60 -60
  28. package/dist/{chunk-HGTDMKNE.cjs → chunk-UOGKSVRQ.cjs} +126 -221
  29. package/dist/{chunk-EL5PAHNP.js → chunk-USQCKRZG.js} +6 -4
  30. package/dist/{chunk-36OKQDCF.js → chunk-WJ2RBZMM.js} +5 -3
  31. package/dist/chunk-X4LUGTQX.cjs +2010 -0
  32. package/dist/{chunk-NQMP3CWF.js → chunk-YBJXCQTR.js} +15 -110
  33. package/dist/chunk-ZIF4UJJ6.js +102 -0
  34. package/dist/{chunk-WTW7QRTS.cjs → chunk-ZMHPQ6HP.cjs} +1 -1
  35. package/dist/image-editor/controller.d.cts +53 -5
  36. package/dist/image-editor/controller.d.ts +53 -5
  37. package/dist/image-editor/index.cjs +1806 -3356
  38. package/dist/image-editor/index.js +462 -2012
  39. package/dist/image-editor/selection/index.d.cts +1 -0
  40. package/dist/image-editor/selection/index.d.ts +1 -0
  41. package/dist/image-editor/selection/segment/focus.d.cts +2 -0
  42. package/dist/image-editor/selection/segment/focus.d.ts +2 -0
  43. package/dist/image-editor/selection/segment/grabcut.d.cts +4 -2
  44. package/dist/image-editor/selection/segment/grabcut.d.ts +4 -2
  45. package/dist/image-editor/selection/segment/sky.d.cts +2 -0
  46. package/dist/image-editor/selection/segment/sky.d.ts +2 -0
  47. package/dist/image-editor/selection/segment/subject.d.cts +2 -1
  48. package/dist/image-editor/selection/segment/subject.d.ts +2 -1
  49. package/dist/image-editor/selection/segment/work.d.cts +5 -0
  50. package/dist/image-editor/selection/segment/work.d.ts +5 -0
  51. package/dist/image-editor/selection/select-and-mask.d.cts +12 -2
  52. package/dist/image-editor/selection/select-and-mask.d.ts +12 -2
  53. package/dist/image-editor/selection/tool-options.d.cts +3 -1
  54. package/dist/image-editor/selection/tool-options.d.ts +3 -1
  55. package/dist/image-editor/selection/worker.d.cts +126 -0
  56. package/dist/image-editor/selection/worker.d.ts +126 -0
  57. package/dist/image-editor/selection-worker.cjs +14 -0
  58. package/dist/image-editor/selection-worker.d.cts +12 -0
  59. package/dist/image-editor/selection-worker.d.ts +12 -0
  60. package/dist/image-editor/selection-worker.js +14 -0
  61. package/dist/image-editor/types.d.cts +22 -0
  62. package/dist/image-editor/types.d.ts +22 -0
  63. package/dist/paint/index.cjs +6 -5
  64. package/dist/paint/index.js +5 -4
  65. package/dist/paint-editor/index.cjs +394 -390
  66. package/dist/paint-editor/index.js +18 -14
  67. package/dist/raster/index.cjs +22 -18
  68. package/dist/raster/index.js +29 -25
  69. package/dist/vector/index.cjs +986 -985
  70. package/dist/vector/index.js +6 -5
  71. package/package.json +11 -1
  72. package/skills/pixerate-image-editor/SKILL.md +1 -1
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BUILTIN_BRUSHES
3
- } from "./chunk-YXKLVD56.js";
3
+ } from "./chunk-F7YA3MMC.js";
4
4
  import {
5
5
  parseProvenance
6
6
  } from "./chunk-M6DNZNVY.js";
@@ -47,7 +47,7 @@ import {
47
47
  GRAIN_PATTERNS,
48
48
  brushstrokeDataUrl,
49
49
  isBrushstrokeBrush
50
- } from "./chunk-2N2QPO3H.js";
50
+ } from "./chunk-2PBZBRP5.js";
51
51
  import {
52
52
  oklabToRgb,
53
53
  rgbToOklab
@@ -1,4 +1,12 @@
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;
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; }
2
+
3
+
4
+
5
+
6
+
7
+
8
+ var _chunk474IQG74cjs = require('./chunk-474IQG74.cjs');
9
+
2
10
 
3
11
 
4
12
  var _chunkXFM3OCHUcjs = require('./chunk-XFM3OCHU.cjs');
@@ -708,369 +716,10 @@ function blendImageData(backdrop, source, mode, alpha = 1) {
708
716
  }
709
717
  }
710
718
 
711
- // src/raster/surface.ts
712
- var TILE = 256;
713
- var TILE_SHIFT = 8;
714
- var TILE_PIXELS = TILE * TILE;
715
- var KEY_OFFSET = 1 << 15;
716
- var KEY_SPAN = 1 << 16;
717
- function tileKey(tx, ty) {
718
- return (ty + KEY_OFFSET) * KEY_SPAN + (tx + KEY_OFFSET);
719
- }
720
- function tileCoord(key) {
721
- return { tx: key % KEY_SPAN - KEY_OFFSET, ty: Math.floor(key / KEY_SPAN) - KEY_OFFSET };
722
- }
723
- function tileRect(tx, ty) {
724
- return { x: tx * TILE, y: ty * TILE, width: TILE, height: TILE };
725
- }
726
- var nextSurfaceId = 1;
727
- var TiledSurface = (_class = class {
728
- constructor(channels, tiles, defaultValue = 0) {;_class.prototype.__init.call(this);
729
- this.channels = channels;
730
- this.tiles = tiles;
731
- this.defaultValue = defaultValue;
732
- }
733
-
734
-
735
-
736
- /** Unique per instance: a cache key that changes whenever the pixels can have changed. */
737
- __init() {this.id = nextSurfaceId++}
738
-
739
- /** Bounds of the stored (non-default) tiles, tile-aligned; `null` when there are none. */
740
- get bounds() {
741
- if (this.boundsCache === void 0) this.boundsCache = tileUnion(this.tiles.keys());
742
- return this.boundsCache;
743
- }
744
- get tileCount() {
745
- return this.tiles.size;
746
- }
747
- getTile(tx, ty) {
748
- return this.tiles.get(tileKey(tx, ty));
749
- }
750
- }, _class);
751
- function tileUnion(keys) {
752
- let x0 = Infinity;
753
- let y0 = Infinity;
754
- let x1 = -Infinity;
755
- let y1 = -Infinity;
756
- for (const key of keys) {
757
- const { tx, ty } = tileCoord(key);
758
- if (tx < x0) x0 = tx;
759
- if (ty < y0) y0 = ty;
760
- if (tx > x1) x1 = tx;
761
- if (ty > y1) y1 = ty;
762
- }
763
- if (x0 === Infinity) return null;
764
- return { x: x0 * TILE, y: y0 * TILE, width: (x1 - x0 + 1) * TILE, height: (y1 - y0 + 1) * TILE };
765
- }
766
- var uniformTiles = /* @__PURE__ */ new Map();
767
- var UNIFORM_LIMIT = 64;
768
- function packPixel(data, offset, channels) {
769
- return channels === 1 ? data[offset] : (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0;
770
- }
771
- function uniformTile(channels, value) {
772
- const key = `${channels}:${value}`;
773
- let tile = uniformTiles.get(key);
774
- if (tile) return tile;
775
- const data = new Uint8ClampedArray(TILE_PIXELS * channels);
776
- if (channels === 1) data.fill(value);
777
- else if (value !== 0) {
778
- const r = value >>> 24;
779
- const g = value >>> 16 & 255;
780
- const b = value >>> 8 & 255;
781
- const a = value & 255;
782
- for (let i = 0; i < data.length; i += 4) {
783
- data[i] = r;
784
- data[i + 1] = g;
785
- data[i + 2] = b;
786
- data[i + 3] = a;
787
- }
788
- }
789
- tile = { data, uniform: value };
790
- if (uniformTiles.size >= UNIFORM_LIMIT) uniformTiles.delete(uniformTiles.keys().next().value);
791
- uniformTiles.set(key, tile);
792
- return tile;
793
- }
794
- function packRgba(r, g, b, a) {
795
- return (r << 24 | g << 16 | b << 8 | a) >>> 0;
796
- }
797
- function defaultPacked(channels, defaultValue) {
798
- return channels === 1 ? defaultValue : packRgba(defaultValue, defaultValue, defaultValue, defaultValue);
799
- }
800
- function uniformValue(data, channels) {
801
- if (channels === 1) {
802
- const v = data[0];
803
- for (let i = 1; i < data.length; i++) if (data[i] !== v) return null;
804
- return v;
805
- }
806
- const words = new Uint32Array(data.buffer, data.byteOffset, data.length >> 2);
807
- const w = words[0];
808
- for (let i = 1; i < words.length; i++) if (words[i] !== w) return null;
809
- return packPixel(data, 0, 4);
810
- }
811
- function finishTile(data, channels, defaultValue) {
812
- const u = uniformValue(data, channels);
813
- if (u === null) return { data, uniform: null };
814
- if (u === defaultPacked(channels, defaultValue)) return null;
815
- return uniformTile(channels, u);
816
- }
817
- function emptySurface(channels = 4, defaultValue = 0) {
818
- return new TiledSurface(channels, /* @__PURE__ */ new Map(), defaultValue);
819
- }
820
- function solidSurface(channels, rect, value, defaultValue = 0) {
821
- const bytes = new Uint8ClampedArray(channels);
822
- if (channels === 1) bytes[0] = value;
823
- else {
824
- bytes[0] = value >>> 24;
825
- bytes[1] = value >>> 16 & 255;
826
- bytes[2] = value >>> 8 & 255;
827
- bytes[3] = value & 255;
828
- }
829
- return fillRect(emptySurface(channels, defaultValue), rect, bytes);
830
- }
831
- function surfaceFromPixels(pixels, channels = 4, x = 0, y = 0, defaultValue = 0) {
832
- return writeRegion(emptySurface(channels, defaultValue), { x, y, width: pixels.width, height: pixels.height }, pixels.data);
833
- }
834
- function tilesInRect(rect) {
835
- const out = [];
836
- if (rect.width <= 0 || rect.height <= 0) return out;
837
- const tx0 = Math.floor(rect.x / TILE);
838
- const ty0 = Math.floor(rect.y / TILE);
839
- const tx1 = Math.floor((rect.x + rect.width - 1) / TILE);
840
- const ty1 = Math.floor((rect.y + rect.height - 1) / TILE);
841
- for (let ty = ty0; ty <= ty1; ty++) for (let tx = tx0; tx <= tx1; tx++) out.push({ tx, ty });
842
- return out;
843
- }
844
- function readRegion(surface, rect, out) {
845
- const ch = surface.channels;
846
- const w = rect.width;
847
- const h = rect.height;
848
- const dst = _nullishCoalesce(out, () => ( new Uint8ClampedArray(w * h * ch)));
849
- if (surface.defaultValue !== 0) dst.fill(surface.defaultValue);
850
- else if (out) dst.fill(0);
851
- for (const { tx, ty } of tilesInRect(rect)) {
852
- const tile = surface.getTile(tx, ty);
853
- if (!tile) continue;
854
- const ox = tx * TILE;
855
- const oy = ty * TILE;
856
- const x0 = Math.max(rect.x, ox);
857
- const y0 = Math.max(rect.y, oy);
858
- const x1 = Math.min(rect.x + w, ox + TILE);
859
- const y1 = Math.min(rect.y + h, oy + TILE);
860
- const span = (x1 - x0) * ch;
861
- for (let yy = y0; yy < y1; yy++) {
862
- const s = ((yy - oy) * TILE + (x0 - ox)) * ch;
863
- const d = ((yy - rect.y) * w + (x0 - rect.x)) * ch;
864
- dst.set(tile.data.subarray(s, s + span), d);
865
- }
866
- }
867
- return dst;
868
- }
869
- function readPixel(surface, x, y) {
870
- const tile = surface.getTile(Math.floor(x / TILE), Math.floor(y / TILE));
871
- const ch = surface.channels;
872
- if (!tile) return new Array(ch).fill(surface.defaultValue);
873
- const i = ((y & TILE - 1) * TILE + (x & TILE - 1)) * ch;
874
- return Array.from(tile.data.subarray(i, i + ch));
875
- }
876
- function contentBounds(surface) {
877
- const ch = surface.channels;
878
- const def = surface.defaultValue;
879
- let x0 = Infinity;
880
- let y0 = Infinity;
881
- let x1 = -Infinity;
882
- let y1 = -Infinity;
883
- for (const [key, tile] of surface.tiles) {
884
- const { tx, ty } = tileCoord(key);
885
- const ox = tx * TILE;
886
- const oy = ty * TILE;
887
- if (tile.uniform !== null) {
888
- if (ox < x0) x0 = ox;
889
- if (oy < y0) y0 = oy;
890
- if (ox + TILE - 1 > x1) x1 = ox + TILE - 1;
891
- if (oy + TILE - 1 > y1) y1 = oy + TILE - 1;
892
- continue;
893
- }
894
- const d = tile.data;
895
- for (let y = 0; y < TILE; y++) {
896
- let first = -1;
897
- let last = -1;
898
- const row = y * TILE * ch;
899
- for (let x = 0; x < TILE; x++) {
900
- const i = row + x * ch;
901
- let differs = false;
902
- for (let c = 0; c < ch; c++) if (d[i + c] !== def) differs = true;
903
- if (differs) {
904
- if (first < 0) first = x;
905
- last = x;
906
- }
907
- }
908
- if (first < 0) continue;
909
- if (ox + first < x0) x0 = ox + first;
910
- if (ox + last > x1) x1 = ox + last;
911
- if (oy + y < y0) y0 = oy + y;
912
- if (oy + y > y1) y1 = oy + y;
913
- }
914
- }
915
- if (x0 === Infinity) return null;
916
- return { x: x0, y: y0, width: x1 - x0 + 1, height: y1 - y0 + 1 };
917
- }
918
- var SurfaceDraft = (_class2 = class {
919
- constructor(base) {;_class2.prototype.__init2.call(this);
920
- this.base = base;
921
- }
922
-
923
- __init2() {this.copies = /* @__PURE__ */ new Map()}
924
- get channels() {
925
- return this.base.channels;
926
- }
927
- /** The writable data of tile (tx, ty), copied from the base on first use. */
928
- tile(tx, ty) {
929
- const key = tileKey(tx, ty);
930
- let data = this.copies.get(key);
931
- if (data) return data;
932
- const src = this.base.tiles.get(key);
933
- if (src) data = new Uint8ClampedArray(src.data);
934
- else {
935
- data = new Uint8ClampedArray(TILE_PIXELS * this.base.channels);
936
- if (this.base.defaultValue !== 0) data.fill(this.base.defaultValue);
937
- }
938
- this.copies.set(key, data);
939
- return data;
940
- }
941
- /** Replaces a whole tile with `data` (owned by the draft from now on). */
942
- replace(tx, ty, data) {
943
- this.copies.set(tileKey(tx, ty), data);
944
- }
945
- /** The current data of a tile without copying it (base tile, draft copy or `null` for default). */
946
- peek(tx, ty) {
947
- const key = tileKey(tx, ty);
948
- return _nullishCoalesce(_nullishCoalesce(this.copies.get(key), () => ( _optionalChain([this, 'access', _11 => _11.base, 'access', _12 => _12.tiles, 'access', _13 => _13.get, 'call', _14 => _14(key), 'optionalAccess', _15 => _15.data]))), () => ( null));
949
- }
950
- /** Keys of the tiles changed so far. */
951
- get touched() {
952
- return [...this.copies.keys()];
953
- }
954
- /** A new surface with the draft's tiles; the draft must not be used afterwards. */
955
- commit() {
956
- if (!this.copies.size) return this.base;
957
- const tiles = new Map(this.base.tiles);
958
- const { channels, defaultValue } = this.base;
959
- for (const [key, data] of this.copies) {
960
- const tile = finishTile(data, channels, defaultValue);
961
- if (tile) tiles.set(key, tile);
962
- else tiles.delete(key);
963
- }
964
- return new TiledSurface(channels, tiles, defaultValue);
965
- }
966
- }, _class2);
967
- function writeRegion(surface, rect, data) {
968
- const ch = surface.channels;
969
- const w = rect.width;
970
- const h = rect.height;
971
- if (w <= 0 || h <= 0) return surface;
972
- if (data.length < w * h * ch) throw new Error(`writeRegion: expected ${w * h * ch} bytes, got ${data.length}`);
973
- const draft = new SurfaceDraft(surface);
974
- const src = data;
975
- const canSubarray = typeof src.subarray === "function";
976
- for (const { tx, ty } of tilesInRect(rect)) {
977
- const ox = tx * TILE;
978
- const oy = ty * TILE;
979
- const x0 = Math.max(rect.x, ox);
980
- const y0 = Math.max(rect.y, oy);
981
- const x1 = Math.min(rect.x + w, ox + TILE);
982
- const y1 = Math.min(rect.y + h, oy + TILE);
983
- const full = x0 === ox && y0 === oy && x1 === ox + TILE && y1 === oy + TILE;
984
- const t = full ? new Uint8ClampedArray(TILE_PIXELS * ch) : draft.tile(tx, ty);
985
- const span = (x1 - x0) * ch;
986
- for (let yy = y0; yy < y1; yy++) {
987
- const s = ((yy - rect.y) * w + (x0 - rect.x)) * ch;
988
- const d = ((yy - oy) * TILE + (x0 - ox)) * ch;
989
- if (canSubarray) t.set(src.subarray(s, s + span), d);
990
- else for (let k = 0; k < span; k++) t[d + k] = src[s + k];
991
- }
992
- if (full) draft.replace(tx, ty, t);
993
- }
994
- return draft.commit();
995
- }
996
- function fillRect(surface, rect, bytes) {
997
- const ch = surface.channels;
998
- if (rect.width <= 0 || rect.height <= 0) return surface;
999
- const tiles = new Map(surface.tiles);
1000
- const draft = new SurfaceDraft(surface);
1001
- const value = packPixel(bytes, 0, ch);
1002
- const isDefault = value === defaultPacked(ch, surface.defaultValue);
1003
- for (const { tx, ty } of tilesInRect(rect)) {
1004
- const ox = tx * TILE;
1005
- const oy = ty * TILE;
1006
- const x0 = Math.max(rect.x, ox);
1007
- const y0 = Math.max(rect.y, oy);
1008
- const x1 = Math.min(rect.x + rect.width, ox + TILE);
1009
- const y1 = Math.min(rect.y + rect.height, oy + TILE);
1010
- const key = tileKey(tx, ty);
1011
- if (x0 === ox && y0 === oy && x1 === ox + TILE && y1 === oy + TILE) {
1012
- if (isDefault) tiles.delete(key);
1013
- else tiles.set(key, uniformTile(ch, value));
1014
- continue;
1015
- }
1016
- const t = draft.tile(tx, ty);
1017
- for (let yy = y0; yy < y1; yy++) {
1018
- let d = ((yy - oy) * TILE + (x0 - ox)) * ch;
1019
- for (let xx = x0; xx < x1; xx++, d += ch) for (let c = 0; c < ch; c++) t[d + c] = bytes[c];
1020
- }
1021
- const tile = finishTile(t, ch, surface.defaultValue);
1022
- if (tile) tiles.set(key, tile);
1023
- else tiles.delete(key);
1024
- }
1025
- return new TiledSurface(ch, tiles, surface.defaultValue);
1026
- }
1027
- function translateSurface(surface, dx, dy) {
1028
- dx = Math.round(dx);
1029
- dy = Math.round(dy);
1030
- if (!dx && !dy) return surface;
1031
- if (dx % TILE === 0 && dy % TILE === 0) {
1032
- const tiles = /* @__PURE__ */ new Map();
1033
- for (const [key, tile] of surface.tiles) {
1034
- const { tx, ty } = tileCoord(key);
1035
- tiles.set(tileKey(tx + dx / TILE, ty + dy / TILE), tile);
1036
- }
1037
- return new TiledSurface(surface.channels, tiles, surface.defaultValue);
1038
- }
1039
- const b = surface.bounds;
1040
- if (!b) return surface;
1041
- const data = readRegion(surface, b);
1042
- return writeRegion(emptySurface(surface.channels, surface.defaultValue), { ...b, x: b.x + dx, y: b.y + dy }, data);
1043
- }
1044
- function surfaceBytes(surface) {
1045
- let n = 0;
1046
- for (const tile of surface.tiles.values()) if (tile.uniform === null) n += tile.data.byteLength;
1047
- return n;
1048
- }
1049
- function collectTiles(surface, into) {
1050
- for (const tile of surface.tiles.values()) if (tile.uniform === null) into.add(tile);
1051
- }
1052
- function surfacesEqual(a, b) {
1053
- if (a === b) return true;
1054
- if (a.channels !== b.channels || a.defaultValue !== b.defaultValue || a.tiles.size !== b.tiles.size) return false;
1055
- for (const [key, ta] of a.tiles) {
1056
- const tb = b.tiles.get(key);
1057
- if (!tb) return false;
1058
- if (ta === tb) continue;
1059
- if (ta.uniform !== null || tb.uniform !== null) {
1060
- if (ta.uniform !== tb.uniform) return false;
1061
- continue;
1062
- }
1063
- const x = ta.data;
1064
- const y = tb.data;
1065
- for (let i = 0; i < x.length; i++) if (x[i] !== y[i]) return false;
1066
- }
1067
- return true;
1068
- }
1069
-
1070
719
  // src/raster/deep.ts
1071
720
  var BIT_DEPTHS = [8, 16, 32];
1072
721
  var isBitDepth = (v) => v === 8 || v === 16 || v === 32;
1073
- var TILE_PIXELS2 = TILE * TILE;
722
+ var TILE_PIXELS = _chunk474IQG74cjs.TILE * _chunk474IQG74cjs.TILE;
1074
723
  function srgbDecode(v) {
1075
724
  return v <= 0.04045 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4);
1076
725
  }
@@ -1186,7 +835,7 @@ function deepTile(deep, channels, defaultValue = 0) {
1186
835
  break;
1187
836
  }
1188
837
  }
1189
- if (exact) return finishTile(data, channels, defaultValue);
838
+ if (exact) return _chunk474IQG74cjs.finishTile.call(void 0, data, channels, defaultValue);
1190
839
  } else if (channels === 4 && defaultValue === 0) {
1191
840
  let empty = true;
1192
841
  for (let i = 3; i < deep.length; i += 4) {
@@ -1200,21 +849,21 @@ function deepTile(deep, channels, defaultValue = 0) {
1200
849
  return { data, uniform: null, deep };
1201
850
  }
1202
851
  function tileSamples16(tile, channels, defaultValue = 0) {
1203
- const deep = _optionalChain([tile, 'optionalAccess', _16 => _16.deep]);
852
+ const deep = _optionalChain([tile, 'optionalAccess', _11 => _11.deep]);
1204
853
  if (deep instanceof Uint16Array) return deep;
1205
854
  if (deep instanceof Float32Array) return to16From32(deep, channels);
1206
855
  if (tile) return to16From8(tile.data);
1207
- return new Uint16Array(TILE_PIXELS2 * channels).fill(defaultValue * 257);
856
+ return new Uint16Array(TILE_PIXELS * channels).fill(defaultValue * 257);
1208
857
  }
1209
858
  function tileSamples32(tile, channels, defaultValue = 0) {
1210
- const deep = _optionalChain([tile, 'optionalAccess', _17 => _17.deep]);
859
+ const deep = _optionalChain([tile, 'optionalAccess', _12 => _12.deep]);
1211
860
  if (deep instanceof Float32Array) return deep;
1212
861
  if (deep instanceof Uint16Array) return to32From16(deep, channels);
1213
862
  if (tile) return to32From8(tile.data, channels);
1214
- const out = new Float32Array(TILE_PIXELS2 * channels);
863
+ const out = new Float32Array(TILE_PIXELS * channels);
1215
864
  if (defaultValue) {
1216
865
  if (channels === 1) out.fill(defaultValue / 255);
1217
- else to32From8(new Uint8ClampedArray(TILE_PIXELS2 * 4).fill(defaultValue), 4, out);
866
+ else to32From8(new Uint8ClampedArray(TILE_PIXELS * 4).fill(defaultValue), 4, out);
1218
867
  }
1219
868
  return out;
1220
869
  }
@@ -1236,19 +885,19 @@ function readDeepRegion(surface, rect, depth) {
1236
885
  const out = depth === 16 ? new Uint16Array(w * h * ch) : new Float32Array(w * h * ch);
1237
886
  const fill = tileSamples(void 0, ch, depth, surface.defaultValue);
1238
887
  if (surface.defaultValue) for (let i = 0; i < out.length; i += ch) for (let c = 0; c < ch; c++) out[i + c] = fill[c];
1239
- for (const { tx, ty } of tilesInRect(rect)) {
1240
- const tile = surface.tiles.get(tileKey(tx, ty));
888
+ for (const { tx, ty } of _chunk474IQG74cjs.tilesInRect.call(void 0, rect)) {
889
+ const tile = surface.tiles.get(_chunk474IQG74cjs.tileKey.call(void 0, tx, ty));
1241
890
  if (!tile) continue;
1242
891
  const src = tileSamples(tile, ch, depth, surface.defaultValue);
1243
- const ox = tx * TILE;
1244
- const oy = ty * TILE;
892
+ const ox = tx * _chunk474IQG74cjs.TILE;
893
+ const oy = ty * _chunk474IQG74cjs.TILE;
1245
894
  const x0 = Math.max(rect.x, ox);
1246
895
  const y0 = Math.max(rect.y, oy);
1247
- const x1 = Math.min(rect.x + w, ox + TILE);
1248
- const y1 = Math.min(rect.y + h, oy + TILE);
896
+ const x1 = Math.min(rect.x + w, ox + _chunk474IQG74cjs.TILE);
897
+ const y1 = Math.min(rect.y + h, oy + _chunk474IQG74cjs.TILE);
1249
898
  const span = (x1 - x0) * ch;
1250
899
  for (let yy = y0; yy < y1; yy++) {
1251
- const s = ((yy - oy) * TILE + (x0 - ox)) * ch;
900
+ const s = ((yy - oy) * _chunk474IQG74cjs.TILE + (x0 - ox)) * ch;
1252
901
  const d = ((yy - rect.y) * w + (x0 - rect.x)) * ch;
1253
902
  out.set(src.subarray(s, s + span), d);
1254
903
  }
@@ -1263,31 +912,31 @@ function writeDeepRegion(surface, rect, samples) {
1263
912
  if (samples.length < w * h * ch) throw new Error(`writeDeepRegion: expected ${w * h * ch} samples, got ${samples.length}`);
1264
913
  const depth = depthOf(samples);
1265
914
  const tiles = new Map(surface.tiles);
1266
- for (const { tx, ty } of tilesInRect(rect)) {
1267
- const key = tileKey(tx, ty);
1268
- const ox = tx * TILE;
1269
- const oy = ty * TILE;
915
+ for (const { tx, ty } of _chunk474IQG74cjs.tilesInRect.call(void 0, rect)) {
916
+ const key = _chunk474IQG74cjs.tileKey.call(void 0, tx, ty);
917
+ const ox = tx * _chunk474IQG74cjs.TILE;
918
+ const oy = ty * _chunk474IQG74cjs.TILE;
1270
919
  const x0 = Math.max(rect.x, ox);
1271
920
  const y0 = Math.max(rect.y, oy);
1272
- const x1 = Math.min(rect.x + w, ox + TILE);
1273
- const y1 = Math.min(rect.y + h, oy + TILE);
1274
- const full = x0 === ox && y0 === oy && x1 === ox + TILE && y1 === oy + TILE;
921
+ const x1 = Math.min(rect.x + w, ox + _chunk474IQG74cjs.TILE);
922
+ const y1 = Math.min(rect.y + h, oy + _chunk474IQG74cjs.TILE);
923
+ const full = x0 === ox && y0 === oy && x1 === ox + _chunk474IQG74cjs.TILE && y1 === oy + _chunk474IQG74cjs.TILE;
1275
924
  const base = full ? null : tileSamples(surface.tiles.get(key), ch, depth, surface.defaultValue);
1276
- const t = base ? base.slice() : depth === 16 ? new Uint16Array(TILE_PIXELS2 * ch) : new Float32Array(TILE_PIXELS2 * ch);
925
+ const t = base ? base.slice() : depth === 16 ? new Uint16Array(TILE_PIXELS * ch) : new Float32Array(TILE_PIXELS * ch);
1277
926
  const span = (x1 - x0) * ch;
1278
927
  for (let yy = y0; yy < y1; yy++) {
1279
928
  const s = ((yy - rect.y) * w + (x0 - rect.x)) * ch;
1280
- const d = ((yy - oy) * TILE + (x0 - ox)) * ch;
929
+ const d = ((yy - oy) * _chunk474IQG74cjs.TILE + (x0 - ox)) * ch;
1281
930
  t.set(samples.subarray(s, s + span), d);
1282
931
  }
1283
932
  const tile = deepTile(t, ch, surface.defaultValue);
1284
933
  if (tile) tiles.set(key, tile);
1285
934
  else tiles.delete(key);
1286
935
  }
1287
- return new TiledSurface(ch, tiles, surface.defaultValue);
936
+ return new (0, _chunk474IQG74cjs.TiledSurface)(ch, tiles, surface.defaultValue);
1288
937
  }
1289
938
  function surfaceFromDeepPixels(pixels, channels = 4, x = 0, y = 0, defaultValue = 0) {
1290
- return writeDeepRegion(emptySurface(channels, defaultValue), { x, y, width: pixels.width, height: pixels.height }, pixels.data);
939
+ return writeDeepRegion(_chunk474IQG74cjs.emptySurface.call(void 0, channels, defaultValue), { x, y, width: pixels.width, height: pixels.height }, pixels.data);
1291
940
  }
1292
941
  function convertSurfaceDepth(surface, depth) {
1293
942
  let changed = false;
@@ -1298,12 +947,12 @@ function convertSurfaceDepth(surface, depth) {
1298
947
  if (!deep || depthOf(deep) === depth) continue;
1299
948
  changed = true;
1300
949
  let next;
1301
- if (depth === 8) next = finishTile(tile.data, ch, surface.defaultValue);
950
+ if (depth === 8) next = _chunk474IQG74cjs.finishTile.call(void 0, tile.data, ch, surface.defaultValue);
1302
951
  else next = deepTile(depth === 16 ? to16From32(deep, ch) : to32From16(deep, ch), ch, surface.defaultValue);
1303
952
  if (next) tiles.set(key, next);
1304
953
  else tiles.delete(key);
1305
954
  }
1306
- return changed ? new TiledSurface(ch, tiles, surface.defaultValue) : surface;
955
+ return changed ? new (0, _chunk474IQG74cjs.TiledSurface)(ch, tiles, surface.defaultValue) : surface;
1307
956
  }
1308
957
  function deepBytes(surface) {
1309
958
  let n = 0;
@@ -1319,7 +968,7 @@ function keepDeepSamples(before, after) {
1319
968
  for (const [key, ta] of after.tiles) {
1320
969
  if (ta.deep) continue;
1321
970
  const tb = before.tiles.get(key);
1322
- if (!_optionalChain([tb, 'optionalAccess', _18 => _18.deep]) || tb === ta) continue;
971
+ if (!_optionalChain([tb, 'optionalAccess', _13 => _13.deep]) || tb === ta) continue;
1323
972
  const out = tileSamples(ta, ch, depth, after.defaultValue);
1324
973
  const a = ta.data;
1325
974
  const b = tb.data;
@@ -1338,7 +987,7 @@ function keepDeepSamples(before, after) {
1338
987
  if (tile) tiles.set(key, tile);
1339
988
  else tiles.delete(key);
1340
989
  }
1341
- return tiles ? new TiledSurface(ch, tiles, after.defaultValue) : after;
990
+ return tiles ? new (0, _chunk474IQG74cjs.TiledSurface)(ch, tiles, after.defaultValue) : after;
1342
991
  }
1343
992
 
1344
993
  // src/raster/png.ts
@@ -1709,27 +1358,4 @@ function pngDataUrl(width, height, data, channels = 4) {
1709
1358
 
1710
1359
 
1711
1360
 
1712
-
1713
-
1714
-
1715
-
1716
-
1717
-
1718
-
1719
-
1720
-
1721
-
1722
-
1723
-
1724
-
1725
-
1726
-
1727
-
1728
-
1729
-
1730
-
1731
-
1732
-
1733
-
1734
-
1735
- exports.PIGMENT_BANDS = PIGMENT_BANDS; exports.PIGMENT_LAMBDA_MIN = PIGMENT_LAMBDA_MIN; exports.PIGMENT_LAMBDA_STEP = PIGMENT_LAMBDA_STEP; exports.PIGMENT_WAVELENGTHS = PIGMENT_WAVELENGTHS; exports.rgbToReflectance = rgbToReflectance; exports.reflectanceToRgb = reflectanceToRgb; exports.createPigment = createPigment; exports.setPigmentColor = setPigmentColor; exports.mixPigments = mixPigments; exports.lerpPigment = lerpPigment; exports.lerpPigmentInto = lerpPigmentInto; exports.BLEND_MODES = BLEND_MODES; exports.isBlendMode = isBlendMode; exports.PAINTERLY_BLEND_MODES = PAINTERLY_BLEND_MODES; exports.isPainterlyBlendMode = isPainterlyBlendMode; exports.standardBlendMode = standardBlendMode; exports.normalizeBlendMode = normalizeBlendMode; exports.canvasCompositeOperation = canvasCompositeOperation; exports.isSeparableBlendMode = isSeparableBlendMode; exports.blendChannel = blendChannel; exports.blendLum = blendLum; exports.setLum = setLum; exports.blendRgb = blendRgb; exports.SHADOW_AMBIENT = SHADOW_AMBIENT; exports.mixPigmentRgb = mixPigmentRgb; exports.pigment8 = pigment8; exports.mixPigment8 = mixPigment8; exports.blendPixel = blendPixel; exports.blendImageData = blendImageData; exports.TILE = TILE; exports.TILE_SHIFT = TILE_SHIFT; exports.tileKey = tileKey; exports.tileCoord = tileCoord; exports.tileRect = tileRect; exports.TiledSurface = TiledSurface; exports.uniformTile = uniformTile; exports.packRgba = packRgba; exports.finishTile = finishTile; exports.emptySurface = emptySurface; exports.solidSurface = solidSurface; exports.surfaceFromPixels = surfaceFromPixels; exports.tilesInRect = tilesInRect; exports.readRegion = readRegion; exports.readPixel = readPixel; exports.contentBounds = contentBounds; exports.SurfaceDraft = SurfaceDraft; exports.writeRegion = writeRegion; exports.fillRect = fillRect; exports.translateSurface = translateSurface; exports.surfaceBytes = surfaceBytes; exports.collectTiles = collectTiles; exports.surfacesEqual = surfacesEqual; exports.BIT_DEPTHS = BIT_DEPTHS; exports.isBitDepth = isBitDepth; exports.srgbDecode = srgbDecode; exports.srgbEncode = srgbEncode; exports.to16From8 = to16From8; exports.to32From8 = to32From8; exports.to32From16 = to32From16; exports.to16From32 = to16From32; exports.to8From16 = to8From16; exports.to8From32 = to8From32; exports.proxyOf = proxyOf; exports.depthOf = depthOf; exports.deepTile = deepTile; exports.tileSamples16 = tileSamples16; exports.tileSamples32 = tileSamples32; exports.tileSamples = tileSamples; exports.surfaceDepth = surfaceDepth; exports.readDeepRegion = readDeepRegion; exports.writeDeepRegion = writeDeepRegion; exports.surfaceFromDeepPixels = surfaceFromDeepPixels; exports.convertSurfaceDepth = convertSurfaceDepth; exports.deepBytes = deepBytes; exports.keepDeepSamples = keepDeepSamples; exports.encodePng = encodePng; exports.isPng = isPng; exports.decodePng = decodePng; exports.bytesToBase64 = bytesToBase64; exports.base64ToBytes = base64ToBytes; exports.parseDataUrl = parseDataUrl; exports.pngDataUrl = pngDataUrl;
1361
+ exports.PIGMENT_BANDS = PIGMENT_BANDS; exports.PIGMENT_LAMBDA_MIN = PIGMENT_LAMBDA_MIN; exports.PIGMENT_LAMBDA_STEP = PIGMENT_LAMBDA_STEP; exports.PIGMENT_WAVELENGTHS = PIGMENT_WAVELENGTHS; exports.rgbToReflectance = rgbToReflectance; exports.reflectanceToRgb = reflectanceToRgb; exports.createPigment = createPigment; exports.setPigmentColor = setPigmentColor; exports.mixPigments = mixPigments; exports.lerpPigment = lerpPigment; exports.lerpPigmentInto = lerpPigmentInto; exports.BLEND_MODES = BLEND_MODES; exports.isBlendMode = isBlendMode; exports.PAINTERLY_BLEND_MODES = PAINTERLY_BLEND_MODES; exports.isPainterlyBlendMode = isPainterlyBlendMode; exports.standardBlendMode = standardBlendMode; exports.normalizeBlendMode = normalizeBlendMode; exports.canvasCompositeOperation = canvasCompositeOperation; exports.isSeparableBlendMode = isSeparableBlendMode; exports.blendChannel = blendChannel; exports.blendLum = blendLum; exports.setLum = setLum; exports.blendRgb = blendRgb; exports.SHADOW_AMBIENT = SHADOW_AMBIENT; exports.mixPigmentRgb = mixPigmentRgb; exports.pigment8 = pigment8; exports.mixPigment8 = mixPigment8; exports.blendPixel = blendPixel; exports.blendImageData = blendImageData; exports.BIT_DEPTHS = BIT_DEPTHS; exports.isBitDepth = isBitDepth; exports.srgbDecode = srgbDecode; exports.srgbEncode = srgbEncode; exports.to16From8 = to16From8; exports.to32From8 = to32From8; exports.to32From16 = to32From16; exports.to16From32 = to16From32; exports.to8From16 = to8From16; exports.to8From32 = to8From32; exports.proxyOf = proxyOf; exports.depthOf = depthOf; exports.deepTile = deepTile; exports.tileSamples16 = tileSamples16; exports.tileSamples32 = tileSamples32; exports.tileSamples = tileSamples; exports.surfaceDepth = surfaceDepth; exports.readDeepRegion = readDeepRegion; exports.writeDeepRegion = writeDeepRegion; exports.surfaceFromDeepPixels = surfaceFromDeepPixels; exports.convertSurfaceDepth = convertSurfaceDepth; exports.deepBytes = deepBytes; exports.keepDeepSamples = keepDeepSamples; exports.encodePng = encodePng; exports.isPng = isPng; exports.decodePng = decodePng; exports.bytesToBase64 = bytesToBase64; exports.base64ToBytes = base64ToBytes; exports.parseDataUrl = parseDataUrl; exports.pngDataUrl = pngDataUrl;