@pixerate/editor 0.136.0 → 0.137.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 +60 -55
- package/dist/animation-editor/index.cjs.map +1 -1
- package/dist/animation-editor/index.d.cts +4 -4
- package/dist/animation-editor/index.d.ts +4 -4
- package/dist/animation-editor/index.js +7 -2
- package/dist/animation-editor/index.js.map +1 -1
- package/dist/{bezier-CdccFsF8.d.cts → bezier-CZ2AhjID.d.cts} +1 -1
- package/dist/{bezier-DG9qNZQV.d.ts → bezier-Dywv3Bw8.d.ts} +1 -1
- package/dist/blending-D7jCmjO6.d.cts +1026 -0
- package/dist/blending-NgF3qo3d.d.ts +1026 -0
- package/dist/brushes-CnvZSYYU.d.cts +744 -0
- package/dist/brushes-DJmUbIgz.d.ts +744 -0
- package/dist/{brushstrokeRender-SII6MG4R.js → brushstrokeRender-2FAXA3XC.js} +13 -16
- package/dist/{brushstrokeRender-SII6MG4R.js.map → brushstrokeRender-2FAXA3XC.js.map} +1 -1
- package/dist/{brushstrokeRender-JNHVEUFG.cjs → brushstrokeRender-IMFY3FF6.cjs} +16 -19
- package/dist/brushstrokeRender-IMFY3FF6.cjs.map +1 -0
- package/dist/canvas/index.cjs +10 -10
- package/dist/canvas/index.cjs.map +1 -1
- package/dist/canvas/index.d.cts +7 -7
- package/dist/canvas/index.d.ts +7 -7
- package/dist/canvas/index.js +4 -4
- package/dist/{chunk-W4LNKTHT.cjs → chunk-2XS6LTUP.cjs} +63 -63
- package/dist/{chunk-W4LNKTHT.cjs.map → chunk-2XS6LTUP.cjs.map} +1 -1
- package/dist/{chunk-MAHQC3SK.js → chunk-3D77LOBM.js} +222 -135
- package/dist/chunk-3D77LOBM.js.map +1 -0
- package/dist/{chunk-BR7EKQUP.js → chunk-3G6J7UFV.js} +322 -2
- package/dist/chunk-3G6J7UFV.js.map +1 -0
- package/dist/{chunk-62XUO5LB.js → chunk-3X6IAJUQ.js} +2 -2
- package/dist/{chunk-EM3FMJWE.js → chunk-5FSRTP6E.js} +320 -3
- package/dist/chunk-5FSRTP6E.js.map +1 -0
- package/dist/{chunk-2R3UW57U.cjs → chunk-5OOIUXNJ.cjs} +333 -246
- package/dist/chunk-5OOIUXNJ.cjs.map +1 -0
- package/dist/{chunk-KZXLZCQ7.js → chunk-6S6362D2.js} +2 -2
- package/dist/{chunk-24ATT2PE.cjs → chunk-AEAAN4AD.cjs} +120 -120
- package/dist/{chunk-24ATT2PE.cjs.map → chunk-AEAAN4AD.cjs.map} +1 -1
- package/dist/{chunk-SVYE5HIM.js → chunk-EQQMGO42.js} +2 -2
- package/dist/{chunk-FHPVDTI2.cjs → chunk-F2Y4E4GU.cjs} +22 -22
- package/dist/{chunk-FHPVDTI2.cjs.map → chunk-F2Y4E4GU.cjs.map} +1 -1
- package/dist/{chunk-UYQUPUR6.js → chunk-HUO3TI4C.js} +3 -3
- package/dist/{chunk-DDSO4HS7.cjs → chunk-KEENUAFN.cjs} +2 -2
- package/dist/{chunk-DDSO4HS7.cjs.map → chunk-KEENUAFN.cjs.map} +1 -1
- package/dist/{chunk-2HC4DRF4.js → chunk-LLFHCSU2.js} +2 -2
- package/dist/{chunk-J5BA3BQ6.cjs → chunk-O7LUD7MH.cjs} +323 -3
- package/dist/chunk-O7LUD7MH.cjs.map +1 -0
- package/dist/{chunk-ILYFOJUN.js → chunk-OIBIRXRG.js} +3 -3
- package/dist/{chunk-B2CUCM7Y.cjs → chunk-PRSRYHQD.cjs} +36 -36
- package/dist/{chunk-B2CUCM7Y.cjs.map → chunk-PRSRYHQD.cjs.map} +1 -1
- package/dist/{chunk-6GFRKLLS.cjs → chunk-QBWEH3IM.cjs} +429 -112
- package/dist/chunk-QBWEH3IM.cjs.map +1 -0
- package/dist/{chunk-6QQR4LKE.js → chunk-SYT2TLQF.js} +35 -37
- package/dist/{chunk-6QQR4LKE.js.map → chunk-SYT2TLQF.js.map} +1 -1
- package/dist/{chunk-YT3JL7YM.cjs → chunk-TLCTTQFF.cjs} +53 -53
- package/dist/{chunk-YT3JL7YM.cjs.map → chunk-TLCTTQFF.cjs.map} +1 -1
- package/dist/{chunk-JLGNZMUV.cjs → chunk-XN2NBLV5.cjs} +313 -315
- package/dist/chunk-XN2NBLV5.cjs.map +1 -0
- package/dist/effects/index.d.cts +4 -4
- package/dist/effects/index.d.ts +4 -4
- package/dist/{export-Ds7zgGD8.d.ts → export-41rL6Cne.d.ts} +1 -1
- package/dist/{export-BOheWw2R.d.cts → export-CyJdfP_Z.d.cts} +5 -4
- package/dist/{export-CEYeRQXH.d.cts → export-D9mXp05Q.d.cts} +1 -1
- package/dist/{export-ByKKIA2S.d.ts → export-DwnZ_hvQ.d.ts} +5 -4
- package/dist/{helpers--ns3W2D7.d.ts → helpers-C-RgeyvH.d.ts} +18 -7
- package/dist/{helpers-BVkU4oUi.d.cts → helpers-v6GMazzg.d.cts} +18 -7
- package/dist/image-editor/index.cjs +984 -987
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +12 -11
- package/dist/image-editor/index.d.ts +12 -11
- package/dist/image-editor/index.js +92 -95
- package/dist/image-editor/index.js.map +1 -1
- package/dist/{opentype-yi-Kz4ND.d.cts → opentype-KR_jj6b_.d.cts} +1 -1
- package/dist/{opentype-DfoVYgmG.d.ts → opentype-a1KAW-qs.d.ts} +1 -1
- package/dist/paint/index.cjs +5 -8
- package/dist/paint/index.cjs.map +1 -1
- package/dist/paint/index.d.cts +4 -2
- package/dist/paint/index.d.ts +4 -2
- package/dist/paint/index.js +15 -18
- package/dist/paint-editor/index.cjs +403 -404
- package/dist/paint-editor/index.cjs.map +1 -1
- package/dist/paint-editor/index.d.cts +12 -748
- package/dist/paint-editor/index.d.ts +12 -748
- package/dist/paint-editor/index.js +77 -78
- package/dist/paint-editor/index.js.map +1 -1
- package/dist/{pathfinder-7JkMwYvC.d.cts → pathfinder-BHS4vQNm.d.cts} +1 -1
- package/dist/{pathfinder-GM3UWdBZ.d.ts → pathfinder-BVvTIBMo.d.ts} +1 -1
- package/dist/{pool-CkTxlLMC.d.ts → pool-CZQOrSXZ.d.ts} +1 -1
- package/dist/{pool-04qp8iW4.d.cts → pool-FjZZmZ80.d.cts} +1 -1
- package/dist/rand-8xbUb6ur.d.ts +1118 -0
- package/dist/rand-Cw9VLrVC.d.cts +1118 -0
- package/dist/raster/index.cjs +17 -19
- package/dist/raster/index.cjs.map +1 -1
- package/dist/raster/index.js +9 -11
- package/dist/raster/index.js.map +1 -1
- package/dist/{svg-rV6_HPmn.d.ts → svg-CSz3mzkw.d.ts} +2 -2
- package/dist/{svg-BDDKvWWY.d.cts → svg-DTb40ICU.d.cts} +2 -2
- package/dist/{tools-DPYerqeR.d.ts → tools-B0wXP5cF.d.ts} +1 -1
- package/dist/{tools-BAjSbTdY.d.cts → tools-Ca0kI1qo.d.cts} +1 -1
- package/dist/vector/index.cjs +1459 -1259
- package/dist/vector/index.cjs.map +1 -1
- package/dist/vector/index.d.cts +87 -11
- package/dist/vector/index.d.ts +87 -11
- package/dist/vector/index.js +213 -13
- package/dist/vector/index.js.map +1 -1
- package/dist/video-editor/index.d.cts +4 -4
- package/dist/video-editor/index.d.ts +4 -4
- package/dist/{warp-DQh9R7Ie.d.cts → warp-DTOp0lON.d.cts} +1 -1
- package/dist/{warp-XVL6SpSh.d.ts → warp-pd7hrH4T.d.ts} +1 -1
- package/package.json +1 -1
- package/skills/pixerate-vector/SKILL.md +8 -0
- package/dist/brushstrokeRender-JNHVEUFG.cjs.map +0 -1
- package/dist/chunk-2R3UW57U.cjs.map +0 -1
- package/dist/chunk-64PYNEHJ.js +0 -340
- package/dist/chunk-64PYNEHJ.js.map +0 -1
- package/dist/chunk-6GFRKLLS.cjs.map +0 -1
- package/dist/chunk-7QN76ESJ.js +0 -323
- package/dist/chunk-7QN76ESJ.js.map +0 -1
- package/dist/chunk-BR7EKQUP.js.map +0 -1
- package/dist/chunk-DCLJNVZS.cjs +0 -323
- package/dist/chunk-DCLJNVZS.cjs.map +0 -1
- package/dist/chunk-EM3FMJWE.js.map +0 -1
- package/dist/chunk-J5BA3BQ6.cjs.map +0 -1
- package/dist/chunk-JLGNZMUV.cjs.map +0 -1
- package/dist/chunk-MAHQC3SK.js.map +0 -1
- package/dist/chunk-Z6OUCS2K.cjs +0 -340
- package/dist/chunk-Z6OUCS2K.cjs.map +0 -1
- package/dist/rand-BszBST4s.d.ts +0 -2140
- package/dist/rand-DOH_aMvm.d.cts +0 -2140
- /package/dist/{chunk-62XUO5LB.js.map → chunk-3X6IAJUQ.js.map} +0 -0
- /package/dist/{chunk-KZXLZCQ7.js.map → chunk-6S6362D2.js.map} +0 -0
- /package/dist/{chunk-SVYE5HIM.js.map → chunk-EQQMGO42.js.map} +0 -0
- /package/dist/{chunk-UYQUPUR6.js.map → chunk-HUO3TI4C.js.map} +0 -0
- /package/dist/{chunk-2HC4DRF4.js.map → chunk-LLFHCSU2.js.map} +0 -0
- /package/dist/{chunk-ILYFOJUN.js.map → chunk-OIBIRXRG.js.map} +0 -0
package/dist/raster/index.cjs
CHANGED
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
|
|
62
62
|
|
|
63
63
|
|
|
64
|
-
var
|
|
64
|
+
var _chunkAEAAN4ADcjs = require('../chunk-AEAAN4AD.cjs');
|
|
65
65
|
require('../chunk-MUUXNRU4.cjs');
|
|
66
66
|
|
|
67
67
|
|
|
@@ -128,7 +128,6 @@ require('../chunk-MUUXNRU4.cjs');
|
|
|
128
128
|
|
|
129
129
|
|
|
130
130
|
|
|
131
|
-
var _chunkJ5BA3BQ6cjs = require('../chunk-J5BA3BQ6.cjs');
|
|
132
131
|
|
|
133
132
|
|
|
134
133
|
|
|
@@ -136,8 +135,7 @@ var _chunkJ5BA3BQ6cjs = require('../chunk-J5BA3BQ6.cjs');
|
|
|
136
135
|
|
|
137
136
|
|
|
138
137
|
|
|
139
|
-
|
|
140
|
-
var _chunkDCLJNVZScjs = require('../chunk-DCLJNVZS.cjs');
|
|
138
|
+
var _chunkO7LUD7MHcjs = require('../chunk-O7LUD7MH.cjs');
|
|
141
139
|
|
|
142
140
|
|
|
143
141
|
|
|
@@ -190,13 +188,13 @@ function surfaceMipLevel(screenPixelsPerSurfacePixel, maxLevel = 4) {
|
|
|
190
188
|
return Math.min(maxLevel, Math.floor(Math.log2(1 / s)));
|
|
191
189
|
}
|
|
192
190
|
function downsampleInto(src, n, out, ox, oy) {
|
|
193
|
-
const side =
|
|
191
|
+
const side = _chunkO7LUD7MHcjs.TILE / n;
|
|
194
192
|
const area = n * n;
|
|
195
193
|
for (let y = 0; y < side; y++) {
|
|
196
194
|
for (let x = 0; x < side; x++) {
|
|
197
195
|
let r = 0, g = 0, b = 0, a = 0;
|
|
198
196
|
for (let dy = 0; dy < n; dy++) {
|
|
199
|
-
let i = ((y * n + dy) *
|
|
197
|
+
let i = ((y * n + dy) * _chunkO7LUD7MHcjs.TILE + x * n) * 4;
|
|
200
198
|
for (let dx = 0; dx < n; dx++, i += 4) {
|
|
201
199
|
const al = src[i + 3];
|
|
202
200
|
r += src[i] * al;
|
|
@@ -205,7 +203,7 @@ function downsampleInto(src, n, out, ox, oy) {
|
|
|
205
203
|
a += al;
|
|
206
204
|
}
|
|
207
205
|
}
|
|
208
|
-
const o = ((oy + y) *
|
|
206
|
+
const o = ((oy + y) * _chunkO7LUD7MHcjs.TILE + ox + x) * 4;
|
|
209
207
|
if (a > 0) {
|
|
210
208
|
out[o] = r / a;
|
|
211
209
|
out[o + 1] = g / a;
|
|
@@ -229,10 +227,10 @@ var SurfaceViewportRenderer = (_class = class {
|
|
|
229
227
|
this.uniform.clear();
|
|
230
228
|
}
|
|
231
229
|
image(data) {
|
|
232
|
-
const canvas = this.createCanvas(
|
|
230
|
+
const canvas = this.createCanvas(_chunkO7LUD7MHcjs.TILE, _chunkO7LUD7MHcjs.TILE);
|
|
233
231
|
const ctx = canvas.getContext("2d");
|
|
234
232
|
if (!ctx) return null;
|
|
235
|
-
const img = ctx.createImageData(
|
|
233
|
+
const img = ctx.createImageData(_chunkO7LUD7MHcjs.TILE, _chunkO7LUD7MHcjs.TILE);
|
|
236
234
|
img.data.set(data);
|
|
237
235
|
ctx.putImageData(img, 0, 0);
|
|
238
236
|
return canvas;
|
|
@@ -250,7 +248,7 @@ var SurfaceViewportRenderer = (_class = class {
|
|
|
250
248
|
uniformImage(value) {
|
|
251
249
|
let c = this.uniform.get(value);
|
|
252
250
|
if (!c) {
|
|
253
|
-
const data = new Uint8ClampedArray(
|
|
251
|
+
const data = new Uint8ClampedArray(_chunkO7LUD7MHcjs.TILE * _chunkO7LUD7MHcjs.TILE * 4);
|
|
254
252
|
for (let i = 0; i < data.length; i += 4) {
|
|
255
253
|
data[i] = value >>> 24 & 255;
|
|
256
254
|
data[i + 1] = value >>> 16 & 255;
|
|
@@ -267,17 +265,17 @@ var SurfaceViewportRenderer = (_class = class {
|
|
|
267
265
|
mipImage(surface, level, mx, my) {
|
|
268
266
|
const n = 1 << level;
|
|
269
267
|
const sources = [];
|
|
270
|
-
for (let dy = 0; dy < n; dy++) for (let dx = 0; dx < n; dx++) sources.push(surface.tiles.get(
|
|
268
|
+
for (let dy = 0; dy < n; dy++) for (let dx = 0; dx < n; dx++) sources.push(surface.tiles.get(_chunkO7LUD7MHcjs.tileKey.call(void 0, mx * n + dx, my * n + dy)));
|
|
271
269
|
if (sources.every((t) => !t)) return null;
|
|
272
270
|
const key = `${level}:${mx}:${my}`;
|
|
273
271
|
const hit = this.mips.get(key);
|
|
274
272
|
if (hit && hit.sources.length === sources.length && hit.sources.every((t, i) => t === sources[i])) return hit.canvas;
|
|
275
|
-
const out = new Uint8ClampedArray(
|
|
276
|
-
const side =
|
|
273
|
+
const out = new Uint8ClampedArray(_chunkO7LUD7MHcjs.TILE * _chunkO7LUD7MHcjs.TILE * 4);
|
|
274
|
+
const side = _chunkO7LUD7MHcjs.TILE / n;
|
|
277
275
|
const blank = surface.defaultValue ? this.defaultTileData(surface.defaultValue) : null;
|
|
278
276
|
sources.forEach((t, i) => {
|
|
279
277
|
const src = _nullishCoalesce(_optionalChain([t, 'optionalAccess', _9 => _9.data]), () => ( blank));
|
|
280
|
-
if (src && src.length ===
|
|
278
|
+
if (src && src.length === _chunkO7LUD7MHcjs.TILE * _chunkO7LUD7MHcjs.TILE * 4) downsampleInto(src, n, out, i % n * side, Math.floor(i / n) * side);
|
|
281
279
|
});
|
|
282
280
|
const canvas = this.image(out);
|
|
283
281
|
if (!canvas) return null;
|
|
@@ -285,7 +283,7 @@ var SurfaceViewportRenderer = (_class = class {
|
|
|
285
283
|
return canvas;
|
|
286
284
|
}
|
|
287
285
|
defaultTileData(value) {
|
|
288
|
-
const data = new Uint8ClampedArray(
|
|
286
|
+
const data = new Uint8ClampedArray(_chunkO7LUD7MHcjs.TILE * _chunkO7LUD7MHcjs.TILE * 4);
|
|
289
287
|
for (let i = 0; i < data.length; i += 4) {
|
|
290
288
|
data[i] = value >>> 24 & 255;
|
|
291
289
|
data[i + 1] = value >>> 16 & 255;
|
|
@@ -305,7 +303,7 @@ var SurfaceViewportRenderer = (_class = class {
|
|
|
305
303
|
const zoom = view.zoom > 0 ? view.zoom : 1;
|
|
306
304
|
const screenPerPixel = zoom / ppu;
|
|
307
305
|
const level = surfaceMipLevel(screenPerPixel, _nullishCoalesce(options.maxMipLevel, () => ( 4)));
|
|
308
|
-
const span =
|
|
306
|
+
const span = _chunkO7LUD7MHcjs.TILE << level;
|
|
309
307
|
const visible = visibleSurfaceRect(mapping, view, options.width, options.height);
|
|
310
308
|
const tx0 = Math.floor(visible.x / span);
|
|
311
309
|
const ty0 = Math.floor(visible.y / span);
|
|
@@ -320,7 +318,7 @@ var SurfaceViewportRenderer = (_class = class {
|
|
|
320
318
|
if (!surface.defaultValue && surface.tiles.size < (tx1 - tx0 + 1) * (ty1 - ty0 + 1)) {
|
|
321
319
|
const seen = /* @__PURE__ */ new Set();
|
|
322
320
|
for (const key of surface.tiles.keys()) {
|
|
323
|
-
const c =
|
|
321
|
+
const c = _chunkO7LUD7MHcjs.tileCoord.call(void 0, key);
|
|
324
322
|
const mx = Math.floor(c.tx / (1 << level));
|
|
325
323
|
const my = Math.floor(c.ty / (1 << level));
|
|
326
324
|
if (mx < tx0 || mx > tx1 || my < ty0 || my > ty1 || seen.has(`${mx},${my}`)) continue;
|
|
@@ -333,7 +331,7 @@ var SurfaceViewportRenderer = (_class = class {
|
|
|
333
331
|
for (const [tx, ty] of keys) {
|
|
334
332
|
let canvas = null;
|
|
335
333
|
if (level === 0) {
|
|
336
|
-
const tile = surface.tiles.get(
|
|
334
|
+
const tile = surface.tiles.get(_chunkO7LUD7MHcjs.tileKey.call(void 0, tx, ty));
|
|
337
335
|
if (tile) {
|
|
338
336
|
const had = this.base.has(tile);
|
|
339
337
|
canvas = this.tileImage(tile);
|
|
@@ -512,5 +510,5 @@ function drawSurfaceToViewport(ctx, surface, mapping, view, options) {
|
|
|
512
510
|
|
|
513
511
|
|
|
514
512
|
|
|
515
|
-
exports.BIT_DEPTHS =
|
|
513
|
+
exports.BIT_DEPTHS = _chunkO7LUD7MHcjs.BIT_DEPTHS; exports.BLEND_MODES = _chunkO7LUD7MHcjs.BLEND_MODES; exports.CURVE_LUT_SIZE = _chunkAEAAN4ADcjs.CURVE_LUT_SIZE; exports.DEFAULT_GLOBAL_LIGHT = _chunkAEAAN4ADcjs.DEFAULT_GLOBAL_LIGHT; exports.DIRECT_GAUSSIAN_MAX_SIGMA = _chunkAEAAN4ADcjs.DIRECT_GAUSSIAN_MAX_SIGMA; exports.DeepCompositor = _chunkAEAAN4ADcjs.DeepCompositor; exports.INTERPOLATIONS = _chunkAEAAN4ADcjs.INTERPOLATIONS; exports.LAYER_EFFECT_KINDS = _chunkAEAAN4ADcjs.LAYER_EFFECT_KINDS; exports.LayerEffectError = _chunkAEAAN4ADcjs.LayerEffectError; exports.MAX_EFFECT_REACH = _chunkAEAAN4ADcjs.MAX_EFFECT_REACH; exports.MAX_TRANSFORM_PIXELS = _chunkAEAAN4ADcjs.MAX_TRANSFORM_PIXELS; exports.PAINTERLY_BLEND_MODES = _chunkO7LUD7MHcjs.PAINTERLY_BLEND_MODES; exports.PatternPlacement = _chunkAEAAN4ADcjs.PatternPlacement; exports.PatternTile = _chunkAEAAN4ADcjs.PatternTile; exports.RasterCompositor = _chunkAEAAN4ADcjs.RasterCompositor; exports.SHADOW_AMBIENT = _chunkO7LUD7MHcjs.SHADOW_AMBIENT; exports.STROKE_CHAMFER_MAX = _chunkAEAAN4ADcjs.STROKE_CHAMFER_MAX; exports.SurfaceDraft = _chunkO7LUD7MHcjs.SurfaceDraft; exports.SurfaceViewportRenderer = SurfaceViewportRenderer; exports.TILE = _chunkO7LUD7MHcjs.TILE; exports.TILE_SHIFT = _chunkO7LUD7MHcjs.TILE_SHIFT; exports.TiledSurface = _chunkO7LUD7MHcjs.TiledSurface; exports.TransformTooLargeError = _chunkAEAAN4ADcjs.TransformTooLargeError; exports.ZlibError = _chunk643B2HKCcjs.ZlibError; exports.activeEffectItems = _chunkAEAAN4ADcjs.activeEffectItems; exports.adler32 = _chunk643B2HKCcjs.adler32; exports.base64ToBytes = _chunkO7LUD7MHcjs.base64ToBytes; exports.blendChannel = _chunkO7LUD7MHcjs.blendChannel; exports.blendImageData = _chunkO7LUD7MHcjs.blendImageData; exports.blendLum = _chunkO7LUD7MHcjs.blendLum; exports.blendPixel = _chunkO7LUD7MHcjs.blendPixel; exports.blendRgb = _chunkO7LUD7MHcjs.blendRgb; exports.blendTile = _chunkAEAAN4ADcjs.blendTile; exports.buildEffectMaps = _chunkAEAAN4ADcjs.buildEffectMaps; exports.builtinPattern = _chunkAEAAN4ADcjs.builtinPattern; exports.builtinPatternIds = _chunkAEAAN4ADcjs.builtinPatternIds; exports.bytesToBase64 = _chunkO7LUD7MHcjs.bytesToBase64; exports.canvasCompositeOperation = _chunkO7LUD7MHcjs.canvasCompositeOperation; exports.changedTiles = _chunkAEAAN4ADcjs.changedTiles; exports.collectTiles = _chunkO7LUD7MHcjs.collectTiles; exports.compositeLayerEffects = _chunkAEAAN4ADcjs.compositeLayerEffects; exports.compositeSurfaceOver = _chunkAEAAN4ADcjs.compositeSurfaceOver; exports.contentBounds = _chunkO7LUD7MHcjs.contentBounds; exports.contourLut = _chunkAEAAN4ADcjs.contourLut; exports.convertSurfaceDepth = _chunkO7LUD7MHcjs.convertSurfaceDepth; exports.curveLut = _chunkAEAAN4ADcjs.curveLut; exports.decodePng = _chunkO7LUD7MHcjs.decodePng; exports.deepBytes = _chunkO7LUD7MHcjs.deepBytes; exports.deepTile = _chunkO7LUD7MHcjs.deepTile; exports.defaultEffectGradient = _chunkAEAAN4ADcjs.defaultEffectGradient; exports.defaultLayerEffect = _chunkAEAAN4ADcjs.defaultLayerEffect; exports.deflate = _chunk643B2HKCcjs.deflate; exports.deflateRaw = _chunk643B2HKCcjs.deflateRaw; exports.depthOf = _chunkO7LUD7MHcjs.depthOf; exports.drawSurfaceToViewport = drawSurfaceToViewport; exports.effectColorHex = _chunkAEAAN4ADcjs.effectColorHex; exports.effectFillColors = _chunkAEAAN4ADcjs.effectFillColors; exports.effectReach = _chunkAEAAN4ADcjs.effectReach; exports.effectsAreLocal = _chunkAEAAN4ADcjs.effectsAreLocal; exports.effectsFingerprint = _chunkAEAAN4ADcjs.effectsFingerprint; exports.effectsMargin = _chunkAEAAN4ADcjs.effectsMargin; exports.effectsScale = _chunkAEAAN4ADcjs.effectsScale; exports.emptySurface = _chunkO7LUD7MHcjs.emptySurface; exports.encodePng = _chunkO7LUD7MHcjs.encodePng; exports.fillRect = _chunkO7LUD7MHcjs.fillRect; exports.findLayer = _chunkAEAAN4ADcjs.findLayer; exports.finishTile = _chunkO7LUD7MHcjs.finishTile; exports.flattenLayers = _chunkAEAAN4ADcjs.flattenLayers; exports.gaussianBlur = _chunkAEAAN4ADcjs.gaussianBlur; exports.gradientT = _chunkAEAAN4ADcjs.gradientT; exports.hasActiveEffects = _chunkAEAAN4ADcjs.hasActiveEffects; exports.hashNoise = _chunkAEAAN4ADcjs.hashNoise; exports.inflate = _chunk643B2HKCcjs.inflate; exports.inflateRaw = _chunk643B2HKCcjs.inflateRaw; exports.insertLayer = _chunkAEAAN4ADcjs.insertLayer; exports.isBitDepth = _chunkO7LUD7MHcjs.isBitDepth; exports.isBlendMode = _chunkO7LUD7MHcjs.isBlendMode; exports.isInterpolation = _chunkAEAAN4ADcjs.isInterpolation; exports.isLayerEffectKind = _chunkAEAAN4ADcjs.isLayerEffectKind; exports.isLayerLocked = _chunkAEAAN4ADcjs.isLayerLocked; exports.isPainterlyBlendMode = _chunkO7LUD7MHcjs.isPainterlyBlendMode; exports.isPng = _chunkO7LUD7MHcjs.isPng; exports.isSeparableBlendMode = _chunkO7LUD7MHcjs.isSeparableBlendMode; exports.keepDeepSamples = _chunkO7LUD7MHcjs.keepDeepSamples; exports.keysWeight = _chunkAEAAN4ADcjs.keysWeight; exports.layerEffectFields = _chunkAEAAN4ADcjs.layerEffectFields; exports.layerEffectLabel = _chunkAEAAN4ADcjs.layerEffectLabel; exports.mapLayer = _chunkAEAAN4ADcjs.mapLayer; exports.mergeLayerEffect = _chunkAEAAN4ADcjs.mergeLayerEffect; exports.mixPigment8 = _chunkO7LUD7MHcjs.mixPigment8; exports.mixPigmentRgb = _chunkO7LUD7MHcjs.mixPigmentRgb; exports.newEffectId = _chunkAEAAN4ADcjs.newEffectId; exports.normalizeBlendMode = _chunkO7LUD7MHcjs.normalizeBlendMode; exports.normalizeLayerEffects = _chunkAEAAN4ADcjs.normalizeLayerEffects; exports.packRgba = _chunkO7LUD7MHcjs.packRgba; exports.parseDataUrl = _chunkO7LUD7MHcjs.parseDataUrl; exports.parseEffectColor = _chunkAEAAN4ADcjs.parseEffectColor; exports.patchEffectMaps = _chunkAEAAN4ADcjs.patchEffectMaps; exports.pigment8 = _chunkO7LUD7MHcjs.pigment8; exports.pngDataUrl = _chunkO7LUD7MHcjs.pngDataUrl; exports.proxyOf = _chunkO7LUD7MHcjs.proxyOf; exports.readDeepRegion = _chunkO7LUD7MHcjs.readDeepRegion; exports.readPixel = _chunkO7LUD7MHcjs.readPixel; exports.readRegion = _chunkO7LUD7MHcjs.readRegion; exports.reduceSurface = _chunkAEAAN4ADcjs.reduceSurface; exports.renderLayerEffects = _chunkAEAAN4ADcjs.renderLayerEffects; exports.scaleLayerEffect = _chunkAEAAN4ADcjs.scaleLayerEffect; exports.screenToWorld = screenToWorld; exports.setLum = _chunkO7LUD7MHcjs.setLum; exports.solidSurface = _chunkO7LUD7MHcjs.solidSurface; exports.srgbDecode = _chunkO7LUD7MHcjs.srgbDecode; exports.srgbEncode = _chunkO7LUD7MHcjs.srgbEncode; exports.standardBlendMode = _chunkO7LUD7MHcjs.standardBlendMode; exports.surfaceBytes = _chunkO7LUD7MHcjs.surfaceBytes; exports.surfaceDepth = _chunkO7LUD7MHcjs.surfaceDepth; exports.surfaceFromDeepPixels = _chunkO7LUD7MHcjs.surfaceFromDeepPixels; exports.surfaceFromPixels = _chunkO7LUD7MHcjs.surfaceFromPixels; exports.surfaceMipLevel = surfaceMipLevel; exports.surfaceResolutionForZoom = surfaceResolutionForZoom; exports.surfaceToWorld = surfaceToWorld; exports.surfacesEqual = _chunkO7LUD7MHcjs.surfacesEqual; exports.tileCoord = _chunkO7LUD7MHcjs.tileCoord; exports.tileKey = _chunkO7LUD7MHcjs.tileKey; exports.tileRect = _chunkO7LUD7MHcjs.tileRect; exports.tileSamples = _chunkO7LUD7MHcjs.tileSamples; exports.tileSamples16 = _chunkO7LUD7MHcjs.tileSamples16; exports.tileSamples32 = _chunkO7LUD7MHcjs.tileSamples32; exports.tilesInRect = _chunkO7LUD7MHcjs.tilesInRect; exports.to16From32 = _chunkO7LUD7MHcjs.to16From32; exports.to16From8 = _chunkO7LUD7MHcjs.to16From8; exports.to32From16 = _chunkO7LUD7MHcjs.to32From16; exports.to32From8 = _chunkO7LUD7MHcjs.to32From8; exports.to8From16 = _chunkO7LUD7MHcjs.to8From16; exports.to8From32 = _chunkO7LUD7MHcjs.to8From32; exports.transformSurface = _chunkAEAAN4ADcjs.transformSurface; exports.transformedBounds = _chunkAEAAN4ADcjs.transformedBounds; exports.translateSurface = _chunkO7LUD7MHcjs.translateSurface; exports.uniformTile = _chunkO7LUD7MHcjs.uniformTile; exports.validateEffectGradient = _chunkAEAAN4ADcjs.validateEffectGradient; exports.validateLayerEffect = _chunkAEAAN4ADcjs.validateLayerEffect; exports.validateLayerEffects = _chunkAEAAN4ADcjs.validateLayerEffects; exports.visibleSurfaceRect = visibleSurfaceRect; exports.visibleWorldRect = visibleWorldRect; exports.warpSurface = _chunkAEAAN4ADcjs.warpSurface; exports.workingToSamples = _chunkAEAAN4ADcjs.workingToSamples; exports.worldRectToSurface = worldRectToSurface; exports.worldToSurface = worldToSurface; exports.writeDeepRegion = _chunkO7LUD7MHcjs.writeDeepRegion; exports.writeRegion = _chunkO7LUD7MHcjs.writeRegion;
|
|
516
514
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/editor/editor/packages/core/dist/raster/index.cjs","../../src/raster/viewport.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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UAAA;AACP,QAAA;AACK,MAAA;AACC,QAAA;AACA,QAAA;AACA,QAAA;AACG,QAAA;AACL,QAAA;AACC,QAAA;AACP,MAAA;AACK,MAAA;AACC,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACK,MAAA;AACP,MAAA;AACJ,MAAA;AACF,IAAA;AACS,IAAA;AACX,EAAA;AACF;AAMgB;AAOC,EAAA;AACjB;ADgCiB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/editor/editor/packages/core/dist/raster/index.cjs","sourcesContent":[null,"/**\n * Showing a tiled surface in a pannable, zoomable view (an infinite canvas): world ↔ surface\n * mapping with a resolution policy, the surface rectangle a view can see, and drawing a surface\n * onto a 2D context with visible-tile culling and mip levels. Hosts bring the 2D context and a\n * canvas factory, so this module stays free of any browser API.\n *\n * Coordinates: **world** units are the host's (a node canvas's flow units). **Surface** pixels are\n * the tiled surface's; surface pixel (0, 0) sits at world `origin` and one world unit is\n * `pixelsPerUnit` surface pixels. **Screen** pixels follow the view as xyflow defines it:\n * `screen = world × zoom + (x, y)`.\n */\n\nimport { TILE, tileCoord, tileKey, type RasterRect, type Tile, type TiledSurface } from './surface';\n\n/** Where a surface lies in the world. */\nexport interface SurfaceMapping {\n /** World position of surface pixel (0, 0) (default 0, 0). */\n origin?: { x: number; y: number };\n /** Surface pixels per world unit (default 1). */\n pixelsPerUnit?: number;\n}\n\n/** A pan / zoom view: `screen = world × zoom + (x, y)` (the xyflow viewport). */\nexport interface ViewTransform {\n x: number;\n y: number;\n zoom: number;\n}\n\nconst ppuOf = (m: SurfaceMapping) => (m.pixelsPerUnit && m.pixelsPerUnit > 0 ? m.pixelsPerUnit : 1);\n\n/** A world point in surface pixels. */\nexport function worldToSurface(mapping: SurfaceMapping, x: number, y: number): { x: number; y: number } {\n const k = ppuOf(mapping);\n return { x: (x - (mapping.origin?.x ?? 0)) * k, y: (y - (mapping.origin?.y ?? 0)) * k };\n}\n\n/** A surface pixel position in world units. */\nexport function surfaceToWorld(mapping: SurfaceMapping, x: number, y: number): { x: number; y: number } {\n const k = ppuOf(mapping);\n return { x: x / k + (mapping.origin?.x ?? 0), y: y / k + (mapping.origin?.y ?? 0) };\n}\n\n/** A world rectangle as the whole surface pixels it touches. */\nexport function worldRectToSurface(mapping: SurfaceMapping, rect: { x: number; y: number; width: number; height: number }): RasterRect {\n const a = worldToSurface(mapping, rect.x, rect.y);\n const b = worldToSurface(mapping, rect.x + rect.width, rect.y + rect.height);\n const x = Math.floor(Math.min(a.x, b.x));\n const y = Math.floor(Math.min(a.y, b.y));\n return { x, y, width: Math.ceil(Math.max(a.x, b.x)) - x, height: Math.ceil(Math.max(a.y, b.y)) - y };\n}\n\n/** A screen point (relative to the view's element) in world units. */\nexport function screenToWorld(view: ViewTransform, x: number, y: number): { x: number; y: number } {\n const z = view.zoom > 0 ? view.zoom : 1;\n return { x: (x - view.x) / z, y: (y - view.y) / z };\n}\n\n/** The world rectangle a `width × height` screen area shows. */\nexport function visibleWorldRect(view: ViewTransform, width: number, height: number): { x: number; y: number; width: number; height: number } {\n const a = screenToWorld(view, 0, 0);\n const z = view.zoom > 0 ? view.zoom : 1;\n return { x: a.x, y: a.y, width: width / z, height: height / z };\n}\n\n/** The surface pixels a `width × height` screen area shows (pad by `margin` surface pixels). */\nexport function visibleSurfaceRect(mapping: SurfaceMapping, view: ViewTransform, width: number, height: number, margin = 0): RasterRect {\n const r = worldRectToSurface(mapping, visibleWorldRect(view, width, height));\n return { x: r.x - margin, y: r.y - margin, width: r.width + 2 * margin, height: r.height + 2 * margin };\n}\n\nexport interface ResolutionPolicy {\n /** Screen pixel density (default 1). */\n devicePixelRatio?: number;\n /** Fewest surface pixels per world unit (default 1/4). */\n min?: number;\n /** Most surface pixels per world unit (default 8). */\n max?: number;\n}\n\n/**\n * The surface density (pixels per world unit) for painting at `zoom`: the screen density rounded\n * up to a power of two and clamped, so strokes are never coarser than the screen and nearby\n * zooms share a density. Use it when creating a surface (or a level of one) for the current view.\n */\nexport function surfaceResolutionForZoom(zoom: number, policy: ResolutionPolicy = {}): number {\n const s = zoom * (policy.devicePixelRatio && policy.devicePixelRatio > 0 ? policy.devicePixelRatio : 1);\n const min = policy.min && policy.min > 0 ? policy.min : 1 / 4;\n const max = policy.max && policy.max > 0 ? policy.max : 8;\n if (!Number.isFinite(s) || s <= 0) return Math.min(max, Math.max(min, 1));\n return Math.min(max, Math.max(min, Math.pow(2, Math.ceil(Math.log2(s) - 1e-9))));\n}\n\n/**\n * The mip level to draw a surface at: 0 at or above half a screen pixel per surface pixel, then\n * one level per halving (each level halves the resolution), at most `maxLevel`.\n */\nexport function surfaceMipLevel(screenPixelsPerSurfacePixel: number, maxLevel = 4): number {\n const s = screenPixelsPerSurfacePixel;\n if (!(s > 0) || s >= 0.5) return 0;\n return Math.min(maxLevel, Math.floor(Math.log2(1 / s)));\n}\n\n// ---------------------------------------------------------------------------\n// Drawing\n// ---------------------------------------------------------------------------\n\n/** The 2D context `drawSurfaceToViewport` draws on (a canvas 2D context, structurally). */\nexport interface ViewportContext2D {\n drawImage(image: never, dx: number, dy: number, dw: number, dh: number): void;\n imageSmoothingEnabled?: boolean;\n}\n\n/** A canvas the renderer makes tile images on (a canvas element or an offscreen canvas, structurally). */\nexport interface TileCanvasLike {\n getContext(type: '2d'): { createImageData(w: number, h: number): { data: Uint8ClampedArray }; putImageData(image: never, x: number, y: number): void } | null;\n}\n\nexport interface DrawSurfaceOptions {\n /** View area in screen pixels (the canvas's CSS size). */\n width: number;\n height: number;\n /** Highest mip level (default 4: down to 1/16 resolution). */\n maxMipLevel?: number;\n /** Smooth scaling (default: true when zoomed out, false when a surface pixel covers 2+ screen pixels). */\n smoothing?: boolean;\n}\n\nexport interface DrawSurfaceStats {\n level: number;\n /** Tiles drawn (at that level). */\n drawn: number;\n /** Tile images made this call (the rest came from the cache). */\n built: number;\n}\n\n/** Box-filters `n × n` blocks of straight-alpha RGBA (premultiplied while averaging). */\nfunction downsampleInto(src: Uint8ClampedArray, n: number, out: Uint8ClampedArray, ox: number, oy: number): void {\n const side = TILE / n;\n const area = n * n;\n for (let y = 0; y < side; y++) {\n for (let x = 0; x < side; x++) {\n let r = 0, g = 0, b = 0, a = 0;\n for (let dy = 0; dy < n; dy++) {\n let i = ((y * n + dy) * TILE + x * n) * 4;\n for (let dx = 0; dx < n; dx++, i += 4) {\n const al = src[i + 3];\n r += src[i] * al;\n g += src[i + 1] * al;\n b += src[i + 2] * al;\n a += al;\n }\n }\n const o = ((oy + y) * TILE + ox + x) * 4;\n if (a > 0) {\n out[o] = r / a;\n out[o + 1] = g / a;\n out[o + 2] = b / a;\n out[o + 3] = a / area;\n }\n }\n }\n}\n\n/**\n * Draws tiled surfaces onto 2D contexts, keeping a cache of tile images: level-0 images by tile\n * identity (tiles are copy-on-write, so an edited tile is a new object), mip images by the tiles\n * they were built from. One renderer per surface you show; `clear` drops the cache.\n */\nexport class SurfaceViewportRenderer<C extends TileCanvasLike = TileCanvasLike> {\n private readonly base = new WeakMap<Tile, C>();\n private readonly mips = new Map<string, { sources: (Tile | undefined)[]; canvas: C }>();\n private readonly uniform = new Map<number, C>();\n\n /** `createCanvas(256, 256)` makes the tile images (inject a canvas element or offscreen canvas). */\n constructor(private readonly createCanvas: (width: number, height: number) => C) {}\n\n clear(): void {\n this.mips.clear();\n this.uniform.clear();\n }\n\n private image(data: ArrayLike<number>): C | null {\n const canvas = this.createCanvas(TILE, TILE);\n const ctx = canvas.getContext('2d');\n if (!ctx) return null;\n const img = ctx.createImageData(TILE, TILE);\n img.data.set(data);\n ctx.putImageData(img as never, 0, 0);\n return canvas;\n }\n\n private tileImage(tile: Tile): C | null {\n let c = this.base.get(tile);\n if (!c) {\n const img = this.image(tile.data);\n if (!img) return null;\n c = img;\n this.base.set(tile, c);\n }\n return c;\n }\n\n private uniformImage(value: number): C | null {\n let c = this.uniform.get(value);\n if (!c) {\n const data = new Uint8ClampedArray(TILE * TILE * 4);\n for (let i = 0; i < data.length; i += 4) {\n data[i] = (value >>> 24) & 255;\n data[i + 1] = (value >>> 16) & 255;\n data[i + 2] = (value >>> 8) & 255;\n data[i + 3] = value & 255;\n }\n const img = this.image(data);\n if (!img) return null;\n c = img;\n this.uniform.set(value, c);\n }\n return c;\n }\n\n private mipImage(surface: TiledSurface, level: number, mx: number, my: number): C | null {\n const n = 1 << level;\n const sources: (Tile | undefined)[] = [];\n for (let dy = 0; dy < n; dy++) for (let dx = 0; dx < n; dx++) sources.push(surface.tiles.get(tileKey(mx * n + dx, my * n + dy)));\n if (sources.every((t) => !t)) return null;\n const key = `${level}:${mx}:${my}`;\n const hit = this.mips.get(key);\n if (hit && hit.sources.length === sources.length && hit.sources.every((t, i) => t === sources[i])) return hit.canvas;\n const out = new Uint8ClampedArray(TILE * TILE * 4);\n const side = TILE / n;\n const blank = surface.defaultValue ? this.defaultTileData(surface.defaultValue) : null;\n sources.forEach((t, i) => {\n const src = t?.data ?? blank;\n if (src && src.length === TILE * TILE * 4) downsampleInto(src as Uint8ClampedArray, n, out, (i % n) * side, Math.floor(i / n) * side);\n });\n const canvas = this.image(out);\n if (!canvas) return null;\n this.mips.set(key, { sources, canvas });\n return canvas;\n }\n\n private defaultTileData(value: number): Uint8ClampedArray {\n const data = new Uint8ClampedArray(TILE * TILE * 4);\n for (let i = 0; i < data.length; i += 4) {\n data[i] = (value >>> 24) & 255;\n data[i + 1] = (value >>> 16) & 255;\n data[i + 2] = (value >>> 8) & 255;\n data[i + 3] = value & 255;\n }\n return data;\n }\n\n /**\n * Draws the part of an RGBA `surface` (placed by `mapping`) that `view` shows onto `ctx`, tile\n * by tile: only visible tiles, at the mip level the zoom calls for, at whole screen pixels so\n * tiles meet without seams. Does not clear `ctx` first.\n */\n draw(ctx: ViewportContext2D, surface: TiledSurface, mapping: SurfaceMapping, view: ViewTransform, options: DrawSurfaceOptions): DrawSurfaceStats {\n if (surface.channels !== 4) throw new Error('drawSurfaceToViewport draws RGBA surfaces (4 channels).');\n const ppu = ppuOf(mapping);\n const zoom = view.zoom > 0 ? view.zoom : 1;\n const screenPerPixel = zoom / ppu;\n const level = surfaceMipLevel(screenPerPixel, options.maxMipLevel ?? 4);\n const span = TILE << level; // surface pixels per drawn tile\n const visible = visibleSurfaceRect(mapping, view, options.width, options.height);\n const tx0 = Math.floor(visible.x / span);\n const ty0 = Math.floor(visible.y / span);\n const tx1 = Math.floor((visible.x + visible.width - 1) / span);\n const ty1 = Math.floor((visible.y + visible.height - 1) / span);\n ctx.imageSmoothingEnabled = options.smoothing ?? screenPerPixel < 2;\n const ox = (mapping.origin?.x ?? 0) * zoom + view.x;\n const oy = (mapping.origin?.y ?? 0) * zoom + view.y;\n let drawn = 0;\n let built = 0;\n // Visit the grid cells in view, or (zoomed far out over sparse paint) only the cells that hold tiles.\n const keys: Array<[number, number]> = [];\n if (!surface.defaultValue && surface.tiles.size < (tx1 - tx0 + 1) * (ty1 - ty0 + 1)) {\n const seen = new Set<string>();\n for (const key of surface.tiles.keys()) {\n const c = tileCoord(key);\n const mx = Math.floor(c.tx / (1 << level));\n const my = Math.floor(c.ty / (1 << level));\n if (mx < tx0 || mx > tx1 || my < ty0 || my > ty1 || seen.has(`${mx},${my}`)) continue;\n seen.add(`${mx},${my}`);\n keys.push([mx, my]);\n }\n } else {\n for (let ty = ty0; ty <= ty1; ty++) for (let tx = tx0; tx <= tx1; tx++) keys.push([tx, ty]);\n }\n for (const [tx, ty] of keys) {\n let canvas: C | null = null;\n if (level === 0) {\n const tile = surface.tiles.get(tileKey(tx, ty));\n if (tile) {\n const had = this.base.has(tile);\n canvas = this.tileImage(tile);\n if (!had && canvas) built++;\n } else if (surface.defaultValue) canvas = this.uniformImage(surface.defaultValue);\n } else {\n const before = this.mips.size;\n const hitKey = `${level}:${tx}:${ty}`;\n const prev = this.mips.get(hitKey)?.canvas;\n canvas = this.mipImage(surface, level, tx, ty);\n if (canvas && (this.mips.size !== before || canvas !== prev)) built++;\n if (!canvas && surface.defaultValue) canvas = this.uniformImage(surface.defaultValue);\n }\n if (!canvas) continue;\n const sx0 = Math.round(ox + (tx * span * zoom) / ppu);\n const sy0 = Math.round(oy + (ty * span * zoom) / ppu);\n const sx1 = Math.round(ox + ((tx + 1) * span * zoom) / ppu);\n const sy1 = Math.round(oy + ((ty + 1) * span * zoom) / ppu);\n if (sx1 <= sx0 || sy1 <= sy0) continue;\n ctx.drawImage(canvas as never, sx0, sy0, sx1 - sx0, sy1 - sy0);\n drawn++;\n }\n return { level, drawn, built };\n }\n}\n\n/**\n * Draws the visible part of an RGBA `surface` onto `ctx` with a `SurfaceViewportRenderer` (pass\n * the same renderer every frame to reuse its tile images). See `SurfaceViewportRenderer.draw`.\n */\nexport function drawSurfaceToViewport<C extends TileCanvasLike>(\n ctx: ViewportContext2D,\n surface: TiledSurface,\n mapping: SurfaceMapping,\n view: ViewTransform,\n options: DrawSurfaceOptions & { renderer: SurfaceViewportRenderer<C> }\n): DrawSurfaceStats {\n return options.renderer.draw(ctx, surface, mapping, view, options);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/editor/editor/packages/core/dist/raster/index.cjs","../../src/raster/viewport.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,yDAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACF,yDAA8B;AAC9B;AACA;ACtHA,IAAM,MAAA,EAAQ,CAAC,CAAA,EAAA,GAAuB,CAAA,CAAE,cAAA,GAAiB,CAAA,CAAE,cAAA,EAAgB,EAAA,EAAI,CAAA,CAAE,cAAA,EAAgB,CAAA;AAG1F,SAAS,cAAA,CAAe,OAAA,EAAyB,CAAA,EAAW,CAAA,EAAqC;AACtG,EAAA,MAAM,EAAA,EAAI,KAAA,CAAM,OAAO,CAAA;AACvB,EAAA,OAAO,EAAE,CAAA,EAAA,CAAI,EAAA,EA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ACE,IAAA;AACA,MAAA;AACK,MAAA;AACZ,IAAA;AACK,IAAA;AACO,IAAA;AACH,IAAA;AACH,IAAA;AACT,EAAA;AAEQ,EAAA;AACO,IAAA;AACA,IAAA;AACA,MAAA;AACD,MAAA;AACA,MAAA;AACA,MAAA;AACZ,IAAA;AACO,IAAA;AACT,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAO6B,EAAA;AACf,IAAA;AACA,IAAA;AACC,IAAA;AACP,IAAA;AACA,IAAA;AACO,IAAA;AACP,IAAA;AACM,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACR,IAAA;AACQ,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AAE0B,IAAA;AACzB,IAAA;AACL,MAAA;AACK,MAAA;AACH,QAAA;AACA,QAAA;AACA,QAAA;AACG,QAAA;AACA,QAAA;AACJ,QAAA;AACP,MAAA;AACK,IAAA;AACI,MAAA;AACX,IAAA;AACY,IAAA;AACN,MAAA;AACA,MAAA;AACI,QAAA;AACF,QAAA;AACI,UAAA;AACN,UAAA;AACK,UAAA;AACP,QAAA;AACK,MAAA;AACC,QAAA;AACA,QAAA;AACA,QAAA;AACG,QAAA;AACL,QAAA;AACC,QAAA;AACP,MAAA;AACK,MAAA;AACC,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACK,MAAA;AACP,MAAA;AACJ,MAAA;AACF,IAAA;AACS,IAAA;AACX,EAAA;AACF;AAMgB;AAOC,EAAA;AACjB;AD8BiB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/editor/editor/packages/core/dist/raster/index.cjs","sourcesContent":[null,"/**\n * Showing a tiled surface in a pannable, zoomable view (an infinite canvas): world ↔ surface\n * mapping with a resolution policy, the surface rectangle a view can see, and drawing a surface\n * onto a 2D context with visible-tile culling and mip levels. Hosts bring the 2D context and a\n * canvas factory, so this module stays free of any browser API.\n *\n * Coordinates: **world** units are the host's (a node canvas's flow units). **Surface** pixels are\n * the tiled surface's; surface pixel (0, 0) sits at world `origin` and one world unit is\n * `pixelsPerUnit` surface pixels. **Screen** pixels follow the view as xyflow defines it:\n * `screen = world × zoom + (x, y)`.\n */\n\nimport { TILE, tileCoord, tileKey, type RasterRect, type Tile, type TiledSurface } from './surface';\n\n/** Where a surface lies in the world. */\nexport interface SurfaceMapping {\n /** World position of surface pixel (0, 0) (default 0, 0). */\n origin?: { x: number; y: number };\n /** Surface pixels per world unit (default 1). */\n pixelsPerUnit?: number;\n}\n\n/** A pan / zoom view: `screen = world × zoom + (x, y)` (the xyflow viewport). */\nexport interface ViewTransform {\n x: number;\n y: number;\n zoom: number;\n}\n\nconst ppuOf = (m: SurfaceMapping) => (m.pixelsPerUnit && m.pixelsPerUnit > 0 ? m.pixelsPerUnit : 1);\n\n/** A world point in surface pixels. */\nexport function worldToSurface(mapping: SurfaceMapping, x: number, y: number): { x: number; y: number } {\n const k = ppuOf(mapping);\n return { x: (x - (mapping.origin?.x ?? 0)) * k, y: (y - (mapping.origin?.y ?? 0)) * k };\n}\n\n/** A surface pixel position in world units. */\nexport function surfaceToWorld(mapping: SurfaceMapping, x: number, y: number): { x: number; y: number } {\n const k = ppuOf(mapping);\n return { x: x / k + (mapping.origin?.x ?? 0), y: y / k + (mapping.origin?.y ?? 0) };\n}\n\n/** A world rectangle as the whole surface pixels it touches. */\nexport function worldRectToSurface(mapping: SurfaceMapping, rect: { x: number; y: number; width: number; height: number }): RasterRect {\n const a = worldToSurface(mapping, rect.x, rect.y);\n const b = worldToSurface(mapping, rect.x + rect.width, rect.y + rect.height);\n const x = Math.floor(Math.min(a.x, b.x));\n const y = Math.floor(Math.min(a.y, b.y));\n return { x, y, width: Math.ceil(Math.max(a.x, b.x)) - x, height: Math.ceil(Math.max(a.y, b.y)) - y };\n}\n\n/** A screen point (relative to the view's element) in world units. */\nexport function screenToWorld(view: ViewTransform, x: number, y: number): { x: number; y: number } {\n const z = view.zoom > 0 ? view.zoom : 1;\n return { x: (x - view.x) / z, y: (y - view.y) / z };\n}\n\n/** The world rectangle a `width × height` screen area shows. */\nexport function visibleWorldRect(view: ViewTransform, width: number, height: number): { x: number; y: number; width: number; height: number } {\n const a = screenToWorld(view, 0, 0);\n const z = view.zoom > 0 ? view.zoom : 1;\n return { x: a.x, y: a.y, width: width / z, height: height / z };\n}\n\n/** The surface pixels a `width × height` screen area shows (pad by `margin` surface pixels). */\nexport function visibleSurfaceRect(mapping: SurfaceMapping, view: ViewTransform, width: number, height: number, margin = 0): RasterRect {\n const r = worldRectToSurface(mapping, visibleWorldRect(view, width, height));\n return { x: r.x - margin, y: r.y - margin, width: r.width + 2 * margin, height: r.height + 2 * margin };\n}\n\nexport interface ResolutionPolicy {\n /** Screen pixel density (default 1). */\n devicePixelRatio?: number;\n /** Fewest surface pixels per world unit (default 1/4). */\n min?: number;\n /** Most surface pixels per world unit (default 8). */\n max?: number;\n}\n\n/**\n * The surface density (pixels per world unit) for painting at `zoom`: the screen density rounded\n * up to a power of two and clamped, so strokes are never coarser than the screen and nearby\n * zooms share a density. Use it when creating a surface (or a level of one) for the current view.\n */\nexport function surfaceResolutionForZoom(zoom: number, policy: ResolutionPolicy = {}): number {\n const s = zoom * (policy.devicePixelRatio && policy.devicePixelRatio > 0 ? policy.devicePixelRatio : 1);\n const min = policy.min && policy.min > 0 ? policy.min : 1 / 4;\n const max = policy.max && policy.max > 0 ? policy.max : 8;\n if (!Number.isFinite(s) || s <= 0) return Math.min(max, Math.max(min, 1));\n return Math.min(max, Math.max(min, Math.pow(2, Math.ceil(Math.log2(s) - 1e-9))));\n}\n\n/**\n * The mip level to draw a surface at: 0 at or above half a screen pixel per surface pixel, then\n * one level per halving (each level halves the resolution), at most `maxLevel`.\n */\nexport function surfaceMipLevel(screenPixelsPerSurfacePixel: number, maxLevel = 4): number {\n const s = screenPixelsPerSurfacePixel;\n if (!(s > 0) || s >= 0.5) return 0;\n return Math.min(maxLevel, Math.floor(Math.log2(1 / s)));\n}\n\n// ---------------------------------------------------------------------------\n// Drawing\n// ---------------------------------------------------------------------------\n\n/** The 2D context `drawSurfaceToViewport` draws on (a canvas 2D context, structurally). */\nexport interface ViewportContext2D {\n drawImage(image: never, dx: number, dy: number, dw: number, dh: number): void;\n imageSmoothingEnabled?: boolean;\n}\n\n/** A canvas the renderer makes tile images on (a canvas element or an offscreen canvas, structurally). */\nexport interface TileCanvasLike {\n getContext(type: '2d'): { createImageData(w: number, h: number): { data: Uint8ClampedArray }; putImageData(image: never, x: number, y: number): void } | null;\n}\n\nexport interface DrawSurfaceOptions {\n /** View area in screen pixels (the canvas's CSS size). */\n width: number;\n height: number;\n /** Highest mip level (default 4: down to 1/16 resolution). */\n maxMipLevel?: number;\n /** Smooth scaling (default: true when zoomed out, false when a surface pixel covers 2+ screen pixels). */\n smoothing?: boolean;\n}\n\nexport interface DrawSurfaceStats {\n level: number;\n /** Tiles drawn (at that level). */\n drawn: number;\n /** Tile images made this call (the rest came from the cache). */\n built: number;\n}\n\n/** Box-filters `n × n` blocks of straight-alpha RGBA (premultiplied while averaging). */\nfunction downsampleInto(src: Uint8ClampedArray, n: number, out: Uint8ClampedArray, ox: number, oy: number): void {\n const side = TILE / n;\n const area = n * n;\n for (let y = 0; y < side; y++) {\n for (let x = 0; x < side; x++) {\n let r = 0, g = 0, b = 0, a = 0;\n for (let dy = 0; dy < n; dy++) {\n let i = ((y * n + dy) * TILE + x * n) * 4;\n for (let dx = 0; dx < n; dx++, i += 4) {\n const al = src[i + 3];\n r += src[i] * al;\n g += src[i + 1] * al;\n b += src[i + 2] * al;\n a += al;\n }\n }\n const o = ((oy + y) * TILE + ox + x) * 4;\n if (a > 0) {\n out[o] = r / a;\n out[o + 1] = g / a;\n out[o + 2] = b / a;\n out[o + 3] = a / area;\n }\n }\n }\n}\n\n/**\n * Draws tiled surfaces onto 2D contexts, keeping a cache of tile images: level-0 images by tile\n * identity (tiles are copy-on-write, so an edited tile is a new object), mip images by the tiles\n * they were built from. One renderer per surface you show; `clear` drops the cache.\n */\nexport class SurfaceViewportRenderer<C extends TileCanvasLike = TileCanvasLike> {\n private readonly base = new WeakMap<Tile, C>();\n private readonly mips = new Map<string, { sources: (Tile | undefined)[]; canvas: C }>();\n private readonly uniform = new Map<number, C>();\n\n /** `createCanvas(256, 256)` makes the tile images (inject a canvas element or offscreen canvas). */\n constructor(private readonly createCanvas: (width: number, height: number) => C) {}\n\n clear(): void {\n this.mips.clear();\n this.uniform.clear();\n }\n\n private image(data: ArrayLike<number>): C | null {\n const canvas = this.createCanvas(TILE, TILE);\n const ctx = canvas.getContext('2d');\n if (!ctx) return null;\n const img = ctx.createImageData(TILE, TILE);\n img.data.set(data);\n ctx.putImageData(img as never, 0, 0);\n return canvas;\n }\n\n private tileImage(tile: Tile): C | null {\n let c = this.base.get(tile);\n if (!c) {\n const img = this.image(tile.data);\n if (!img) return null;\n c = img;\n this.base.set(tile, c);\n }\n return c;\n }\n\n private uniformImage(value: number): C | null {\n let c = this.uniform.get(value);\n if (!c) {\n const data = new Uint8ClampedArray(TILE * TILE * 4);\n for (let i = 0; i < data.length; i += 4) {\n data[i] = (value >>> 24) & 255;\n data[i + 1] = (value >>> 16) & 255;\n data[i + 2] = (value >>> 8) & 255;\n data[i + 3] = value & 255;\n }\n const img = this.image(data);\n if (!img) return null;\n c = img;\n this.uniform.set(value, c);\n }\n return c;\n }\n\n private mipImage(surface: TiledSurface, level: number, mx: number, my: number): C | null {\n const n = 1 << level;\n const sources: (Tile | undefined)[] = [];\n for (let dy = 0; dy < n; dy++) for (let dx = 0; dx < n; dx++) sources.push(surface.tiles.get(tileKey(mx * n + dx, my * n + dy)));\n if (sources.every((t) => !t)) return null;\n const key = `${level}:${mx}:${my}`;\n const hit = this.mips.get(key);\n if (hit && hit.sources.length === sources.length && hit.sources.every((t, i) => t === sources[i])) return hit.canvas;\n const out = new Uint8ClampedArray(TILE * TILE * 4);\n const side = TILE / n;\n const blank = surface.defaultValue ? this.defaultTileData(surface.defaultValue) : null;\n sources.forEach((t, i) => {\n const src = t?.data ?? blank;\n if (src && src.length === TILE * TILE * 4) downsampleInto(src as Uint8ClampedArray, n, out, (i % n) * side, Math.floor(i / n) * side);\n });\n const canvas = this.image(out);\n if (!canvas) return null;\n this.mips.set(key, { sources, canvas });\n return canvas;\n }\n\n private defaultTileData(value: number): Uint8ClampedArray {\n const data = new Uint8ClampedArray(TILE * TILE * 4);\n for (let i = 0; i < data.length; i += 4) {\n data[i] = (value >>> 24) & 255;\n data[i + 1] = (value >>> 16) & 255;\n data[i + 2] = (value >>> 8) & 255;\n data[i + 3] = value & 255;\n }\n return data;\n }\n\n /**\n * Draws the part of an RGBA `surface` (placed by `mapping`) that `view` shows onto `ctx`, tile\n * by tile: only visible tiles, at the mip level the zoom calls for, at whole screen pixels so\n * tiles meet without seams. Does not clear `ctx` first.\n */\n draw(ctx: ViewportContext2D, surface: TiledSurface, mapping: SurfaceMapping, view: ViewTransform, options: DrawSurfaceOptions): DrawSurfaceStats {\n if (surface.channels !== 4) throw new Error('drawSurfaceToViewport draws RGBA surfaces (4 channels).');\n const ppu = ppuOf(mapping);\n const zoom = view.zoom > 0 ? view.zoom : 1;\n const screenPerPixel = zoom / ppu;\n const level = surfaceMipLevel(screenPerPixel, options.maxMipLevel ?? 4);\n const span = TILE << level; // surface pixels per drawn tile\n const visible = visibleSurfaceRect(mapping, view, options.width, options.height);\n const tx0 = Math.floor(visible.x / span);\n const ty0 = Math.floor(visible.y / span);\n const tx1 = Math.floor((visible.x + visible.width - 1) / span);\n const ty1 = Math.floor((visible.y + visible.height - 1) / span);\n ctx.imageSmoothingEnabled = options.smoothing ?? screenPerPixel < 2;\n const ox = (mapping.origin?.x ?? 0) * zoom + view.x;\n const oy = (mapping.origin?.y ?? 0) * zoom + view.y;\n let drawn = 0;\n let built = 0;\n // Visit the grid cells in view, or (zoomed far out over sparse paint) only the cells that hold tiles.\n const keys: Array<[number, number]> = [];\n if (!surface.defaultValue && surface.tiles.size < (tx1 - tx0 + 1) * (ty1 - ty0 + 1)) {\n const seen = new Set<string>();\n for (const key of surface.tiles.keys()) {\n const c = tileCoord(key);\n const mx = Math.floor(c.tx / (1 << level));\n const my = Math.floor(c.ty / (1 << level));\n if (mx < tx0 || mx > tx1 || my < ty0 || my > ty1 || seen.has(`${mx},${my}`)) continue;\n seen.add(`${mx},${my}`);\n keys.push([mx, my]);\n }\n } else {\n for (let ty = ty0; ty <= ty1; ty++) for (let tx = tx0; tx <= tx1; tx++) keys.push([tx, ty]);\n }\n for (const [tx, ty] of keys) {\n let canvas: C | null = null;\n if (level === 0) {\n const tile = surface.tiles.get(tileKey(tx, ty));\n if (tile) {\n const had = this.base.has(tile);\n canvas = this.tileImage(tile);\n if (!had && canvas) built++;\n } else if (surface.defaultValue) canvas = this.uniformImage(surface.defaultValue);\n } else {\n const before = this.mips.size;\n const hitKey = `${level}:${tx}:${ty}`;\n const prev = this.mips.get(hitKey)?.canvas;\n canvas = this.mipImage(surface, level, tx, ty);\n if (canvas && (this.mips.size !== before || canvas !== prev)) built++;\n if (!canvas && surface.defaultValue) canvas = this.uniformImage(surface.defaultValue);\n }\n if (!canvas) continue;\n const sx0 = Math.round(ox + (tx * span * zoom) / ppu);\n const sy0 = Math.round(oy + (ty * span * zoom) / ppu);\n const sx1 = Math.round(ox + ((tx + 1) * span * zoom) / ppu);\n const sy1 = Math.round(oy + ((ty + 1) * span * zoom) / ppu);\n if (sx1 <= sx0 || sy1 <= sy0) continue;\n ctx.drawImage(canvas as never, sx0, sy0, sx1 - sx0, sy1 - sy0);\n drawn++;\n }\n return { level, drawn, built };\n }\n}\n\n/**\n * Draws the visible part of an RGBA `surface` onto `ctx` with a `SurfaceViewportRenderer` (pass\n * the same renderer every frame to reuse its tile images). See `SurfaceViewportRenderer.draw`.\n */\nexport function drawSurfaceToViewport<C extends TileCanvasLike>(\n ctx: ViewportContext2D,\n surface: TiledSurface,\n mapping: SurfaceMapping,\n view: ViewTransform,\n options: DrawSurfaceOptions & { renderer: SurfaceViewportRenderer<C> }\n): DrawSurfaceStats {\n return options.renderer.draw(ctx, surface, mapping, view, options);\n}\n"]}
|
package/dist/raster/index.js
CHANGED
|
@@ -61,7 +61,7 @@ import {
|
|
|
61
61
|
validateLayerEffects,
|
|
62
62
|
warpSurface,
|
|
63
63
|
workingToSamples
|
|
64
|
-
} from "../chunk-
|
|
64
|
+
} from "../chunk-LLFHCSU2.js";
|
|
65
65
|
import "../chunk-GX332W2C.js";
|
|
66
66
|
import {
|
|
67
67
|
BIT_DEPTHS,
|
|
@@ -72,31 +72,38 @@ import {
|
|
|
72
72
|
TILE,
|
|
73
73
|
TILE_SHIFT,
|
|
74
74
|
TiledSurface,
|
|
75
|
+
base64ToBytes,
|
|
75
76
|
blendChannel,
|
|
76
77
|
blendImageData,
|
|
77
78
|
blendLum,
|
|
78
79
|
blendPixel,
|
|
79
80
|
blendRgb,
|
|
81
|
+
bytesToBase64,
|
|
80
82
|
canvasCompositeOperation,
|
|
81
83
|
collectTiles,
|
|
82
84
|
contentBounds,
|
|
83
85
|
convertSurfaceDepth,
|
|
86
|
+
decodePng,
|
|
84
87
|
deepBytes,
|
|
85
88
|
deepTile,
|
|
86
89
|
depthOf,
|
|
87
90
|
emptySurface,
|
|
91
|
+
encodePng,
|
|
88
92
|
fillRect,
|
|
89
93
|
finishTile,
|
|
90
94
|
isBitDepth,
|
|
91
95
|
isBlendMode,
|
|
92
96
|
isPainterlyBlendMode,
|
|
97
|
+
isPng,
|
|
93
98
|
isSeparableBlendMode,
|
|
94
99
|
keepDeepSamples,
|
|
95
100
|
mixPigment8,
|
|
96
101
|
mixPigmentRgb,
|
|
97
102
|
normalizeBlendMode,
|
|
98
103
|
packRgba,
|
|
104
|
+
parseDataUrl,
|
|
99
105
|
pigment8,
|
|
106
|
+
pngDataUrl,
|
|
100
107
|
proxyOf,
|
|
101
108
|
readDeepRegion,
|
|
102
109
|
readPixel,
|
|
@@ -128,16 +135,7 @@ import {
|
|
|
128
135
|
uniformTile,
|
|
129
136
|
writeDeepRegion,
|
|
130
137
|
writeRegion
|
|
131
|
-
} from "../chunk-
|
|
132
|
-
import {
|
|
133
|
-
base64ToBytes,
|
|
134
|
-
bytesToBase64,
|
|
135
|
-
decodePng,
|
|
136
|
-
encodePng,
|
|
137
|
-
isPng,
|
|
138
|
-
parseDataUrl,
|
|
139
|
-
pngDataUrl
|
|
140
|
-
} from "../chunk-7QN76ESJ.js";
|
|
138
|
+
} from "../chunk-3G6J7UFV.js";
|
|
141
139
|
import {
|
|
142
140
|
ZlibError,
|
|
143
141
|
adler32,
|
package/dist/raster/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/raster/viewport.ts"],"sourcesContent":["/**\n * Showing a tiled surface in a pannable, zoomable view (an infinite canvas): world ↔ surface\n * mapping with a resolution policy, the surface rectangle a view can see, and drawing a surface\n * onto a 2D context with visible-tile culling and mip levels. Hosts bring the 2D context and a\n * canvas factory, so this module stays free of any browser API.\n *\n * Coordinates: **world** units are the host's (a node canvas's flow units). **Surface** pixels are\n * the tiled surface's; surface pixel (0, 0) sits at world `origin` and one world unit is\n * `pixelsPerUnit` surface pixels. **Screen** pixels follow the view as xyflow defines it:\n * `screen = world × zoom + (x, y)`.\n */\n\nimport { TILE, tileCoord, tileKey, type RasterRect, type Tile, type TiledSurface } from './surface';\n\n/** Where a surface lies in the world. */\nexport interface SurfaceMapping {\n /** World position of surface pixel (0, 0) (default 0, 0). */\n origin?: { x: number; y: number };\n /** Surface pixels per world unit (default 1). */\n pixelsPerUnit?: number;\n}\n\n/** A pan / zoom view: `screen = world × zoom + (x, y)` (the xyflow viewport). */\nexport interface ViewTransform {\n x: number;\n y: number;\n zoom: number;\n}\n\nconst ppuOf = (m: SurfaceMapping) => (m.pixelsPerUnit && m.pixelsPerUnit > 0 ? m.pixelsPerUnit : 1);\n\n/** A world point in surface pixels. */\nexport function worldToSurface(mapping: SurfaceMapping, x: number, y: number): { x: number; y: number } {\n const k = ppuOf(mapping);\n return { x: (x - (mapping.origin?.x ?? 0)) * k, y: (y - (mapping.origin?.y ?? 0)) * k };\n}\n\n/** A surface pixel position in world units. */\nexport function surfaceToWorld(mapping: SurfaceMapping, x: number, y: number): { x: number; y: number } {\n const k = ppuOf(mapping);\n return { x: x / k + (mapping.origin?.x ?? 0), y: y / k + (mapping.origin?.y ?? 0) };\n}\n\n/** A world rectangle as the whole surface pixels it touches. */\nexport function worldRectToSurface(mapping: SurfaceMapping, rect: { x: number; y: number; width: number; height: number }): RasterRect {\n const a = worldToSurface(mapping, rect.x, rect.y);\n const b = worldToSurface(mapping, rect.x + rect.width, rect.y + rect.height);\n const x = Math.floor(Math.min(a.x, b.x));\n const y = Math.floor(Math.min(a.y, b.y));\n return { x, y, width: Math.ceil(Math.max(a.x, b.x)) - x, height: Math.ceil(Math.max(a.y, b.y)) - y };\n}\n\n/** A screen point (relative to the view's element) in world units. */\nexport function screenToWorld(view: ViewTransform, x: number, y: number): { x: number; y: number } {\n const z = view.zoom > 0 ? view.zoom : 1;\n return { x: (x - view.x) / z, y: (y - view.y) / z };\n}\n\n/** The world rectangle a `width × height` screen area shows. */\nexport function visibleWorldRect(view: ViewTransform, width: number, height: number): { x: number; y: number; width: number; height: number } {\n const a = screenToWorld(view, 0, 0);\n const z = view.zoom > 0 ? view.zoom : 1;\n return { x: a.x, y: a.y, width: width / z, height: height / z };\n}\n\n/** The surface pixels a `width × height` screen area shows (pad by `margin` surface pixels). */\nexport function visibleSurfaceRect(mapping: SurfaceMapping, view: ViewTransform, width: number, height: number, margin = 0): RasterRect {\n const r = worldRectToSurface(mapping, visibleWorldRect(view, width, height));\n return { x: r.x - margin, y: r.y - margin, width: r.width + 2 * margin, height: r.height + 2 * margin };\n}\n\nexport interface ResolutionPolicy {\n /** Screen pixel density (default 1). */\n devicePixelRatio?: number;\n /** Fewest surface pixels per world unit (default 1/4). */\n min?: number;\n /** Most surface pixels per world unit (default 8). */\n max?: number;\n}\n\n/**\n * The surface density (pixels per world unit) for painting at `zoom`: the screen density rounded\n * up to a power of two and clamped, so strokes are never coarser than the screen and nearby\n * zooms share a density. Use it when creating a surface (or a level of one) for the current view.\n */\nexport function surfaceResolutionForZoom(zoom: number, policy: ResolutionPolicy = {}): number {\n const s = zoom * (policy.devicePixelRatio && policy.devicePixelRatio > 0 ? policy.devicePixelRatio : 1);\n const min = policy.min && policy.min > 0 ? policy.min : 1 / 4;\n const max = policy.max && policy.max > 0 ? policy.max : 8;\n if (!Number.isFinite(s) || s <= 0) return Math.min(max, Math.max(min, 1));\n return Math.min(max, Math.max(min, Math.pow(2, Math.ceil(Math.log2(s) - 1e-9))));\n}\n\n/**\n * The mip level to draw a surface at: 0 at or above half a screen pixel per surface pixel, then\n * one level per halving (each level halves the resolution), at most `maxLevel`.\n */\nexport function surfaceMipLevel(screenPixelsPerSurfacePixel: number, maxLevel = 4): number {\n const s = screenPixelsPerSurfacePixel;\n if (!(s > 0) || s >= 0.5) return 0;\n return Math.min(maxLevel, Math.floor(Math.log2(1 / s)));\n}\n\n// ---------------------------------------------------------------------------\n// Drawing\n// ---------------------------------------------------------------------------\n\n/** The 2D context `drawSurfaceToViewport` draws on (a canvas 2D context, structurally). */\nexport interface ViewportContext2D {\n drawImage(image: never, dx: number, dy: number, dw: number, dh: number): void;\n imageSmoothingEnabled?: boolean;\n}\n\n/** A canvas the renderer makes tile images on (a canvas element or an offscreen canvas, structurally). */\nexport interface TileCanvasLike {\n getContext(type: '2d'): { createImageData(w: number, h: number): { data: Uint8ClampedArray }; putImageData(image: never, x: number, y: number): void } | null;\n}\n\nexport interface DrawSurfaceOptions {\n /** View area in screen pixels (the canvas's CSS size). */\n width: number;\n height: number;\n /** Highest mip level (default 4: down to 1/16 resolution). */\n maxMipLevel?: number;\n /** Smooth scaling (default: true when zoomed out, false when a surface pixel covers 2+ screen pixels). */\n smoothing?: boolean;\n}\n\nexport interface DrawSurfaceStats {\n level: number;\n /** Tiles drawn (at that level). */\n drawn: number;\n /** Tile images made this call (the rest came from the cache). */\n built: number;\n}\n\n/** Box-filters `n × n` blocks of straight-alpha RGBA (premultiplied while averaging). */\nfunction downsampleInto(src: Uint8ClampedArray, n: number, out: Uint8ClampedArray, ox: number, oy: number): void {\n const side = TILE / n;\n const area = n * n;\n for (let y = 0; y < side; y++) {\n for (let x = 0; x < side; x++) {\n let r = 0, g = 0, b = 0, a = 0;\n for (let dy = 0; dy < n; dy++) {\n let i = ((y * n + dy) * TILE + x * n) * 4;\n for (let dx = 0; dx < n; dx++, i += 4) {\n const al = src[i + 3];\n r += src[i] * al;\n g += src[i + 1] * al;\n b += src[i + 2] * al;\n a += al;\n }\n }\n const o = ((oy + y) * TILE + ox + x) * 4;\n if (a > 0) {\n out[o] = r / a;\n out[o + 1] = g / a;\n out[o + 2] = b / a;\n out[o + 3] = a / area;\n }\n }\n }\n}\n\n/**\n * Draws tiled surfaces onto 2D contexts, keeping a cache of tile images: level-0 images by tile\n * identity (tiles are copy-on-write, so an edited tile is a new object), mip images by the tiles\n * they were built from. One renderer per surface you show; `clear` drops the cache.\n */\nexport class SurfaceViewportRenderer<C extends TileCanvasLike = TileCanvasLike> {\n private readonly base = new WeakMap<Tile, C>();\n private readonly mips = new Map<string, { sources: (Tile | undefined)[]; canvas: C }>();\n private readonly uniform = new Map<number, C>();\n\n /** `createCanvas(256, 256)` makes the tile images (inject a canvas element or offscreen canvas). */\n constructor(private readonly createCanvas: (width: number, height: number) => C) {}\n\n clear(): void {\n this.mips.clear();\n this.uniform.clear();\n }\n\n private image(data: ArrayLike<number>): C | null {\n const canvas = this.createCanvas(TILE, TILE);\n const ctx = canvas.getContext('2d');\n if (!ctx) return null;\n const img = ctx.createImageData(TILE, TILE);\n img.data.set(data);\n ctx.putImageData(img as never, 0, 0);\n return canvas;\n }\n\n private tileImage(tile: Tile): C | null {\n let c = this.base.get(tile);\n if (!c) {\n const img = this.image(tile.data);\n if (!img) return null;\n c = img;\n this.base.set(tile, c);\n }\n return c;\n }\n\n private uniformImage(value: number): C | null {\n let c = this.uniform.get(value);\n if (!c) {\n const data = new Uint8ClampedArray(TILE * TILE * 4);\n for (let i = 0; i < data.length; i += 4) {\n data[i] = (value >>> 24) & 255;\n data[i + 1] = (value >>> 16) & 255;\n data[i + 2] = (value >>> 8) & 255;\n data[i + 3] = value & 255;\n }\n const img = this.image(data);\n if (!img) return null;\n c = img;\n this.uniform.set(value, c);\n }\n return c;\n }\n\n private mipImage(surface: TiledSurface, level: number, mx: number, my: number): C | null {\n const n = 1 << level;\n const sources: (Tile | undefined)[] = [];\n for (let dy = 0; dy < n; dy++) for (let dx = 0; dx < n; dx++) sources.push(surface.tiles.get(tileKey(mx * n + dx, my * n + dy)));\n if (sources.every((t) => !t)) return null;\n const key = `${level}:${mx}:${my}`;\n const hit = this.mips.get(key);\n if (hit && hit.sources.length === sources.length && hit.sources.every((t, i) => t === sources[i])) return hit.canvas;\n const out = new Uint8ClampedArray(TILE * TILE * 4);\n const side = TILE / n;\n const blank = surface.defaultValue ? this.defaultTileData(surface.defaultValue) : null;\n sources.forEach((t, i) => {\n const src = t?.data ?? blank;\n if (src && src.length === TILE * TILE * 4) downsampleInto(src as Uint8ClampedArray, n, out, (i % n) * side, Math.floor(i / n) * side);\n });\n const canvas = this.image(out);\n if (!canvas) return null;\n this.mips.set(key, { sources, canvas });\n return canvas;\n }\n\n private defaultTileData(value: number): Uint8ClampedArray {\n const data = new Uint8ClampedArray(TILE * TILE * 4);\n for (let i = 0; i < data.length; i += 4) {\n data[i] = (value >>> 24) & 255;\n data[i + 1] = (value >>> 16) & 255;\n data[i + 2] = (value >>> 8) & 255;\n data[i + 3] = value & 255;\n }\n return data;\n }\n\n /**\n * Draws the part of an RGBA `surface` (placed by `mapping`) that `view` shows onto `ctx`, tile\n * by tile: only visible tiles, at the mip level the zoom calls for, at whole screen pixels so\n * tiles meet without seams. Does not clear `ctx` first.\n */\n draw(ctx: ViewportContext2D, surface: TiledSurface, mapping: SurfaceMapping, view: ViewTransform, options: DrawSurfaceOptions): DrawSurfaceStats {\n if (surface.channels !== 4) throw new Error('drawSurfaceToViewport draws RGBA surfaces (4 channels).');\n const ppu = ppuOf(mapping);\n const zoom = view.zoom > 0 ? view.zoom : 1;\n const screenPerPixel = zoom / ppu;\n const level = surfaceMipLevel(screenPerPixel, options.maxMipLevel ?? 4);\n const span = TILE << level; // surface pixels per drawn tile\n const visible = visibleSurfaceRect(mapping, view, options.width, options.height);\n const tx0 = Math.floor(visible.x / span);\n const ty0 = Math.floor(visible.y / span);\n const tx1 = Math.floor((visible.x + visible.width - 1) / span);\n const ty1 = Math.floor((visible.y + visible.height - 1) / span);\n ctx.imageSmoothingEnabled = options.smoothing ?? screenPerPixel < 2;\n const ox = (mapping.origin?.x ?? 0) * zoom + view.x;\n const oy = (mapping.origin?.y ?? 0) * zoom + view.y;\n let drawn = 0;\n let built = 0;\n // Visit the grid cells in view, or (zoomed far out over sparse paint) only the cells that hold tiles.\n const keys: Array<[number, number]> = [];\n if (!surface.defaultValue && surface.tiles.size < (tx1 - tx0 + 1) * (ty1 - ty0 + 1)) {\n const seen = new Set<string>();\n for (const key of surface.tiles.keys()) {\n const c = tileCoord(key);\n const mx = Math.floor(c.tx / (1 << level));\n const my = Math.floor(c.ty / (1 << level));\n if (mx < tx0 || mx > tx1 || my < ty0 || my > ty1 || seen.has(`${mx},${my}`)) continue;\n seen.add(`${mx},${my}`);\n keys.push([mx, my]);\n }\n } else {\n for (let ty = ty0; ty <= ty1; ty++) for (let tx = tx0; tx <= tx1; tx++) keys.push([tx, ty]);\n }\n for (const [tx, ty] of keys) {\n let canvas: C | null = null;\n if (level === 0) {\n const tile = surface.tiles.get(tileKey(tx, ty));\n if (tile) {\n const had = this.base.has(tile);\n canvas = this.tileImage(tile);\n if (!had && canvas) built++;\n } else if (surface.defaultValue) canvas = this.uniformImage(surface.defaultValue);\n } else {\n const before = this.mips.size;\n const hitKey = `${level}:${tx}:${ty}`;\n const prev = this.mips.get(hitKey)?.canvas;\n canvas = this.mipImage(surface, level, tx, ty);\n if (canvas && (this.mips.size !== before || canvas !== prev)) built++;\n if (!canvas && surface.defaultValue) canvas = this.uniformImage(surface.defaultValue);\n }\n if (!canvas) continue;\n const sx0 = Math.round(ox + (tx * span * zoom) / ppu);\n const sy0 = Math.round(oy + (ty * span * zoom) / ppu);\n const sx1 = Math.round(ox + ((tx + 1) * span * zoom) / ppu);\n const sy1 = Math.round(oy + ((ty + 1) * span * zoom) / ppu);\n if (sx1 <= sx0 || sy1 <= sy0) continue;\n ctx.drawImage(canvas as never, sx0, sy0, sx1 - sx0, sy1 - sy0);\n drawn++;\n }\n return { level, drawn, built };\n }\n}\n\n/**\n * Draws the visible part of an RGBA `surface` onto `ctx` with a `SurfaceViewportRenderer` (pass\n * the same renderer every frame to reuse its tile images). See `SurfaceViewportRenderer.draw`.\n */\nexport function drawSurfaceToViewport<C extends TileCanvasLike>(\n ctx: ViewportContext2D,\n surface: TiledSurface,\n mapping: SurfaceMapping,\n view: ViewTransform,\n options: DrawSurfaceOptions & { renderer: SurfaceViewportRenderer<C> }\n): DrawSurfaceStats {\n return options.renderer.draw(ctx, surface, mapping, view, options);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,IAAM,QAAQ,CAAC,MAAuB,EAAE,iBAAiB,EAAE,gBAAgB,IAAI,EAAE,gBAAgB;AAG1F,SAAS,eAAe,SAAyB,GAAW,GAAqC;AACtG,QAAM,IAAI,MAAM,OAAO;AACvB,SAAO,EAAE,IAAI,KAAK,QAAQ,QAAQ,KAAK,MAAM,GAAG,IAAI,KAAK,QAAQ,QAAQ,KAAK,MAAM,EAAE;AACxF;AAGO,SAAS,eAAe,SAAyB,GAAW,GAAqC;AACtG,QAAM,IAAI,MAAM,OAAO;AACvB,SAAO,EAAE,GAAG,IAAI,KAAK,QAAQ,QAAQ,KAAK,IAAI,GAAG,IAAI,KAAK,QAAQ,QAAQ,KAAK,GAAG;AACpF;AAGO,SAAS,mBAAmB,SAAyB,MAA2E;AACrI,QAAM,IAAI,eAAe,SAAS,KAAK,GAAG,KAAK,CAAC;AAChD,QAAM,IAAI,eAAe,SAAS,KAAK,IAAI,KAAK,OAAO,KAAK,IAAI,KAAK,MAAM;AAC3E,QAAM,IAAI,KAAK,MAAM,KAAK,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;AACvC,QAAM,IAAI,KAAK,MAAM,KAAK,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;AACvC,SAAO,EAAE,GAAG,GAAG,OAAO,KAAK,KAAK,KAAK,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,IAAI,GAAG,QAAQ,KAAK,KAAK,KAAK,IAAI,EAAE,GAAG,EAAE,C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;AAC9B,UAAI,UAAU,QAAiB,KAAK,KAAK,MAAM,KAAK,MAAM,GAAG;AAC7D;AAAA,IACF;AACA,WAAO,EAAE,OAAO,OAAO,MAAM;AAAA,EAC/B;AACF;AAMO,SAAS,sBACd,KACA,SACA,SACA,MACA,SACkB;AAClB,SAAO,QAAQ,SAAS,KAAK,KAAK,SAAS,SAAS,MAAM,OAAO;AACnE;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/raster/viewport.ts"],"sourcesContent":["/**\n * Showing a tiled surface in a pannable, zoomable view (an infinite canvas): world ↔ surface\n * mapping with a resolution policy, the surface rectangle a view can see, and drawing a surface\n * onto a 2D context with visible-tile culling and mip levels. Hosts bring the 2D context and a\n * canvas factory, so this module stays free of any browser API.\n *\n * Coordinates: **world** units are the host's (a node canvas's flow units). **Surface** pixels are\n * the tiled surface's; surface pixel (0, 0) sits at world `origin` and one world unit is\n * `pixelsPerUnit` surface pixels. **Screen** pixels follow the view as xyflow defines it:\n * `screen = world × zoom + (x, y)`.\n */\n\nimport { TILE, tileCoord, tileKey, type RasterRect, type Tile, type TiledSurface } from './surface';\n\n/** Where a surface lies in the world. */\nexport interface SurfaceMapping {\n /** World position of surface pixel (0, 0) (default 0, 0). */\n origin?: { x: number; y: number };\n /** Surface pixels per world unit (default 1). */\n pixelsPerUnit?: number;\n}\n\n/** A pan / zoom view: `screen = world × zoom + (x, y)` (the xyflow viewport). */\nexport interface ViewTransform {\n x: number;\n y: number;\n zoom: number;\n}\n\nconst ppuOf = (m: SurfaceMapping) => (m.pixelsPerUnit && m.pixelsPerUnit > 0 ? m.pixelsPerUnit : 1);\n\n/** A world point in surface pixels. */\nexport function worldToSurface(mapping: SurfaceMapping, x: number, y: number): { x: number; y: number } {\n const k = ppuOf(mapping);\n return { x: (x - (mapping.origin?.x ?? 0)) * k, y: (y - (mapping.origin?.y ?? 0)) * k };\n}\n\n/** A surface pixel position in world units. */\nexport function surfaceToWorld(mapping: SurfaceMapping, x: number, y: number): { x: number; y: number } {\n const k = ppuOf(mapping);\n return { x: x / k + (mapping.origin?.x ?? 0), y: y / k + (mapping.origin?.y ?? 0) };\n}\n\n/** A world rectangle as the whole surface pixels it touches. */\nexport function worldRectToSurface(mapping: SurfaceMapping, rect: { x: number; y: number; width: number; height: number }): RasterRect {\n const a = worldToSurface(mapping, rect.x, rect.y);\n const b = worldToSurface(mapping, rect.x + rect.width, rect.y + rect.height);\n const x = Math.floor(Math.min(a.x, b.x));\n const y = Math.floor(Math.min(a.y, b.y));\n return { x, y, width: Math.ceil(Math.max(a.x, b.x)) - x, height: Math.ceil(Math.max(a.y, b.y)) - y };\n}\n\n/** A screen point (relative to the view's element) in world units. */\nexport function screenToWorld(view: ViewTransform, x: number, y: number): { x: number; y: number } {\n const z = view.zoom > 0 ? view.zoom : 1;\n return { x: (x - view.x) / z, y: (y - view.y) / z };\n}\n\n/** The world rectangle a `width × height` screen area shows. */\nexport function visibleWorldRect(view: ViewTransform, width: number, height: number): { x: number; y: number; width: number; height: number } {\n const a = screenToWorld(view, 0, 0);\n const z = view.zoom > 0 ? view.zoom : 1;\n return { x: a.x, y: a.y, width: width / z, height: height / z };\n}\n\n/** The surface pixels a `width × height` screen area shows (pad by `margin` surface pixels). */\nexport function visibleSurfaceRect(mapping: SurfaceMapping, view: ViewTransform, width: number, height: number, margin = 0): RasterRect {\n const r = worldRectToSurface(mapping, visibleWorldRect(view, width, height));\n return { x: r.x - margin, y: r.y - margin, width: r.width + 2 * margin, height: r.height + 2 * margin };\n}\n\nexport interface ResolutionPolicy {\n /** Screen pixel density (default 1). */\n devicePixelRatio?: number;\n /** Fewest surface pixels per world unit (default 1/4). */\n min?: number;\n /** Most surface pixels per world unit (default 8). */\n max?: number;\n}\n\n/**\n * The surface density (pixels per world unit) for painting at `zoom`: the screen density rounded\n * up to a power of two and clamped, so strokes are never coarser than the screen and nearby\n * zooms share a density. Use it when creating a surface (or a level of one) for the current view.\n */\nexport function surfaceResolutionForZoom(zoom: number, policy: ResolutionPolicy = {}): number {\n const s = zoom * (policy.devicePixelRatio && policy.devicePixelRatio > 0 ? policy.devicePixelRatio : 1);\n const min = policy.min && policy.min > 0 ? policy.min : 1 / 4;\n const max = policy.max && policy.max > 0 ? policy.max : 8;\n if (!Number.isFinite(s) || s <= 0) return Math.min(max, Math.max(min, 1));\n return Math.min(max, Math.max(min, Math.pow(2, Math.ceil(Math.log2(s) - 1e-9))));\n}\n\n/**\n * The mip level to draw a surface at: 0 at or above half a screen pixel per surface pixel, then\n * one level per halving (each level halves the resolution), at most `maxLevel`.\n */\nexport function surfaceMipLevel(screenPixelsPerSurfacePixel: number, maxLevel = 4): number {\n const s = screenPixelsPerSurfacePixel;\n if (!(s > 0) || s >= 0.5) return 0;\n return Math.min(maxLevel, Math.floor(Math.log2(1 / s)));\n}\n\n// ---------------------------------------------------------------------------\n// Drawing\n// ---------------------------------------------------------------------------\n\n/** The 2D context `drawSurfaceToViewport` draws on (a canvas 2D context, structurally). */\nexport interface ViewportContext2D {\n drawImage(image: never, dx: number, dy: number, dw: number, dh: number): void;\n imageSmoothingEnabled?: boolean;\n}\n\n/** A canvas the renderer makes tile images on (a canvas element or an offscreen canvas, structurally). */\nexport interface TileCanvasLike {\n getContext(type: '2d'): { createImageData(w: number, h: number): { data: Uint8ClampedArray }; putImageData(image: never, x: number, y: number): void } | null;\n}\n\nexport interface DrawSurfaceOptions {\n /** View area in screen pixels (the canvas's CSS size). */\n width: number;\n height: number;\n /** Highest mip level (default 4: down to 1/16 resolution). */\n maxMipLevel?: number;\n /** Smooth scaling (default: true when zoomed out, false when a surface pixel covers 2+ screen pixels). */\n smoothing?: boolean;\n}\n\nexport interface DrawSurfaceStats {\n level: number;\n /** Tiles drawn (at that level). */\n drawn: number;\n /** Tile images made this call (the rest came from the cache). */\n built: number;\n}\n\n/** Box-filters `n × n` blocks of straight-alpha RGBA (premultiplied while averaging). */\nfunction downsampleInto(src: Uint8ClampedArray, n: number, out: Uint8ClampedArray, ox: number, oy: number): void {\n const side = TILE / n;\n const area = n * n;\n for (let y = 0; y < side; y++) {\n for (let x = 0; x < side; x++) {\n let r = 0, g = 0, b = 0, a = 0;\n for (let dy = 0; dy < n; dy++) {\n let i = ((y * n + dy) * TILE + x * n) * 4;\n for (let dx = 0; dx < n; dx++, i += 4) {\n const al = src[i + 3];\n r += src[i] * al;\n g += src[i + 1] * al;\n b += src[i + 2] * al;\n a += al;\n }\n }\n const o = ((oy + y) * TILE + ox + x) * 4;\n if (a > 0) {\n out[o] = r / a;\n out[o + 1] = g / a;\n out[o + 2] = b / a;\n out[o + 3] = a / area;\n }\n }\n }\n}\n\n/**\n * Draws tiled surfaces onto 2D contexts, keeping a cache of tile images: level-0 images by tile\n * identity (tiles are copy-on-write, so an edited tile is a new object), mip images by the tiles\n * they were built from. One renderer per surface you show; `clear` drops the cache.\n */\nexport class SurfaceViewportRenderer<C extends TileCanvasLike = TileCanvasLike> {\n private readonly base = new WeakMap<Tile, C>();\n private readonly mips = new Map<string, { sources: (Tile | undefined)[]; canvas: C }>();\n private readonly uniform = new Map<number, C>();\n\n /** `createCanvas(256, 256)` makes the tile images (inject a canvas element or offscreen canvas). */\n constructor(private readonly createCanvas: (width: number, height: number) => C) {}\n\n clear(): void {\n this.mips.clear();\n this.uniform.clear();\n }\n\n private image(data: ArrayLike<number>): C | null {\n const canvas = this.createCanvas(TILE, TILE);\n const ctx = canvas.getContext('2d');\n if (!ctx) return null;\n const img = ctx.createImageData(TILE, TILE);\n img.data.set(data);\n ctx.putImageData(img as never, 0, 0);\n return canvas;\n }\n\n private tileImage(tile: Tile): C | null {\n let c = this.base.get(tile);\n if (!c) {\n const img = this.image(tile.data);\n if (!img) return null;\n c = img;\n this.base.set(tile, c);\n }\n return c;\n }\n\n private uniformImage(value: number): C | null {\n let c = this.uniform.get(value);\n if (!c) {\n const data = new Uint8ClampedArray(TILE * TILE * 4);\n for (let i = 0; i < data.length; i += 4) {\n data[i] = (value >>> 24) & 255;\n data[i + 1] = (value >>> 16) & 255;\n data[i + 2] = (value >>> 8) & 255;\n data[i + 3] = value & 255;\n }\n const img = this.image(data);\n if (!img) return null;\n c = img;\n this.uniform.set(value, c);\n }\n return c;\n }\n\n private mipImage(surface: TiledSurface, level: number, mx: number, my: number): C | null {\n const n = 1 << level;\n const sources: (Tile | undefined)[] = [];\n for (let dy = 0; dy < n; dy++) for (let dx = 0; dx < n; dx++) sources.push(surface.tiles.get(tileKey(mx * n + dx, my * n + dy)));\n if (sources.every((t) => !t)) return null;\n const key = `${level}:${mx}:${my}`;\n const hit = this.mips.get(key);\n if (hit && hit.sources.length === sources.length && hit.sources.every((t, i) => t === sources[i])) return hit.canvas;\n const out = new Uint8ClampedArray(TILE * TILE * 4);\n const side = TILE / n;\n const blank = surface.defaultValue ? this.defaultTileData(surface.defaultValue) : null;\n sources.forEach((t, i) => {\n const src = t?.data ?? blank;\n if (src && src.length === TILE * TILE * 4) downsampleInto(src as Uint8ClampedArray, n, out, (i % n) * side, Math.floor(i / n) * side);\n });\n const canvas = this.image(out);\n if (!canvas) return null;\n this.mips.set(key, { sources, canvas });\n return canvas;\n }\n\n private defaultTileData(value: number): Uint8ClampedArray {\n const data = new Uint8ClampedArray(TILE * TILE * 4);\n for (let i = 0; i < data.length; i += 4) {\n data[i] = (value >>> 24) & 255;\n data[i + 1] = (value >>> 16) & 255;\n data[i + 2] = (value >>> 8) & 255;\n data[i + 3] = value & 255;\n }\n return data;\n }\n\n /**\n * Draws the part of an RGBA `surface` (placed by `mapping`) that `view` shows onto `ctx`, tile\n * by tile: only visible tiles, at the mip level the zoom calls for, at whole screen pixels so\n * tiles meet without seams. Does not clear `ctx` first.\n */\n draw(ctx: ViewportContext2D, surface: TiledSurface, mapping: SurfaceMapping, view: ViewTransform, options: DrawSurfaceOptions): DrawSurfaceStats {\n if (surface.channels !== 4) throw new Error('drawSurfaceToViewport draws RGBA surfaces (4 channels).');\n const ppu = ppuOf(mapping);\n const zoom = view.zoom > 0 ? view.zoom : 1;\n const screenPerPixel = zoom / ppu;\n const level = surfaceMipLevel(screenPerPixel, options.maxMipLevel ?? 4);\n const span = TILE << level; // surface pixels per drawn tile\n const visible = visibleSurfaceRect(mapping, view, options.width, options.height);\n const tx0 = Math.floor(visible.x / span);\n const ty0 = Math.floor(visible.y / span);\n const tx1 = Math.floor((visible.x + visible.width - 1) / span);\n const ty1 = Math.floor((visible.y + visible.height - 1) / span);\n ctx.imageSmoothingEnabled = options.smoothing ?? screenPerPixel < 2;\n const ox = (mapping.origin?.x ?? 0) * zoom + view.x;\n const oy = (mapping.origin?.y ?? 0) * zoom + view.y;\n let drawn = 0;\n let built = 0;\n // Visit the grid cells in view, or (zoomed far out over sparse paint) only the cells that hold tiles.\n const keys: Array<[number, number]> = [];\n if (!surface.defaultValue && surface.tiles.size < (tx1 - tx0 + 1) * (ty1 - ty0 + 1)) {\n const seen = new Set<string>();\n for (const key of surface.tiles.keys()) {\n const c = tileCoord(key);\n const mx = Math.floor(c.tx / (1 << level));\n const my = Math.floor(c.ty / (1 << level));\n if (mx < tx0 || mx > tx1 || my < ty0 || my > ty1 || seen.has(`${mx},${my}`)) continue;\n seen.add(`${mx},${my}`);\n keys.push([mx, my]);\n }\n } else {\n for (let ty = ty0; ty <= ty1; ty++) for (let tx = tx0; tx <= tx1; tx++) keys.push([tx, ty]);\n }\n for (const [tx, ty] of keys) {\n let canvas: C | null = null;\n if (level === 0) {\n const tile = surface.tiles.get(tileKey(tx, ty));\n if (tile) {\n const had = this.base.has(tile);\n canvas = this.tileImage(tile);\n if (!had && canvas) built++;\n } else if (surface.defaultValue) canvas = this.uniformImage(surface.defaultValue);\n } else {\n const before = this.mips.size;\n const hitKey = `${level}:${tx}:${ty}`;\n const prev = this.mips.get(hitKey)?.canvas;\n canvas = this.mipImage(surface, level, tx, ty);\n if (canvas && (this.mips.size !== before || canvas !== prev)) built++;\n if (!canvas && surface.defaultValue) canvas = this.uniformImage(surface.defaultValue);\n }\n if (!canvas) continue;\n const sx0 = Math.round(ox + (tx * span * zoom) / ppu);\n const sy0 = Math.round(oy + (ty * span * zoom) / ppu);\n const sx1 = Math.round(ox + ((tx + 1) * span * zoom) / ppu);\n const sy1 = Math.round(oy + ((ty + 1) * span * zoom) / ppu);\n if (sx1 <= sx0 || sy1 <= sy0) continue;\n ctx.drawImage(canvas as never, sx0, sy0, sx1 - sx0, sy1 - sy0);\n drawn++;\n }\n return { level, drawn, built };\n }\n}\n\n/**\n * Draws the visible part of an RGBA `surface` onto `ctx` with a `SurfaceViewportRenderer` (pass\n * the same renderer every frame to reuse its tile images). See `SurfaceViewportRenderer.draw`.\n */\nexport function drawSurfaceToViewport<C extends TileCanvasLike>(\n ctx: ViewportContext2D,\n surface: TiledSurface,\n mapping: SurfaceMapping,\n view: ViewTransform,\n options: DrawSurfaceOptions & { renderer: SurfaceViewportRenderer<C> }\n): DrawSurfaceStats {\n return options.renderer.draw(ctx, surface, mapping, view, options);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,IAAM,QAAQ,CAAC,MAAuB,EAAE,iBAAiB,EAAE,gBAAgB,IAAI,EAAE,gBAAgB;AAG1F,SAAS,eAAe,SAAyB,GAAW,GAAqC;AACtG,QAAM,IAAI,MAAM,OAAO;AACvB,SAAO,EAAE,IAAI,KAAK,QAAQ,QAAQ,KAAK,MAAM,GAAG,IAAI,KAAK,QAAQ,QAAQ,KAAK,MAAM,EAAE;AACxF;AAGO,SAAS,eAAe,SAAyB,GAAW,GAAqC;AACtG,QAAM,IAAI,MAAM,OAAO;AACvB,SAAO,EAAE,GAAG,IAAI,KAAK,QAAQ,QAAQ,KAAK,IAAI,GAAG,IAAI,KAAK,QAAQ,QAAQ,KAAK,GAAG;AACpF;AAGO,SAAS,mBAAmB,SAAyB,MAA2E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K,KAAK,SAAS,UAAU,WAAW,MAAO;AAC9D,YAAI,CAAC,UAAU,QAAQ,aAAc,UAAS,KAAK,aAAa,QAAQ,YAAY;AAAA,MACtF;AACA,UAAI,CAAC,OAAQ;AACb,YAAM,MAAM,KAAK,MAAM,KAAM,KAAK,OAAO,OAAQ,GAAG;AACpD,YAAM,MAAM,KAAK,MAAM,KAAM,KAAK,OAAO,OAAQ,GAAG;AACpD,YAAM,MAAM,KAAK,MAAM,MAAO,KAAK,KAAK,OAAO,OAAQ,GAAG;AAC1D,YAAM,MAAM,KAAK,MAAM,MAAO,KAAK,KAAK,OAAO,OAAQ,GAAG;AAC1D,UAAI,OAAO,OAAO,OAAO,IAAK;AAC9B,UAAI,UAAU,QAAiB,KAAK,KAAK,MAAM,KAAK,MAAM,GAAG;AAC7D;AAAA,IACF;AACA,WAAO,EAAE,OAAO,OAAO,MAAM;AAAA,EAC/B;AACF;AAMO,SAAS,sBACd,KACA,SACA,SACA,MACA,SACkB;AAClB,SAAO,QAAQ,SAAS,KAAK,KAAK,SAAS,SAAS,MAAM,OAAO;AACnE;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as BezierPath, A as AffineMatrix } from './bezier-
|
|
2
|
-
import { V as VectorEffectType, H as VectorEffectParamsMap, I as VectorPathNode, J as VectorFillRule, K as VectorBooleanOperation, L as VectorNode, M as VectorEffect, N as VectorGroupNode, O as VectorBounds, P as VectorWarpMesh, Q as VectorInstanceNode, R as VectorFilterType, T as VectorFilterParamsMap, U as VectorFilter, W as VectorGradient, X as Vec2, Y as VectorGradientUnits, S as SvgGradientDef, Z as VectorGradientSpread, _ as VectorGradientType, $ as VectorPaint, a0 as VectorMatrix, a1 as VectorGradientStop, a2 as VectorStrokeAlign, a3 as VectorSubpath, a4 as VectorDocument, a5 as VectorWidthPoint } from './helpers
|
|
1
|
+
import { B as BezierPath, A as AffineMatrix } from './bezier-Dywv3Bw8.js';
|
|
2
|
+
import { V as VectorEffectType, H as VectorEffectParamsMap, I as VectorPathNode, J as VectorFillRule, K as VectorBooleanOperation, L as VectorNode, M as VectorEffect, N as VectorGroupNode, O as VectorBounds, P as VectorWarpMesh, Q as VectorInstanceNode, R as VectorFilterType, T as VectorFilterParamsMap, U as VectorFilter, W as VectorGradient, X as Vec2, Y as VectorGradientUnits, S as SvgGradientDef, Z as VectorGradientSpread, _ as VectorGradientType, $ as VectorPaint, a0 as VectorMatrix, a1 as VectorGradientStop, a2 as VectorStrokeAlign, a3 as VectorSubpath, a4 as VectorDocument, a5 as VectorWidthPoint } from './helpers-C-RgeyvH.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Live appearance: path effect stacks and live boolean groups, evaluated on demand while the
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as BezierPath, A as AffineMatrix } from './bezier-
|
|
2
|
-
import { V as VectorEffectType, H as VectorEffectParamsMap, I as VectorPathNode, J as VectorFillRule, K as VectorBooleanOperation, L as VectorNode, M as VectorEffect, N as VectorGroupNode, O as VectorBounds, P as VectorWarpMesh, Q as VectorInstanceNode, R as VectorFilterType, T as VectorFilterParamsMap, U as VectorFilter, W as VectorGradient, X as Vec2, Y as VectorGradientUnits, S as SvgGradientDef, Z as VectorGradientSpread, _ as VectorGradientType, $ as VectorPaint, a0 as VectorMatrix, a1 as VectorGradientStop, a2 as VectorStrokeAlign, a3 as VectorSubpath, a4 as VectorDocument, a5 as VectorWidthPoint } from './helpers-
|
|
1
|
+
import { B as BezierPath, A as AffineMatrix } from './bezier-CZ2AhjID.cjs';
|
|
2
|
+
import { V as VectorEffectType, H as VectorEffectParamsMap, I as VectorPathNode, J as VectorFillRule, K as VectorBooleanOperation, L as VectorNode, M as VectorEffect, N as VectorGroupNode, O as VectorBounds, P as VectorWarpMesh, Q as VectorInstanceNode, R as VectorFilterType, T as VectorFilterParamsMap, U as VectorFilter, W as VectorGradient, X as Vec2, Y as VectorGradientUnits, S as SvgGradientDef, Z as VectorGradientSpread, _ as VectorGradientType, $ as VectorPaint, a0 as VectorMatrix, a1 as VectorGradientStop, a2 as VectorStrokeAlign, a3 as VectorSubpath, a4 as VectorDocument, a5 as VectorWidthPoint } from './helpers-v6GMazzg.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Live appearance: path effect stacks and live boolean groups, evaluated on demand while the
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { A as AgentTool, a as AgentToolProvider } from './registry-D-4fit9C.js';
|
|
2
2
|
import { J as JsonSchema } from './schema-Di0CS6Pe.js';
|
|
3
|
-
import { E as EffectProvider, c as EffectUse } from './helpers
|
|
3
|
+
import { E as EffectProvider, c as EffectUse } from './helpers-C-RgeyvH.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The agent tools for provider effects, shared by every editor that takes an `EffectProvider`:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { A as AgentTool, a as AgentToolProvider } from './registry-BqA1AZt0.cjs';
|
|
2
2
|
import { J as JsonSchema } from './schema-Di0CS6Pe.cjs';
|
|
3
|
-
import { E as EffectProvider, c as EffectUse } from './helpers-
|
|
3
|
+
import { E as EffectProvider, c as EffectUse } from './helpers-v6GMazzg.cjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The agent tools for provider effects, shared by every editor that takes an `EffectProvider`:
|