@weasel-js/core 1.8.1 → 1.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +68 -0
- package/README.md +9 -5
- package/dist/{builtins-CMEh6-Oc.d.ts → builtins-CQcvcLXh.d.ts} +98 -31
- package/dist/canvas/DrawCanvas.js +33 -33
- package/dist/canvas/DrawCanvas.js.map +1 -1
- package/dist/canvas/MinimapCanvas.js +29 -29
- package/dist/canvas/MinimapCanvas.js.map +1 -1
- package/dist/canvas/NodeShape.js +63 -54
- package/dist/canvas/NodeShape.js.map +1 -1
- package/dist/canvas/SceneCanvas/features.js +26 -5
- package/dist/canvas/SceneCanvas/features.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneSelectTool.js +3 -2
- package/dist/canvas/SceneCanvas/useSceneSelectTool.js.map +1 -1
- package/dist/canvas/SceneCanvas.js +526 -529
- package/dist/canvas/SceneCanvas.js.map +1 -1
- package/dist/canvas/SceneViewCanvas.js +35 -35
- package/dist/canvas/SceneViewCanvas.js.map +1 -1
- package/dist/canvas/defaultDrawOne.js +6 -1
- package/dist/canvas/defaultDrawOne.js.map +1 -1
- package/dist/canvas/pickWalk.js.map +1 -1
- package/dist/canvas/sceneAdapter.js.map +1 -1
- package/dist/canvas/useHitObserver.js +23 -0
- package/dist/canvas/useHitObserver.js.map +1 -0
- package/dist/canvas/useHostAnchor.js.map +1 -1
- package/dist/core/device/useDeviceProfile.js.map +1 -1
- package/dist/core/scene/derivedPath.js.map +1 -1
- package/dist/core/scene/effectivePose.js.map +1 -1
- package/dist/core/scene/kitRegistry.js.map +1 -1
- package/dist/core/scene/scene.js.map +1 -1
- package/dist/core/scene/types.js.map +1 -1
- package/dist/core/scene/useScene.js.map +1 -1
- package/dist/core/viewport/fitViewToBounds.js +3 -3
- package/dist/core/viewport/fitViewToBounds.js.map +1 -1
- package/dist/core/viewport/screenSlop.js +8 -2
- package/dist/core/viewport/screenSlop.js.map +1 -1
- package/dist/features/minimap/actions.js.map +1 -1
- package/dist/features/paths/markerCommands.js +95 -63
- package/dist/features/paths/markerCommands.js.map +1 -1
- package/dist/features/paths/tessellate/dash.js +52 -0
- package/dist/features/paths/tessellate/dash.js.map +1 -0
- package/dist/features/paths/tessellate/insets.js +32 -0
- package/dist/features/paths/tessellate/insets.js.map +1 -0
- package/dist/features/paths/tessellate/metric.js +72 -0
- package/dist/features/paths/tessellate/metric.js.map +1 -0
- package/dist/features/paths/tessellate/stroke.js +74 -134
- package/dist/features/paths/tessellate/stroke.js.map +1 -1
- package/dist/features/paths/tessellate/vertexWidths.js +32 -0
- package/dist/features/paths/tessellate/vertexWidths.js.map +1 -0
- package/dist/features/pointer/PointerContext.js +2 -2
- package/dist/features/pointer/PointerContext.js.map +1 -1
- package/dist/features/poseRun/usePoseRun.js.map +1 -1
- package/dist/features/text/useTextEdit.js +86 -84
- package/dist/features/text/useTextEdit.js.map +1 -1
- package/dist/index.d.ts +78 -39
- package/dist/index.js +148 -148
- package/dist/interactions/actions/defaults/align.js.map +1 -1
- package/dist/interactions/actions/defaults/anchorEditing.js.map +1 -1
- package/dist/interactions/actions/defaults/areaSelect.js.map +1 -1
- package/dist/interactions/actions/defaults/booleans.js.map +1 -1
- package/dist/interactions/actions/defaults/cancelGesture.js.map +1 -1
- package/dist/interactions/actions/defaults/clearSelection.js.map +1 -1
- package/dist/interactions/actions/defaults/clipboard.js.map +1 -1
- package/dist/interactions/actions/defaults/clone.js.map +1 -1
- package/dist/interactions/actions/defaults/createOutlines.js +1 -1
- package/dist/interactions/actions/defaults/createOutlines.js.map +1 -1
- package/dist/interactions/actions/defaults/createPaintAction.js.map +1 -1
- package/dist/interactions/actions/defaults/delete.js.map +1 -1
- package/dist/interactions/actions/defaults/distribute.js.map +1 -1
- package/dist/interactions/actions/defaults/duplicate.js.map +1 -1
- package/dist/interactions/actions/defaults/editAnchors.js.map +1 -1
- package/dist/interactions/actions/defaults/enterPathEdit.js.map +1 -1
- package/dist/interactions/actions/defaults/enterTextEdit.js.map +1 -1
- package/dist/interactions/actions/defaults/escape.js +1 -1
- package/dist/interactions/actions/defaults/escape.js.map +1 -1
- package/dist/interactions/actions/defaults/exitPathEdit.js.map +1 -1
- package/dist/interactions/actions/defaults/flip.js.map +1 -1
- package/dist/interactions/actions/defaults/group.js.map +1 -1
- package/dist/interactions/actions/defaults/ingest.js.map +1 -1
- package/dist/interactions/actions/defaults/insert.js.map +1 -1
- package/dist/interactions/actions/defaults/insertPathAnchor.js +1 -1
- package/dist/interactions/actions/defaults/insertPathAnchor.js.map +1 -1
- package/dist/interactions/actions/defaults/lassoSelect.js.map +1 -1
- package/dist/interactions/actions/defaults/move.js.map +1 -1
- package/dist/interactions/actions/defaults/nudge.js.map +1 -1
- package/dist/interactions/actions/defaults/pinchZoom.js.map +1 -1
- package/dist/interactions/actions/defaults/reorder.js.map +1 -1
- package/dist/interactions/actions/defaults/requiresSelection.js.map +1 -1
- package/dist/interactions/actions/defaults/resize.js.map +1 -1
- package/dist/interactions/actions/defaults/rotate.js.map +1 -1
- package/dist/interactions/actions/defaults/selectAll.js.map +1 -1
- package/dist/interactions/actions/defaults/slice.js.map +1 -1
- package/dist/interactions/actions/defaults/toolActivate.js.map +1 -1
- package/dist/interactions/actions/defaults/toolResetToDefault.js.map +1 -1
- package/dist/interactions/actions/defaults/undoRedo.js +1 -1
- package/dist/interactions/actions/defaults/undoRedo.js.map +1 -1
- package/dist/interactions/actions/defaults/viewportDragPan.js.map +1 -1
- package/dist/interactions/actions/defaults/viewportWheelPan.js.map +1 -1
- package/dist/interactions/actions/defaults/viewportZoom.js.map +1 -1
- package/dist/interactions/actions/planeInput.js.map +1 -1
- package/dist/interactions/gestures/shared/screenTolerance.js.map +1 -1
- package/dist/{registerProgram-ateHDGjw.d.ts → registerProgram-BMZRDgrh.d.ts} +4 -0
- package/dist/renderer/cache/markerCommandCache.js +46 -42
- package/dist/renderer/cache/markerCommandCache.js.map +1 -1
- package/dist/renderer/cache/outlineStrokeMeshCache.js +30 -25
- package/dist/renderer/cache/outlineStrokeMeshCache.js.map +1 -1
- package/dist/renderer/cache/strokeMeshCache.js +42 -31
- package/dist/renderer/cache/strokeMeshCache.js.map +1 -1
- package/dist/renderer/cullDrawCommands.js +32 -31
- package/dist/renderer/cullDrawCommands.js.map +1 -1
- package/dist/renderer/draw.js +315 -362
- package/dist/renderer/draw.js.map +1 -1
- package/dist/renderer/glyphOutlineMesh.js +67 -0
- package/dist/renderer/glyphOutlineMesh.js.map +1 -0
- package/dist/renderer/math/mat3.js +8 -3
- package/dist/renderer/math/mat3.js.map +1 -1
- package/dist/renderer/strokeLengths.js +50 -0
- package/dist/renderer/strokeLengths.js.map +1 -0
- package/dist/renderer.d.ts +2 -2
- package/dist/{test-seams-fYf6m5pu.d.ts → test-seams-CuIxe0xY.d.ts} +1 -1
- package/dist/test-seams.d.ts +2 -2
- package/dist/tools/builtin/eyedropper/useEyedropperTool.js.map +1 -1
- package/dist/tools/builtin/pen/usePenTool.js +1 -1
- package/dist/tools/builtin/pen/usePenTool.js.map +1 -1
- package/dist/tools/builtin/select/selectionContributions.js +43 -23
- package/dist/tools/builtin/select/selectionContributions.js.map +1 -1
- package/dist/tools/builtin/select/useSelectTool.js.map +1 -1
- package/dist/tools/builtin/slice/useSliceTool.js.map +1 -1
- package/dist/version.js +1 -1
- package/package.json +17 -17
package/dist/renderer/draw.js
CHANGED
|
@@ -8,30 +8,30 @@ import { getPaintKind as l } from "../core/paintKinds.js";
|
|
|
8
8
|
import { SPRITE_STRIDE as u } from "./DrawCommand.js";
|
|
9
9
|
import { patternTileSpace as d } from "./math/patternSpace.js";
|
|
10
10
|
import { getMesh as f } from "./cache/cache.js";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
11
|
+
import { metricKeepsRects as p } from "../features/paths/tessellate/metric.js";
|
|
12
|
+
import { resolveStrokeWidth as m } from "../features/paths/tessellate/stroke.js";
|
|
13
|
+
import { strokeMesh as h } from "./cache/strokeMeshCache.js";
|
|
14
|
+
import { SYNTHETIC_ITALIC_RADIANS as g } from "./syntheticItalic.js";
|
|
15
|
+
import { outlineGroupMesh as _, outlineGroupStrokeMesh as v } from "./glyphOutlineMesh.js";
|
|
16
|
+
import { resolveStrokeLengths as y } from "./strokeLengths.js";
|
|
16
17
|
import { cachedMarkerCommands as b } from "./cache/markerCommandCache.js";
|
|
17
18
|
import { axisAlignedClipRect as ee, intersectClipRects as x } from "./batchClip.js";
|
|
18
19
|
import { COMPOSITE_PROGRAM_ID as S } from "./effects/composite.js";
|
|
19
|
-
import {
|
|
20
|
-
import { GLYPH_MODE_MSDF as C, GLYPH_MODE_R8 as ne, dynamicPageTextureId as re, ensureFontTexture as ie, glyphFieldScale as ae, syncDynamicPageTexture as oe, textureCacheKey as se } from "@weasel-js/font";
|
|
20
|
+
import { GLYPH_MODE_MSDF as te, GLYPH_MODE_R8 as ne, dynamicPageTextureId as re, ensureFontTexture as ie, glyphFieldScale as ae, syncDynamicPageTexture as oe, textureCacheKey as se } from "@weasel-js/font";
|
|
21
21
|
import { cachedLayoutRuns as ce, resolveTextStyle as le, verticalAlignOffset as ue } from "@weasel-js/text";
|
|
22
22
|
import { tessellate as de } from "@weasel-js/geom/tessellate";
|
|
23
23
|
//#region src/renderer/draw.ts
|
|
24
|
-
function
|
|
24
|
+
function C(e, t, n) {
|
|
25
25
|
e.gl.drawElements(e.gl.TRIANGLES, t, n, 0), e.stats && e.stats.drawCalls++;
|
|
26
26
|
}
|
|
27
27
|
var fe = /* @__PURE__ */ new WeakMap(), pe = /* @__PURE__ */ new WeakMap();
|
|
28
|
-
function
|
|
28
|
+
function w(e, t) {
|
|
29
29
|
let n = fe.get(e);
|
|
30
30
|
n || (n = /* @__PURE__ */ new WeakMap(), fe.set(e, n));
|
|
31
31
|
let r = n.get(t);
|
|
32
32
|
return r || (r = {}, n.set(t, r)), r;
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function T(e, t) {
|
|
35
35
|
if (e === void 0 || e.length !== t.length) return !1;
|
|
36
36
|
for (let n = 0; n < e.length; n++) if (e[n] !== t[n]) return !1;
|
|
37
37
|
return !0;
|
|
@@ -39,7 +39,7 @@ function E(e, t) {
|
|
|
39
39
|
function me(e, t, n, r, i, a) {
|
|
40
40
|
let o = t.uniform("u_color");
|
|
41
41
|
if (o === void 0) return;
|
|
42
|
-
let s =
|
|
42
|
+
let s = w(e, t), c = s.color;
|
|
43
43
|
(c === void 0 || c[0] !== n || c[1] !== r || c[2] !== i || c[3] !== a) && (e.gl.uniform4f(o, n, r, i, a), s.color = [
|
|
44
44
|
n,
|
|
45
45
|
r,
|
|
@@ -47,23 +47,23 @@ function me(e, t, n, r, i, a) {
|
|
|
47
47
|
a
|
|
48
48
|
]);
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function E(e, t, n) {
|
|
51
51
|
let r = t.uniform("u_alpha");
|
|
52
52
|
if (r === void 0) return;
|
|
53
|
-
let i =
|
|
53
|
+
let i = w(e, t);
|
|
54
54
|
i.alpha !== n && (e.gl.uniform1f(r, n), i.alpha = n);
|
|
55
55
|
}
|
|
56
|
-
var
|
|
56
|
+
var D = o.identity();
|
|
57
57
|
function he(e) {
|
|
58
58
|
let t = pe.get(e);
|
|
59
59
|
return t || (t = o.screenToClip(e.widthCss, e.heightCss), pe.set(e, t)), t;
|
|
60
60
|
}
|
|
61
|
-
var
|
|
62
|
-
function
|
|
63
|
-
let r = e.gl, i =
|
|
61
|
+
var O = /* @__PURE__ */ new Float32Array(16);
|
|
62
|
+
function k(e, t, n = e.state.colorMatrix) {
|
|
63
|
+
let r = e.gl, i = w(e, t), a = t.uniform("u_colorMatrix");
|
|
64
64
|
if (a !== void 0) {
|
|
65
|
-
for (let e = 0; e < 4; e++) for (let t = 0; t < 4; t++)
|
|
66
|
-
|
|
65
|
+
for (let e = 0; e < 4; e++) for (let t = 0; t < 4; t++) O[t * 4 + e] = n[e * 5 + t];
|
|
66
|
+
T(i.colorMatrix, O) || (r.uniformMatrix4fv(a, !1, O), i.colorMatrix = Float32Array.from(O));
|
|
67
67
|
}
|
|
68
68
|
let o = t.uniform("u_colorBias");
|
|
69
69
|
if (o !== void 0) {
|
|
@@ -73,7 +73,7 @@ function A(e, t, n = e.state.colorMatrix) {
|
|
|
73
73
|
n[14],
|
|
74
74
|
n[19]
|
|
75
75
|
];
|
|
76
|
-
|
|
76
|
+
T(i.colorBias, e) || (r.uniform4f(o, e[0], e[1], e[2], e[3]), i.colorBias = Float32Array.from(e));
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
function ge(e, t) {
|
|
@@ -85,22 +85,22 @@ function _e(e, t) {
|
|
|
85
85
|
function ve(e, t) {
|
|
86
86
|
return _e(e, ge(e, t));
|
|
87
87
|
}
|
|
88
|
-
function
|
|
88
|
+
function A(e, t) {
|
|
89
89
|
switch (t.kind) {
|
|
90
|
-
case "group": return
|
|
91
|
-
case "path": return
|
|
92
|
-
case "text": return
|
|
93
|
-
case "image": return
|
|
94
|
-
case "sprites": return
|
|
95
|
-
case "shader": return
|
|
90
|
+
case "group": return Ae(e, t);
|
|
91
|
+
case "path": return Fe(e, t);
|
|
92
|
+
case "text": return Dt(e, t);
|
|
93
|
+
case "image": return Vt(e, t);
|
|
94
|
+
case "sprites": return Ht(e, t);
|
|
95
|
+
case "shader": return F(e), Ee(e, t);
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
-
var
|
|
99
|
-
function
|
|
98
|
+
var ye = /* @__PURE__ */ new Set();
|
|
99
|
+
function be(e, t) {
|
|
100
100
|
let n = `${e}:${t}`;
|
|
101
|
-
|
|
101
|
+
ye.has(n) || (ye.add(n), (typeof process > "u" || process.env.NODE_ENV !== "production") && console.warn(`weasel drawShader: uniform "${t}" not found in program "${e}". Check spelling, ensure it's used in the shader (unused uniforms are optimized away by the driver).`));
|
|
102
102
|
}
|
|
103
|
-
function
|
|
103
|
+
function xe(e, t, n, r, i) {
|
|
104
104
|
if (typeof n == "object" && n && !Array.isArray(n) && !(n instanceof Float32Array) && "id" in n && typeof n.id == "string") {
|
|
105
105
|
let a = n, o = c(a.id);
|
|
106
106
|
if (!o) {
|
|
@@ -138,7 +138,7 @@ function Se(e, t, n, r, i) {
|
|
|
138
138
|
return;
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
-
var
|
|
141
|
+
var Se = {
|
|
142
142
|
float: {
|
|
143
143
|
fn: "uniform1fv",
|
|
144
144
|
n: 1
|
|
@@ -264,11 +264,11 @@ var Ce = {
|
|
|
264
264
|
matrix: !0
|
|
265
265
|
}
|
|
266
266
|
};
|
|
267
|
-
function
|
|
267
|
+
function Ce(e) {
|
|
268
268
|
return Array.isArray(e) || e instanceof Float32Array || e instanceof Int32Array || e instanceof Uint32Array;
|
|
269
269
|
}
|
|
270
|
-
function
|
|
271
|
-
let i = typeof process < "u" ? process.env.NODE_ENV !== "production" : !0, a =
|
|
270
|
+
function we(e, t, n, r) {
|
|
271
|
+
let i = typeof process < "u" ? process.env.NODE_ENV !== "production" : !0, a = Se[n.type];
|
|
272
272
|
if (!a) {
|
|
273
273
|
i && console.warn(`weasel setUniform: array uniform "${t}" has type ${n.type}, which cannot be written as a whole`);
|
|
274
274
|
return;
|
|
@@ -281,22 +281,22 @@ function Te(e, t, n, r) {
|
|
|
281
281
|
let o = e[a.fn];
|
|
282
282
|
a.matrix ? o.call(e, n.location, !1, r) : o.call(e, n.location, r);
|
|
283
283
|
}
|
|
284
|
-
function
|
|
284
|
+
function Te(e, t, n, r, i, a) {
|
|
285
285
|
for (let [o, s] of Object.entries(r)) {
|
|
286
286
|
let r = t.uniformArray(o);
|
|
287
|
-
if (r &&
|
|
288
|
-
|
|
287
|
+
if (r && Ce(s)) {
|
|
288
|
+
we(e, o, r, s);
|
|
289
289
|
continue;
|
|
290
290
|
}
|
|
291
291
|
let c = t.uniform(o);
|
|
292
292
|
if (c === void 0) {
|
|
293
|
-
|
|
293
|
+
be(n, o);
|
|
294
294
|
continue;
|
|
295
295
|
}
|
|
296
|
-
|
|
296
|
+
xe(e, c, s, i, a);
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
|
-
function
|
|
299
|
+
function Ee(e, t) {
|
|
300
300
|
let { gl: n, programRegistry: r, quadVbo: i, quadIbo: a, textureCache: s } = e, c = r.get(t.program.id);
|
|
301
301
|
if (!c) {
|
|
302
302
|
console.warn(`weasel drawShader: program "${t.program.id}" not compiled on this renderer. Call renderer.registerProgram(handle) after the module-level registerProgram().`);
|
|
@@ -314,36 +314,36 @@ function De(e, t) {
|
|
|
314
314
|
let p = c.uniform("u_bounds");
|
|
315
315
|
p !== void 0 && n.uniform4f(p, t.bounds.x, t.bounds.y, t.bounds.w, t.bounds.h);
|
|
316
316
|
let m = c.uniform("u_view");
|
|
317
|
-
m !== void 0 && n.uniformMatrix3fv(m, !1, e.state.transform),
|
|
317
|
+
m !== void 0 && n.uniformMatrix3fv(m, !1, e.state.transform), Te(n, c, t.program.id, t.uniforms, s, { value: 1 }), Z(e), C(e, 6, e.gl.UNSIGNED_SHORT), l !== void 0 && n.disableVertexAttribArray(l), u !== void 0 && n.disableVertexAttribArray(u), n.bindBuffer(n.ARRAY_BUFFER, null), n.bindBuffer(n.ELEMENT_ARRAY_BUFFER, null);
|
|
318
318
|
}
|
|
319
|
-
function
|
|
319
|
+
function De(e, t, n, r, i) {
|
|
320
320
|
let a = e.gl;
|
|
321
|
-
|
|
321
|
+
F(e);
|
|
322
322
|
let o = e.renderTarget ?? null, s = e.clipDepth, c = e.clipStack, l = e.drawBatch.clip, u = a.isEnabled(a.SCISSOR_TEST), d = n.acquire(r, i), f = e.state.pushIsolated({ transform: t.transform });
|
|
323
323
|
e.clipDepth = 0, e.clipStack = [], e.drawBatch.clip = null, a.bindFramebuffer(a.FRAMEBUFFER, d.fbo), e.renderTarget = d, a.viewport(0, 0, r, i), a.disable(a.SCISSOR_TEST), a.stencilMask(255), a.clear(a.COLOR_BUFFER_BIT | a.STENCIL_BUFFER_BIT);
|
|
324
|
-
for (let n of t.children)
|
|
325
|
-
|
|
324
|
+
for (let n of t.children) A(e, n);
|
|
325
|
+
q(e), a.disable(a.BLEND);
|
|
326
326
|
for (let o of t.effects) {
|
|
327
327
|
let t = e.ensureProgram?.(o.program.id) ?? null;
|
|
328
328
|
if (!t) {
|
|
329
|
-
|
|
329
|
+
be(o.program.id, "(program)");
|
|
330
330
|
continue;
|
|
331
331
|
}
|
|
332
332
|
let s = n.acquire(r, i);
|
|
333
|
-
a.bindFramebuffer(a.FRAMEBUFFER, s.fbo), a.viewport(0, 0, r, i), a.clear(a.COLOR_BUFFER_BIT),
|
|
333
|
+
a.bindFramebuffer(a.FRAMEBUFFER, s.fbo), a.viewport(0, 0, r, i), a.clear(a.COLOR_BUFFER_BIT), ke(e, t, d.texture, r, i, o.uniforms, void 0, o.program.id), n.release(d), d = s;
|
|
334
334
|
}
|
|
335
|
-
a.enable(a.BLEND), e.state.pop(), e.clipDepth = s, e.clipStack = c, e.drawBatch.clip = l, e.renderTarget = o,
|
|
335
|
+
a.enable(a.BLEND), e.state.pop(), e.clipDepth = s, e.clipStack = c, e.drawBatch.clip = l, e.renderTarget = o, Oe(e, r, i, u);
|
|
336
336
|
let p = e.ensureProgram?.(S) ?? null;
|
|
337
|
-
p && (Z(e),
|
|
337
|
+
p && (Z(e), ke(e, p, d.texture, r, i, void 0, {
|
|
338
338
|
alpha: f.alpha,
|
|
339
339
|
colorMatrix: f.colorMatrix
|
|
340
340
|
})), n.release(d);
|
|
341
341
|
}
|
|
342
|
-
function
|
|
342
|
+
function Oe(e, t, n, r) {
|
|
343
343
|
let i = e.gl, a = e.renderTarget ?? null;
|
|
344
344
|
i.bindFramebuffer(i.FRAMEBUFFER, a ? a.fbo : null), a ? i.viewport(0, 0, t, n) : (e.restoreTargetRect?.(), r && i.enable(i.SCISSOR_TEST));
|
|
345
345
|
}
|
|
346
|
-
function
|
|
346
|
+
function ke(e, t, n, r, i, a, o, s) {
|
|
347
347
|
let c = e.gl;
|
|
348
348
|
c.useProgram(t.handle);
|
|
349
349
|
let l = t.attribute("a_position"), u = t.attribute("a_uv");
|
|
@@ -355,13 +355,13 @@ function Ae(e, t, n, r, i, a, o, s) {
|
|
|
355
355
|
let p = t.uniform("u_texel");
|
|
356
356
|
if (p !== void 0 && c.uniform2f(p, 1 / r, 1 / i), o) {
|
|
357
357
|
let n = t.uniform("u_alpha");
|
|
358
|
-
n !== void 0 && c.uniform1f(n, o.alpha),
|
|
358
|
+
n !== void 0 && c.uniform1f(n, o.alpha), k(e, t, o.colorMatrix);
|
|
359
359
|
}
|
|
360
|
-
a &&
|
|
360
|
+
a && Te(c, t, s ?? "effect", a, e.textureCache, { value: 1 }), C(e, 6, e.gl.UNSIGNED_SHORT), l !== void 0 && l >= 0 && c.disableVertexAttribArray(l), u !== void 0 && u >= 0 && c.disableVertexAttribArray(u), c.bindBuffer(c.ARRAY_BUFFER, null), c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, null);
|
|
361
361
|
}
|
|
362
|
-
function
|
|
362
|
+
function Ae(e, t) {
|
|
363
363
|
if (t.effects && t.effects.length > 0 && e.effectTargets && e.deviceWidth && e.deviceHeight) {
|
|
364
|
-
|
|
364
|
+
De(e, t, e.effectTargets, e.deviceWidth, e.deviceHeight);
|
|
365
365
|
return;
|
|
366
366
|
}
|
|
367
367
|
if (e.state.push({
|
|
@@ -371,17 +371,17 @@ function je(e, t) {
|
|
|
371
371
|
}), t.clip) {
|
|
372
372
|
let n = e.clipStack.reduce((e, t) => e + +(t.depth === 0), 0);
|
|
373
373
|
if (e.clipDepth + n + 1 > 7) throw e.state.pop(), Error("weasel: clip nesting depth exceeded (max 7). You can't nest more than 7 levels of clipped containers in a single draw tree. Flatten the hierarchy or compose poses outside the scene graph.");
|
|
374
|
-
|
|
374
|
+
je(e, t.clip);
|
|
375
375
|
}
|
|
376
|
-
for (let n of t.children)
|
|
377
|
-
t.clip &&
|
|
376
|
+
for (let n of t.children) A(e, n);
|
|
377
|
+
t.clip && Me(e), e.state.pop();
|
|
378
378
|
}
|
|
379
|
-
function
|
|
379
|
+
function je(e, t) {
|
|
380
380
|
let n = e.state.transform, r = ee(t, n);
|
|
381
381
|
if (r === null) {
|
|
382
|
-
|
|
382
|
+
j(e);
|
|
383
383
|
let r = e.clipDepth + 1;
|
|
384
|
-
|
|
384
|
+
_t(e, t, r), e.clipDepth = r, e.clipStack.push({
|
|
385
385
|
path: t,
|
|
386
386
|
transform: n,
|
|
387
387
|
rect: null,
|
|
@@ -393,105 +393,110 @@ function Me(e, t) {
|
|
|
393
393
|
rect: r,
|
|
394
394
|
depth: 0
|
|
395
395
|
});
|
|
396
|
-
|
|
396
|
+
Ne(e);
|
|
397
397
|
}
|
|
398
|
-
function
|
|
398
|
+
function Me(e) {
|
|
399
399
|
let t = e.clipStack.pop();
|
|
400
|
-
t.depth > 0 && (
|
|
400
|
+
t.depth > 0 && (vt(e, t.path, t.depth - 1, t.transform), e.clipDepth = t.depth - 1), Ne(e);
|
|
401
401
|
}
|
|
402
|
-
function
|
|
402
|
+
function j(e) {
|
|
403
403
|
for (let t of e.clipStack) {
|
|
404
404
|
if (t.depth !== 0) continue;
|
|
405
405
|
let n = e.clipDepth + 1;
|
|
406
|
-
|
|
406
|
+
_t(e, t.path, n, t.transform), t.depth = n, e.clipDepth = n;
|
|
407
407
|
}
|
|
408
408
|
}
|
|
409
|
-
function
|
|
409
|
+
function Ne(e) {
|
|
410
410
|
let t = null;
|
|
411
411
|
for (let n of e.clipStack) n.rect && (t = t ? x(t, n.rect) : n.rect);
|
|
412
412
|
e.drawBatch.clip = t;
|
|
413
413
|
}
|
|
414
|
-
function
|
|
414
|
+
function Pe(e) {
|
|
415
415
|
let t = e.clipStack;
|
|
416
416
|
if (t.length === 0 || e.uncut) return e.clipDepth;
|
|
417
417
|
for (let e = t.length - 1; e >= 0; e--) if (t[e].rect === null) return t[e].depth;
|
|
418
418
|
for (let e of t) if (e.depth > 0) return e.depth - 1;
|
|
419
419
|
return e.clipDepth;
|
|
420
420
|
}
|
|
421
|
-
function
|
|
422
|
-
|
|
421
|
+
function M(e) {
|
|
422
|
+
j(e);
|
|
423
423
|
let t = e.drawBatch.clip;
|
|
424
424
|
return e.drawBatch.clip = null, e.uncut = !0, t;
|
|
425
425
|
}
|
|
426
|
-
function
|
|
426
|
+
function N(e, t) {
|
|
427
427
|
e.drawBatch.clip = t, e.uncut = !1;
|
|
428
428
|
}
|
|
429
|
-
function
|
|
430
|
-
let i =
|
|
431
|
-
r(e, t, n),
|
|
429
|
+
function P(e, t, n, r) {
|
|
430
|
+
let i = M(e);
|
|
431
|
+
r(e, t, n), N(e, i);
|
|
432
432
|
}
|
|
433
|
-
function
|
|
434
|
-
|
|
433
|
+
function F(e) {
|
|
434
|
+
q(e), e.clipStack.length > 0 && j(e);
|
|
435
435
|
}
|
|
436
|
-
function
|
|
437
|
-
t.fill &&
|
|
436
|
+
function Fe(e, t) {
|
|
437
|
+
t.fill && Ie(e, t), t.stroke?.paint && bt(e, t);
|
|
438
438
|
}
|
|
439
|
-
function
|
|
440
|
-
let n = t.fill, r = n.fill === void 0 || n.fill === "solid", i = !!(t.vertexColors && t.vertexColors.length > 0), a = n, o =
|
|
439
|
+
function Ie(e, t) {
|
|
440
|
+
let n = t.fill, r = n.fill === void 0 || n.fill === "solid", i = !!(t.vertexColors && t.vertexColors.length > 0), a = n, o = G(e, n, i);
|
|
441
441
|
if (o === null) return;
|
|
442
442
|
if (o !== void 0 && t.path.kind === "rect") {
|
|
443
|
-
o.kind === "ramp" ?
|
|
443
|
+
o.kind === "ramp" ? $e(e, t.path, o) : Ge(e, t.path, o);
|
|
444
444
|
return;
|
|
445
445
|
}
|
|
446
446
|
let s = ge(e, t.path);
|
|
447
|
-
if (
|
|
447
|
+
if (K(e, s, o)) return;
|
|
448
448
|
let c = _e(e, s);
|
|
449
|
-
r && i ?
|
|
449
|
+
r && i ? nt(e, t, a, c) : c.requiresStencil ? yt(e, n, c) : ct(e, n, c);
|
|
450
450
|
}
|
|
451
|
-
var
|
|
452
|
-
function
|
|
453
|
-
return e === s ||
|
|
451
|
+
var Le = new Int32Array(Array.from({ length: t }, (e, t) => t)), I = new Float32Array(2 * t);
|
|
452
|
+
function Re(e) {
|
|
453
|
+
return e === s || T(s, e);
|
|
454
454
|
}
|
|
455
|
-
function
|
|
456
|
-
if (t.clipDepth !== (e.clipStack.length === 0 ? e.clipDepth :
|
|
455
|
+
function L(e, t, n, r, i = 0) {
|
|
456
|
+
if (t.clipDepth !== (e.clipStack.length === 0 ? e.clipDepth : Pe(e)) || t.synthBold !== i || !t.foldsAlpha && t.alpha !== e.state.alpha || n !== void 0 && ze(t, n, r) < 0) return !1;
|
|
457
457
|
let a = e.state.colorMatrix;
|
|
458
|
-
return t.colorMatrix === a ||
|
|
458
|
+
return t.colorMatrix === a || T(t.colorMatrix, a);
|
|
459
459
|
}
|
|
460
|
-
function
|
|
460
|
+
function ze(e, t, n) {
|
|
461
461
|
for (let r = 0; r < e.textures.length; r++) {
|
|
462
462
|
let i = e.textures[r];
|
|
463
463
|
if (i.kind === "bitmap" && i.image === t) return i.sampling === n ? r + 1 : -1;
|
|
464
464
|
}
|
|
465
|
-
return
|
|
465
|
+
return R(e);
|
|
466
466
|
}
|
|
467
|
-
function
|
|
467
|
+
function Be(e) {
|
|
468
468
|
for (let t = 0; t < e.textures.length; t++) if (e.textures[t].kind === "ramps") return t + 1;
|
|
469
|
-
return
|
|
469
|
+
return R(e);
|
|
470
470
|
}
|
|
471
|
-
function
|
|
471
|
+
function Ve(e, t) {
|
|
472
472
|
for (let n = 0; n < e.textures.length; n++) {
|
|
473
473
|
let r = e.textures[n];
|
|
474
474
|
if (r.kind === "atlas" && r.id === t) return n + 1;
|
|
475
475
|
}
|
|
476
|
-
return
|
|
476
|
+
return R(e);
|
|
477
477
|
}
|
|
478
|
-
function
|
|
478
|
+
function R(e) {
|
|
479
479
|
return e.textures.length + 1 < t ? e.textures.length + 1 : -1;
|
|
480
480
|
}
|
|
481
|
-
var
|
|
482
|
-
|
|
483
|
-
|
|
481
|
+
var z = {
|
|
482
|
+
maxVertices: 96,
|
|
483
|
+
maxVerticesInRun: 1024
|
|
484
|
+
};
|
|
485
|
+
function He(e, t) {
|
|
486
|
+
if (t.requiresStencil) return !1;
|
|
487
|
+
let n = e.drawBatch.length > 0 ? z.maxVerticesInRun : z.maxVertices;
|
|
488
|
+
return t.vertices.length >> 1 <= n;
|
|
484
489
|
}
|
|
485
|
-
function
|
|
486
|
-
return e.batchState !== void 0 && !
|
|
490
|
+
function B(e, t) {
|
|
491
|
+
return e.batchState !== void 0 && !L(e, e.batchState) && q(e), e.drawBatch.wouldOverflow(t) && q(e), V(e);
|
|
487
492
|
}
|
|
488
|
-
function
|
|
493
|
+
function V(e) {
|
|
489
494
|
if (e.batchState === void 0) {
|
|
490
|
-
let t = e.state.colorMatrix, n =
|
|
495
|
+
let t = e.state.colorMatrix, n = Re(t);
|
|
491
496
|
e.batchState = {
|
|
492
497
|
alpha: n ? 1 : e.state.alpha,
|
|
493
498
|
colorMatrix: t,
|
|
494
|
-
clipDepth:
|
|
499
|
+
clipDepth: Pe(e),
|
|
495
500
|
synthBold: 0,
|
|
496
501
|
foldsAlpha: n,
|
|
497
502
|
textures: []
|
|
@@ -499,9 +504,9 @@ function z(e) {
|
|
|
499
504
|
}
|
|
500
505
|
return e.batchState;
|
|
501
506
|
}
|
|
502
|
-
function
|
|
503
|
-
e.batchState !== void 0 && !
|
|
504
|
-
let r =
|
|
507
|
+
function H(e, t, n) {
|
|
508
|
+
e.batchState !== void 0 && !L(e, e.batchState, t, n) && q(e), e.drawBatch.wouldOverflow(4) && q(e);
|
|
509
|
+
let r = V(e), i = ze(r, t, n);
|
|
505
510
|
return i > r.textures.length && (r.textures.push({
|
|
506
511
|
kind: "bitmap",
|
|
507
512
|
image: t,
|
|
@@ -511,11 +516,11 @@ function B(e, t, n) {
|
|
|
511
516
|
slot: i
|
|
512
517
|
};
|
|
513
518
|
}
|
|
514
|
-
function
|
|
515
|
-
e.batchState !== void 0 && (!
|
|
516
|
-
let i =
|
|
519
|
+
function U(e, t, n, r) {
|
|
520
|
+
e.batchState !== void 0 && (!L(e, e.batchState, void 0, void 0, r) || Ve(e.batchState, t) < 0) && q(e), e.drawBatch.wouldOverflow(4) && q(e);
|
|
521
|
+
let i = V(e);
|
|
517
522
|
i.synthBold = r;
|
|
518
|
-
let a =
|
|
523
|
+
let a = Ve(i, t);
|
|
519
524
|
return a > i.textures.length && (i.textures.push({
|
|
520
525
|
kind: "atlas",
|
|
521
526
|
id: t,
|
|
@@ -525,36 +530,36 @@ function V(e, t, n, r) {
|
|
|
525
530
|
slot: a
|
|
526
531
|
};
|
|
527
532
|
}
|
|
528
|
-
function
|
|
529
|
-
e.gradRamps.wouldReshape(t, n) &&
|
|
530
|
-
let i =
|
|
533
|
+
function Ue(e, t, n, r) {
|
|
534
|
+
e.gradRamps.wouldReshape(t, n) && q(e), e.batchState !== void 0 && (!L(e, e.batchState) || Be(e.batchState) < 0) && q(e), e.drawBatch.wouldOverflow(r) && q(e);
|
|
535
|
+
let i = V(e), a = Be(i);
|
|
531
536
|
return a > i.textures.length && (i.textures.push({ kind: "ramps" }), a = i.textures.length), {
|
|
532
537
|
staged: i,
|
|
533
538
|
slot: a,
|
|
534
539
|
rowV: e.gradRamps.rowV(e.gradRamps.upload(t, n))
|
|
535
540
|
};
|
|
536
541
|
}
|
|
537
|
-
function
|
|
542
|
+
function W(e, t, n) {
|
|
538
543
|
return (n ?? 1) * (t.foldsAlpha ? e.state.alpha : 1);
|
|
539
544
|
}
|
|
540
|
-
function
|
|
545
|
+
function We(e, t, n) {
|
|
541
546
|
let [r, i, o, s] = a(n.color);
|
|
542
547
|
return [
|
|
543
548
|
r,
|
|
544
549
|
i,
|
|
545
550
|
o,
|
|
546
|
-
s *
|
|
551
|
+
s * W(e, t, n.opacity)
|
|
547
552
|
];
|
|
548
553
|
}
|
|
549
|
-
function
|
|
550
|
-
let [r, i, a, o] =
|
|
551
|
-
e.drawBatch.pushRect(t.x, t.y, t.width, t.height, e.state.transform, r, i, a, o) ||
|
|
554
|
+
function Ge(e, t, n) {
|
|
555
|
+
let [r, i, a, o] = We(e, B(e, 4), n);
|
|
556
|
+
e.drawBatch.pushRect(t.x, t.y, t.width, t.height, e.state.transform, r, i, a, o) || P(e, t, n, Ge);
|
|
552
557
|
}
|
|
553
|
-
function
|
|
554
|
-
let [r, i, a, o] =
|
|
555
|
-
e.drawBatch.pushMesh(t, e.state.transform, r, i, a, o) ||
|
|
558
|
+
function Ke(e, t, n) {
|
|
559
|
+
let [r, i, a, o] = We(e, B(e, t.vertices.length >> 1), n);
|
|
560
|
+
e.drawBatch.pushMesh(t, e.state.transform, r, i, a, o) || P(e, t, n, Ke);
|
|
556
561
|
}
|
|
557
|
-
function
|
|
562
|
+
function G(e, t, a) {
|
|
558
563
|
if (a) return;
|
|
559
564
|
let o = t.fill ?? "solid";
|
|
560
565
|
if (o === "solid") {
|
|
@@ -566,10 +571,10 @@ function H(e, t, a) {
|
|
|
566
571
|
};
|
|
567
572
|
}
|
|
568
573
|
if (o !== "linear-gradient" && o !== "radial-gradient" && o !== "conic-gradient") return;
|
|
569
|
-
let s = t, c =
|
|
570
|
-
return c ? s.fill === "linear-gradient" ?
|
|
574
|
+
let s = t, c = Je(e, s.units);
|
|
575
|
+
return c ? s.fill === "linear-gradient" ? qe(s, r, Ye(c, s)) : s.fill === "radial-gradient" ? qe(s, i, Xe(c, s)) : qe(s, n, Ze(c, s)) : null;
|
|
571
576
|
}
|
|
572
|
-
function
|
|
577
|
+
function qe(e, t, n) {
|
|
573
578
|
return {
|
|
574
579
|
kind: "ramp",
|
|
575
580
|
stops: e.stops,
|
|
@@ -579,11 +584,11 @@ function U(e, t, n) {
|
|
|
579
584
|
uv: n
|
|
580
585
|
};
|
|
581
586
|
}
|
|
582
|
-
function
|
|
587
|
+
function Je(e, t) {
|
|
583
588
|
let n = X(e, t);
|
|
584
589
|
return n && o.multiply(n, e.state.transform);
|
|
585
590
|
}
|
|
586
|
-
function
|
|
591
|
+
function Ye(e, t) {
|
|
587
592
|
let n = t.to.x - t.from.x, r = t.to.y - t.from.y, i = Math.hypot(n, r) || 1, a = 1 / (i * i);
|
|
588
593
|
return {
|
|
589
594
|
ux: (e[0] * n + e[1] * r) * a,
|
|
@@ -594,7 +599,7 @@ function Qe(e, t) {
|
|
|
594
599
|
v0: 0
|
|
595
600
|
};
|
|
596
601
|
}
|
|
597
|
-
function
|
|
602
|
+
function Xe(e, t) {
|
|
598
603
|
let n = 1 / Math.max(t.radius, 1e-4);
|
|
599
604
|
return {
|
|
600
605
|
ux: e[0] * n,
|
|
@@ -605,7 +610,7 @@ function $e(e, t) {
|
|
|
605
610
|
v0: (e[7] - t.center.y) * n
|
|
606
611
|
};
|
|
607
612
|
}
|
|
608
|
-
function
|
|
613
|
+
function Ze(e, t) {
|
|
609
614
|
let n = Math.cos(t.angle), r = Math.sin(t.angle), i = e[6] - t.center.x, a = e[7] - t.center.y;
|
|
610
615
|
return {
|
|
611
616
|
ux: n * e[0] + r * e[1],
|
|
@@ -616,7 +621,7 @@ function et(e, t) {
|
|
|
616
621
|
v0: n * a - r * i
|
|
617
622
|
};
|
|
618
623
|
}
|
|
619
|
-
function
|
|
624
|
+
function Qe(e, t) {
|
|
620
625
|
return e.mode === r ? {
|
|
621
626
|
uv: {
|
|
622
627
|
...e.uv,
|
|
@@ -628,18 +633,18 @@ function tt(e, t) {
|
|
|
628
633
|
post: t
|
|
629
634
|
};
|
|
630
635
|
}
|
|
631
|
-
function
|
|
632
|
-
let { staged: r, slot: i, rowV: a } =
|
|
633
|
-
e.drawBatch.pushGradientRect(t.x, t.y, t.width, t.height, e.state.transform, o, s, i, n.mode, 1, 1, 1,
|
|
636
|
+
function $e(e, t, n) {
|
|
637
|
+
let { staged: r, slot: i, rowV: a } = Ue(e, n.stops, n.space, 4), { uv: o, post: s } = Qe(n, a);
|
|
638
|
+
e.drawBatch.pushGradientRect(t.x, t.y, t.width, t.height, e.state.transform, o, s, i, n.mode, 1, 1, 1, W(e, r, n.opacity)) || P(e, t, n, $e);
|
|
634
639
|
}
|
|
635
|
-
function
|
|
636
|
-
let { staged: r, slot: i, rowV: a } =
|
|
637
|
-
e.drawBatch.pushGradientMesh(t, e.state.transform, o, s, i, n.mode, 1, 1, 1,
|
|
640
|
+
function et(e, t, n) {
|
|
641
|
+
let { staged: r, slot: i, rowV: a } = Ue(e, n.stops, n.space, t.vertices.length >> 1), { uv: o, post: s } = Qe(n, a);
|
|
642
|
+
e.drawBatch.pushGradientMesh(t, e.state.transform, o, s, i, n.mode, 1, 1, 1, W(e, r, n.opacity)) || P(e, t, n, et);
|
|
638
643
|
}
|
|
639
|
-
function
|
|
640
|
-
return n !== void 0 &&
|
|
644
|
+
function K(e, t, n) {
|
|
645
|
+
return n !== void 0 && He(e, t) ? (n.kind === "ramp" ? et(e, t, n) : Ke(e, t, n), !0) : (F(e), !1);
|
|
641
646
|
}
|
|
642
|
-
function
|
|
647
|
+
function q(e) {
|
|
643
648
|
let t = e.drawBatch, n = e.batchState;
|
|
644
649
|
if (t.length === 0 || n === void 0) {
|
|
645
650
|
e.batchState = void 0;
|
|
@@ -648,11 +653,11 @@ function G(e) {
|
|
|
648
653
|
let r = e.gl, i = e.batchFill;
|
|
649
654
|
r.useProgram(i.handle);
|
|
650
655
|
let a = t.uploadAndBind();
|
|
651
|
-
|
|
656
|
+
J(e, i, D), me(e, i, 1, 1, 1, 1), E(e, i, n.alpha), r.uniform1f(i.uniform("u_synthBold"), n.synthBold), k(e, i, n.colorMatrix), r.activeTexture(r.TEXTURE0), r.bindTexture(r.TEXTURE_2D, e.whiteTexture);
|
|
652
657
|
for (let t = 0; t < n.textures.length; t++) {
|
|
653
658
|
let i = n.textures[t];
|
|
654
659
|
if (i.kind === "atlas") {
|
|
655
|
-
e.textureCache.bind(i.id, t + 1),
|
|
660
|
+
e.textureCache.bind(i.id, t + 1), I[2 * (t + 1)] = i.fieldScale[0], I[2 * (t + 1) + 1] = i.fieldScale[1];
|
|
656
661
|
continue;
|
|
657
662
|
}
|
|
658
663
|
if (i.kind === "ramps") {
|
|
@@ -661,9 +666,9 @@ function G(e) {
|
|
|
661
666
|
}
|
|
662
667
|
e.imageCache.bind(i.image, t + 1), e.imageCache.setMagFilter(i.image, i.sampling === "nearest" ? r.NEAREST : r.LINEAR);
|
|
663
668
|
}
|
|
664
|
-
r.uniform1iv(i.uniform("u_samplers"),
|
|
669
|
+
r.uniform1iv(i.uniform("u_samplers"), Le), r.uniform2fv(i.uniform("u_fieldScale"), I), Z(e, n.clipDepth), C(e, a, e.gl.UNSIGNED_INT), r.activeTexture(r.TEXTURE0), r.bindVertexArray(null), t.reset(), e.batchState = void 0;
|
|
665
670
|
}
|
|
666
|
-
function
|
|
671
|
+
function tt(e, t) {
|
|
667
672
|
let n = t.anchorA, r = t.anchorB, i = t.anchorT;
|
|
668
673
|
if (!n || !r || !i) return new Float32Array(e);
|
|
669
674
|
let a = n.length, o = new Float32Array(a * 4);
|
|
@@ -673,33 +678,33 @@ function K(e, t) {
|
|
|
673
678
|
}
|
|
674
679
|
return o;
|
|
675
680
|
}
|
|
676
|
-
function
|
|
681
|
+
function nt(e, t, n, r) {
|
|
677
682
|
let i = e.gl, a = e.pathFillVColor;
|
|
678
|
-
i.useProgram(a.handle), i.bindVertexArray(r.vao),
|
|
679
|
-
let o =
|
|
683
|
+
i.useProgram(a.handle), i.bindVertexArray(r.vao), J(e, a), Y(e, a, n.color, n.opacity), k(e, a);
|
|
684
|
+
let o = tt(t.vertexColors, r), s = i.createBuffer();
|
|
680
685
|
if (!s) throw Error("drawPathFillVColor: createBuffer (color VBO) returned null");
|
|
681
686
|
i.bindBuffer(i.ARRAY_BUFFER, s), i.bufferData(i.ARRAY_BUFFER, o, i.DYNAMIC_DRAW);
|
|
682
687
|
let c = a.attribute("a_vertexColor");
|
|
683
|
-
c !== void 0 && (i.enableVertexAttribArray(c), i.vertexAttribPointer(c, 4, i.FLOAT, !1, 0, 0)), Z(e),
|
|
688
|
+
c !== void 0 && (i.enableVertexAttribArray(c), i.vertexAttribPointer(c, 4, i.FLOAT, !1, 0, 0)), Z(e), C(e, r.indexCount, e.gl.UNSIGNED_INT), i.bindVertexArray(null), i.deleteBuffer(s);
|
|
684
689
|
}
|
|
685
|
-
function
|
|
686
|
-
let i = e.gl, a =
|
|
687
|
-
|
|
690
|
+
function J(e, t, n = e.state.transform, r = he(e)) {
|
|
691
|
+
let i = e.gl, a = w(e, t);
|
|
692
|
+
T(a.proj, r) || (i.uniformMatrix3fv(t.uniform("u_proj"), !1, r), a.proj = Float32Array.from(r)), T(a.model, n) || (i.uniformMatrix3fv(t.uniform("u_model"), !1, n), a.model = Float32Array.from(n));
|
|
688
693
|
}
|
|
689
|
-
function
|
|
694
|
+
function Y(e, t, n, r) {
|
|
690
695
|
let [i, o, s, c] = a(n);
|
|
691
|
-
me(e, t, i, o, s, c * (r ?? 1)),
|
|
696
|
+
me(e, t, i, o, s, c * (r ?? 1)), E(e, t, e.state.alpha);
|
|
692
697
|
}
|
|
693
|
-
function
|
|
698
|
+
function rt(e, t) {
|
|
694
699
|
let n = t.fill ?? "solid";
|
|
695
|
-
if (n === "solid") return
|
|
696
|
-
if (n === "pattern") return
|
|
697
|
-
if (n === "linear-gradient" || n === "radial-gradient" || n === "conic-gradient") return
|
|
700
|
+
if (n === "solid") return lt(e, t);
|
|
701
|
+
if (n === "pattern") return ut(e, t);
|
|
702
|
+
if (n === "linear-gradient" || n === "radial-gradient" || n === "conic-gradient") return mt(e, t);
|
|
698
703
|
let r = l(n)?.bind;
|
|
699
|
-
return r ? r(
|
|
704
|
+
return r ? r(it(e), t) : null;
|
|
700
705
|
}
|
|
701
|
-
function
|
|
702
|
-
let t =
|
|
706
|
+
function it(e) {
|
|
707
|
+
let t = at.get(e);
|
|
703
708
|
if (t) return t;
|
|
704
709
|
let n = {
|
|
705
710
|
gl: e.gl,
|
|
@@ -707,38 +712,38 @@ function at(e) {
|
|
|
707
712
|
return e.state.alpha;
|
|
708
713
|
},
|
|
709
714
|
program: (t) => e.ensureProgram?.(t) ?? e.programRegistry.get(t) ?? null,
|
|
710
|
-
setProjAndModel: (t) =>
|
|
715
|
+
setProjAndModel: (t) => J(e, t),
|
|
711
716
|
spaceInverse: (t) => X(e, t),
|
|
712
|
-
spaceToDevice: (t) =>
|
|
717
|
+
spaceToDevice: (t) => pt(e, t),
|
|
713
718
|
get maxTextureSize() {
|
|
714
719
|
return e.imageCache.maxTextureSide;
|
|
715
720
|
},
|
|
716
|
-
resources: e.paintResources ??
|
|
721
|
+
resources: e.paintResources ?? st(e.gl),
|
|
717
722
|
bindRamp: (t, n, r) => {
|
|
718
723
|
let i = e.gradRamps.upload(t, r);
|
|
719
724
|
return e.gradRamps.bind(n), e.gradRamps.rowV(i);
|
|
720
725
|
}
|
|
721
726
|
};
|
|
722
|
-
return
|
|
727
|
+
return at.set(e, n), n;
|
|
723
728
|
}
|
|
724
|
-
var
|
|
725
|
-
function
|
|
726
|
-
let n =
|
|
727
|
-
return n || (n = e(),
|
|
729
|
+
var at = /* @__PURE__ */ new WeakMap(), ot = /* @__PURE__ */ new WeakMap();
|
|
730
|
+
function st(t) {
|
|
731
|
+
let n = ot.get(t);
|
|
732
|
+
return n || (n = e(), ot.set(t, n)), n;
|
|
728
733
|
}
|
|
729
|
-
function
|
|
730
|
-
if (!
|
|
734
|
+
function ct(e, t, n) {
|
|
735
|
+
if (!rt(e, t)) return;
|
|
731
736
|
let r = e.gl;
|
|
732
|
-
r.bindVertexArray(n.vao), Z(e),
|
|
737
|
+
r.bindVertexArray(n.vao), Z(e), C(e, n.indexCount, e.gl.UNSIGNED_INT), r.bindVertexArray(null);
|
|
733
738
|
}
|
|
734
|
-
function
|
|
739
|
+
function lt(e, t) {
|
|
735
740
|
let n = e.pathFill;
|
|
736
|
-
return e.gl.useProgram(n.handle),
|
|
741
|
+
return e.gl.useProgram(n.handle), J(e, n), Y(e, n, t.color, t.opacity), k(e, n), n;
|
|
737
742
|
}
|
|
738
|
-
function
|
|
739
|
-
return
|
|
743
|
+
function ut(e, t) {
|
|
744
|
+
return dt(e, e.patternFill, t, e.state.transform);
|
|
740
745
|
}
|
|
741
|
-
function
|
|
746
|
+
function dt(e, t, n, r) {
|
|
742
747
|
let i = n.pattern, a = c(i.id);
|
|
743
748
|
if (!a) return (typeof process > "u" || process.env.NODE_ENV !== "production") && console.warn(`weasel: pattern TextureHandle "${i.id}" not registered`), null;
|
|
744
749
|
let o = X(e, n.units);
|
|
@@ -750,31 +755,31 @@ function ft(e, t, n, r) {
|
|
|
750
755
|
if (!s) return null;
|
|
751
756
|
e.textureCache.upload(i.id, a.source, "repeat");
|
|
752
757
|
let l = e.gl;
|
|
753
|
-
l.useProgram(t.handle),
|
|
754
|
-
let [u, f] =
|
|
755
|
-
return l.uniform2f(t.uniform("u_tileSize"), u, f), e.textureCache.bind(i.id, 0), l.uniform1i(t.uniform("u_sampler"), 0), l.uniform1f(t.uniform("u_opacity"), n.opacity ?? 1),
|
|
758
|
+
l.useProgram(t.handle), J(e, t, r), k(e, t), l.uniformMatrix3fv(t.uniform("u_worldInv"), !1, s);
|
|
759
|
+
let [u, f] = ft(a.source);
|
|
760
|
+
return l.uniform2f(t.uniform("u_tileSize"), u, f), e.textureCache.bind(i.id, 0), l.uniform1i(t.uniform("u_sampler"), 0), l.uniform1f(t.uniform("u_opacity"), n.opacity ?? 1), E(e, t, e.state.alpha), t;
|
|
756
761
|
}
|
|
757
|
-
function
|
|
762
|
+
function ft(e) {
|
|
758
763
|
let t = "naturalWidth" in e ? e.naturalWidth : e.width, n = "naturalHeight" in e ? e.naturalHeight : e.height;
|
|
759
764
|
return [t || 1, n || 1];
|
|
760
765
|
}
|
|
761
766
|
function X(e, t) {
|
|
762
767
|
return t === "local" ? o.invert(e.state.transform) : t === "world" && e.viewMatrix ? o.invert(e.viewMatrix) : o.identity();
|
|
763
768
|
}
|
|
764
|
-
function
|
|
769
|
+
function pt(e, t) {
|
|
765
770
|
let n = X(e, t), r = n && o.invert(n);
|
|
766
771
|
if (!r) return null;
|
|
767
772
|
let i = e.deviceWidth && e.widthCss > 0 ? e.deviceWidth / e.widthCss : 1;
|
|
768
773
|
return o.multiply(o.scaled(o.identity(), i, i), r);
|
|
769
774
|
}
|
|
770
|
-
function
|
|
771
|
-
return
|
|
775
|
+
function mt(e, t) {
|
|
776
|
+
return ht(e, e.gradFill, t, e.state.transform);
|
|
772
777
|
}
|
|
773
|
-
function
|
|
778
|
+
function ht(e, t, n, r) {
|
|
774
779
|
let i = X(e, n.units);
|
|
775
780
|
if (!i) return null;
|
|
776
781
|
let a = e.gl, o = e.gradRamps.upload(n.stops, n.interpolate ?? "rgb");
|
|
777
|
-
if (a.useProgram(t.handle),
|
|
782
|
+
if (a.useProgram(t.handle), J(e, t, r), a.uniformMatrix3fv(t.uniform("u_worldInv"), !1, i), k(e, t), e.gradRamps.bind(0), a.uniform1i(t.uniform("u_ramp"), 0), a.uniform1f(t.uniform("u_rampV"), e.gradRamps.rowV(o)), E(e, t, e.state.alpha), a.uniform1f(t.uniform("u_opacity"), n.opacity ?? 1), n.fill === "linear-gradient") {
|
|
778
783
|
a.uniform1i(t.uniform("u_gradKind"), 0);
|
|
779
784
|
let e = n.to.x - n.from.x, r = n.to.y - n.from.y, i = Math.hypot(e, r) || 1;
|
|
780
785
|
a.uniform2f(t.uniform("u_gradP0"), n.from.x, n.from.y), a.uniform2f(t.uniform("u_gradDir"), e / i, r / i), a.uniform1f(t.uniform("u_gradLen"), i), a.uniform1f(t.uniform("u_gradRadius"), 0), a.uniform1f(t.uniform("u_gradAngle"), 0);
|
|
@@ -793,115 +798,97 @@ function Z(e, t = e.clipDepth) {
|
|
|
793
798
|
function Q(e) {
|
|
794
799
|
return e === 0 ? 0 : (1 << e + 1) - 1 & 254;
|
|
795
800
|
}
|
|
796
|
-
function
|
|
801
|
+
function gt(e, t, n) {
|
|
797
802
|
let r = e.gl, i = ve(e, t);
|
|
798
|
-
r.useProgram(e.pathFill.handle), r.bindVertexArray(i.vao),
|
|
803
|
+
r.useProgram(e.pathFill.handle), r.bindVertexArray(i.vao), J(e, e.pathFill, n), C(e, i.indexCount, e.gl.UNSIGNED_INT), r.bindVertexArray(null);
|
|
799
804
|
}
|
|
800
|
-
function
|
|
801
|
-
|
|
805
|
+
function _t(e, t, n, r = e.state.transform) {
|
|
806
|
+
q(e);
|
|
802
807
|
let i = e.gl, a = Q(n - 1), o = 1 << n, s = a | o;
|
|
803
|
-
i.enable(i.STENCIL_TEST), i.colorMask(!1, !1, !1, !1), i.stencilMask(o), i.stencilFunc(i.EQUAL, s, a), i.stencilOp(i.KEEP, i.KEEP, i.REPLACE),
|
|
808
|
+
i.enable(i.STENCIL_TEST), i.colorMask(!1, !1, !1, !1), i.stencilMask(o), i.stencilFunc(i.EQUAL, s, a), i.stencilOp(i.KEEP, i.KEEP, i.REPLACE), gt(e, t, r), i.colorMask(!0, !0, !0, !0), i.stencilMask(255);
|
|
804
809
|
}
|
|
805
|
-
function
|
|
806
|
-
e.batchState !== void 0 && e.batchState.clipDepth > n &&
|
|
810
|
+
function vt(e, t, n, r = e.state.transform) {
|
|
811
|
+
e.batchState !== void 0 && e.batchState.clipDepth > n && q(e);
|
|
807
812
|
let i = e.gl;
|
|
808
813
|
i.enable(i.STENCIL_TEST);
|
|
809
814
|
let a = 1 << n + 1, o = Q(n) | a;
|
|
810
|
-
i.colorMask(!1, !1, !1, !1), i.stencilMask(a), i.stencilFunc(i.EQUAL, o, o), i.stencilOp(i.KEEP, i.KEEP, i.ZERO),
|
|
815
|
+
i.colorMask(!1, !1, !1, !1), i.stencilMask(a), i.stencilFunc(i.EQUAL, o, o), i.stencilOp(i.KEEP, i.KEEP, i.ZERO), gt(e, t, r), i.colorMask(!0, !0, !0, !0), i.stencilMask(255);
|
|
811
816
|
}
|
|
812
|
-
function
|
|
817
|
+
function yt(e, t, n) {
|
|
813
818
|
let r = e.gl;
|
|
814
|
-
r.useProgram(e.pathFill.handle), r.bindVertexArray(n.vao),
|
|
819
|
+
r.useProgram(e.pathFill.handle), r.bindVertexArray(n.vao), J(e, e.pathFill), r.enable(r.STENCIL_TEST), r.colorMask(!1, !1, !1, !1), r.stencilMask(1), r.stencilFunc(r.ALWAYS, 0, 1), r.stencilOp(r.KEEP, r.KEEP, r.INVERT), C(e, n.indexCount, e.gl.UNSIGNED_INT);
|
|
815
820
|
let i = Q(e.clipDepth);
|
|
816
|
-
r.colorMask(!0, !0, !0, !0), r.stencilFunc(r.EQUAL, i | 1, i | 1), r.stencilOp(r.KEEP, r.KEEP, r.KEEP),
|
|
817
|
-
}
|
|
818
|
-
function
|
|
819
|
-
let n =
|
|
820
|
-
|
|
821
|
-
let s =
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
...e,
|
|
833
|
-
size: _(e, 0, v(e.size.px, t))
|
|
834
|
-
};
|
|
835
|
-
}
|
|
836
|
-
function Ct(e, t) {
|
|
837
|
-
let n = xt(e, t), r = n.stroke, i = r.align ?? "center";
|
|
838
|
-
n.path.kind === "polygon" && i !== "center" ? (P(e), Dt(e, n, i)) : wt(e, n);
|
|
839
|
-
let a = p(r.width ?? 1, 1);
|
|
840
|
-
for (let i of b(n.path, t.stroke, r, a, e.flattenTolerance)) Le(e, i);
|
|
841
|
-
}
|
|
842
|
-
function wt(e, t) {
|
|
843
|
-
let n = t.stroke, r = n.paint, i = r.fill === void 0 || r.fill === "solid", a = r, o = y(t.path, n, e.flattenTolerance);
|
|
844
|
-
if (o.indices.length === 0) return;
|
|
845
|
-
let s = !!(n.vertexColors && n.vertexColors.length > 0), c = H(e, r, s);
|
|
846
|
-
if (c === null || W(e, o, c)) return;
|
|
847
|
-
let l = s ? e.meshCache.uploadTransient(o) : e.meshCache.uploadRecurring(o);
|
|
848
|
-
if (!i && !s) {
|
|
849
|
-
lt(e, r, l);
|
|
821
|
+
r.colorMask(!0, !0, !0, !0), r.stencilFunc(r.EQUAL, i | 1, i | 1), r.stencilOp(r.KEEP, r.KEEP, r.KEEP), rt(e, t) && C(e, n.indexCount, e.gl.UNSIGNED_INT), r.stencilMask(1), r.clear(r.STENCIL_BUFFER_BIT), r.disable(r.STENCIL_TEST), r.bindVertexArray(null);
|
|
822
|
+
}
|
|
823
|
+
function bt(e, t) {
|
|
824
|
+
let { cmd: n, spaces: r } = y(e.state.transform, t), i = n.stroke, a = i.align ?? "center", o = r.ribbon?.metric;
|
|
825
|
+
(n.path.kind === "polygon" || o !== void 0 && !p(o)) && a !== "center" ? (F(e), wt(e, n, a, r)) : xt(e, n, r);
|
|
826
|
+
let s = m(i.width ?? 1, 1), c = b(n.path, t.stroke, i, s, e.flattenTolerance, r);
|
|
827
|
+
for (let t of c) Fe(e, t);
|
|
828
|
+
}
|
|
829
|
+
function xt(e, t, n) {
|
|
830
|
+
let r = t.stroke, i = r.paint, a = i.fill === void 0 || i.fill === "solid", o = i, s = h(t.path, r, e.flattenTolerance, n);
|
|
831
|
+
if (s.indices.length === 0) return;
|
|
832
|
+
let c = !!(r.vertexColors && r.vertexColors.length > 0), l = G(e, i, c);
|
|
833
|
+
if (l === null || K(e, s, l)) return;
|
|
834
|
+
let u = c ? e.meshCache.uploadTransient(s) : e.meshCache.uploadRecurring(s);
|
|
835
|
+
if (!a && !c) {
|
|
836
|
+
ct(e, i, u);
|
|
850
837
|
return;
|
|
851
838
|
}
|
|
852
|
-
let
|
|
853
|
-
if (
|
|
839
|
+
let d = e.gl;
|
|
840
|
+
if (c) {
|
|
854
841
|
let t = e.pathFillVColor;
|
|
855
|
-
|
|
856
|
-
let
|
|
842
|
+
d.useProgram(t.handle), d.bindVertexArray(u.vao), J(e, t), Y(e, t, a ? o.color : "#ffffff", i.opacity), k(e, t);
|
|
843
|
+
let n = tt(r.vertexColors, u), s = d.createBuffer();
|
|
857
844
|
if (!s) throw Error("drawPathStrokeUnclipped: createBuffer (color VBO) returned null");
|
|
858
|
-
|
|
845
|
+
d.bindBuffer(d.ARRAY_BUFFER, s), d.bufferData(d.ARRAY_BUFFER, n, d.DYNAMIC_DRAW);
|
|
859
846
|
let c = t.attribute("a_vertexColor");
|
|
860
|
-
c !== void 0 && (
|
|
847
|
+
c !== void 0 && (d.enableVertexAttribArray(c), d.vertexAttribPointer(c, 4, d.FLOAT, !1, 0, 0)), Z(e), C(e, u.indexCount, e.gl.UNSIGNED_INT), d.bindVertexArray(null), d.deleteBuffer(s);
|
|
861
848
|
return;
|
|
862
849
|
}
|
|
863
|
-
|
|
864
|
-
}
|
|
865
|
-
var
|
|
866
|
-
function
|
|
867
|
-
let t =
|
|
868
|
-
return t === void 0 && (t = e.map((e) => e * 2),
|
|
869
|
-
}
|
|
870
|
-
function
|
|
871
|
-
let
|
|
872
|
-
...
|
|
873
|
-
width:
|
|
874
|
-
...
|
|
850
|
+
d.useProgram(e.pathFill.handle), d.bindVertexArray(u.vao), J(e, e.pathFill), Y(e, e.pathFill, o.color, o.opacity), k(e, e.pathFill), Z(e), C(e, u.indexCount, e.gl.UNSIGNED_INT), d.bindVertexArray(null);
|
|
851
|
+
}
|
|
852
|
+
var St = /* @__PURE__ */ new WeakMap();
|
|
853
|
+
function Ct(e) {
|
|
854
|
+
let t = St.get(e);
|
|
855
|
+
return t === void 0 && (t = e.map((e) => e * 2), St.set(e, t)), t;
|
|
856
|
+
}
|
|
857
|
+
function wt(e, t, n, r) {
|
|
858
|
+
let i = t.stroke, a = i.paint, o = a.fill === void 0 || a.fill === "solid", s = a, c = {
|
|
859
|
+
...i,
|
|
860
|
+
width: m(i.width ?? 1, 1) * 2,
|
|
861
|
+
...i.vertexWidths ? { vertexWidths: Ct(i.vertexWidths) } : {},
|
|
875
862
|
align: "center"
|
|
876
|
-
},
|
|
877
|
-
if (
|
|
878
|
-
let
|
|
879
|
-
|
|
880
|
-
let
|
|
881
|
-
|
|
882
|
-
let
|
|
883
|
-
if (
|
|
884
|
-
|
|
863
|
+
}, l = !!(i.vertexColors && i.vertexColors.length > 0), u = ve(e, t.path), d = h(t.path, c, e.flattenTolerance, r);
|
|
864
|
+
if (d.indices.length === 0) return;
|
|
865
|
+
let f = l ? e.meshCache.uploadTransient(d) : e.meshCache.uploadRecurring(d), p = e.gl, g = l ? e.pathFillVColor : e.pathFill;
|
|
866
|
+
p.useProgram(g.handle), J(e, g), p.enable(p.STENCIL_TEST), p.colorMask(!1, !1, !1, !1), p.stencilMask(1), p.stencilFunc(p.ALWAYS, 1, 1), p.stencilOp(p.KEEP, p.KEEP, p.REPLACE), p.bindVertexArray(u.vao), C(e, u.indexCount, e.gl.UNSIGNED_INT);
|
|
867
|
+
let _ = Q(e.clipDepth);
|
|
868
|
+
p.colorMask(!0, !0, !0, !0), n === "inner" ? p.stencilFunc(p.EQUAL, _ | 1, _ | 1) : p.stencilFunc(p.EQUAL, _, _ | 1), p.stencilOp(p.KEEP, p.KEEP, p.KEEP);
|
|
869
|
+
let v = g;
|
|
870
|
+
if (l ? (Y(e, g, o ? s.color : "#ffffff", a.opacity), k(e, g)) : v = rt(e, a), !v) {
|
|
871
|
+
p.stencilMask(1), p.clear(p.STENCIL_BUFFER_BIT), p.disable(p.STENCIL_TEST), p.bindVertexArray(null);
|
|
885
872
|
return;
|
|
886
873
|
}
|
|
887
|
-
|
|
888
|
-
let
|
|
889
|
-
if (
|
|
890
|
-
let e =
|
|
891
|
-
if (
|
|
892
|
-
|
|
893
|
-
let t =
|
|
894
|
-
t !== void 0 && (
|
|
874
|
+
p.bindVertexArray(f.vao);
|
|
875
|
+
let y = null;
|
|
876
|
+
if (l) {
|
|
877
|
+
let e = tt(i.vertexColors, f);
|
|
878
|
+
if (y = p.createBuffer(), !y) throw Error("drawPathStrokeStenciled: createBuffer (color VBO) returned null");
|
|
879
|
+
p.bindBuffer(p.ARRAY_BUFFER, y), p.bufferData(p.ARRAY_BUFFER, e, p.DYNAMIC_DRAW);
|
|
880
|
+
let t = v.attribute("a_vertexColor");
|
|
881
|
+
t !== void 0 && (p.enableVertexAttribArray(t), p.vertexAttribPointer(t, 4, p.FLOAT, !1, 0, 0));
|
|
895
882
|
}
|
|
896
|
-
|
|
883
|
+
C(e, f.indexCount, e.gl.UNSIGNED_INT), p.stencilMask(1), p.clear(p.STENCIL_BUFFER_BIT), p.disable(p.STENCIL_TEST), p.bindVertexArray(null), y && p.deleteBuffer(y);
|
|
897
884
|
}
|
|
898
|
-
var
|
|
899
|
-
function
|
|
885
|
+
var Tt = 48;
|
|
886
|
+
function Et(e) {
|
|
900
887
|
let t = Math.hypot(e[0], e[1]), n = Math.hypot(e[3], e[4]);
|
|
901
888
|
return Math.sqrt(t * n) || 1;
|
|
902
889
|
}
|
|
903
|
-
function
|
|
904
|
-
let n = le(t.style), r = n.lineHeight, i = t.align ?? n.align, a = t.maxWidth ?? Infinity, o = e.textOutlineMinScreenSize ??
|
|
890
|
+
function Dt(e, t) {
|
|
891
|
+
let n = le(t.style), r = n.lineHeight, i = t.align ?? n.align, a = t.maxWidth ?? Infinity, o = e.textOutlineMinScreenSize ?? Tt, s = Number.isFinite(o) ? o / Et(e.state.transform) : void 0, c = ce(t.runs, {
|
|
905
892
|
maxWidth: a,
|
|
906
893
|
alignWidth: t.width,
|
|
907
894
|
lineHeight: r,
|
|
@@ -911,62 +898,28 @@ function At(e, t) {
|
|
|
911
898
|
});
|
|
912
899
|
if (c.groups.length === 0 && c.decorations.length === 0) return;
|
|
913
900
|
let l = t.x, u = t.y + ue(t.verticalAlign, t.height, c.bounds.height);
|
|
914
|
-
for (let t of c.groups) t.source === "outline" ?
|
|
915
|
-
|
|
901
|
+
for (let t of c.groups) t.source === "outline" ? Ot(e, t, l, u) : Nt(e, t, l, u);
|
|
902
|
+
At(e, c.decorations, l, u);
|
|
916
903
|
}
|
|
917
|
-
function
|
|
904
|
+
function Ot(e, t, n, r) {
|
|
918
905
|
let i = t.fill;
|
|
919
906
|
if (i !== null) {
|
|
920
|
-
let a =
|
|
921
|
-
a &&
|
|
907
|
+
let a = _(t, n, r);
|
|
908
|
+
a && kt(e, i, a);
|
|
922
909
|
}
|
|
923
910
|
let a = t.stroke?.paint;
|
|
924
911
|
if (!a) return;
|
|
925
|
-
let
|
|
926
|
-
|
|
912
|
+
let o = v(t, n, r, e.state.transform);
|
|
913
|
+
o && kt(e, a, o);
|
|
927
914
|
}
|
|
928
|
-
function
|
|
929
|
-
let r =
|
|
930
|
-
r !== null && (
|
|
931
|
-
}
|
|
932
|
-
function Nt(e, t, n) {
|
|
933
|
-
return Ft(e, t, n, (e) => m(e.key, e.d));
|
|
934
|
-
}
|
|
935
|
-
function Pt(e, t, n, r) {
|
|
936
|
-
let i = e.stroke;
|
|
937
|
-
if (!i) return null;
|
|
938
|
-
let a = p(i.width ?? 1, r);
|
|
939
|
-
return a > 0 ? Ft(e, t, n, (e) => e.scale > 0 ? h(e.key, e.d, g(a / e.scale), i) : null) : null;
|
|
940
|
-
}
|
|
941
|
-
function Ft(e, t, n, r) {
|
|
942
|
-
let i = [], a = 0, o = 0;
|
|
943
|
-
for (let t of e.glyphs) {
|
|
944
|
-
let e = r(t);
|
|
945
|
-
e && e.indices.length !== 0 && (i.push({
|
|
946
|
-
mesh: e,
|
|
947
|
-
glyph: t
|
|
948
|
-
}), a += e.vertices.length, o += e.indices.length);
|
|
949
|
-
}
|
|
950
|
-
if (i.length === 0) return null;
|
|
951
|
-
let s = e.synthetic.italic ? Math.tan(te) : 0, c = new Float32Array(a), l = new Uint32Array(o), u = 0, d = 0, f = 0;
|
|
952
|
-
for (let { mesh: e, glyph: r } of i) {
|
|
953
|
-
let { x: i, baselineY: a, scale: o } = r;
|
|
954
|
-
for (let r = 0; r < e.vertices.length; r += 2) {
|
|
955
|
-
let l = e.vertices[r], d = e.vertices[r + 1];
|
|
956
|
-
c[u++] = i + t + (l - d * s) * o, c[u++] = a + n + d * o;
|
|
957
|
-
}
|
|
958
|
-
for (let t = 0; t < e.indices.length; t++) l[d++] = f + e.indices[t];
|
|
959
|
-
f += e.vertices.length / 2;
|
|
960
|
-
}
|
|
961
|
-
return {
|
|
962
|
-
vertices: c,
|
|
963
|
-
indices: l
|
|
964
|
-
};
|
|
915
|
+
function kt(e, t, n) {
|
|
916
|
+
let r = G(e, t, !1);
|
|
917
|
+
r !== null && (K(e, n, r) || ct(e, t, e.meshCache.uploadTransient(n)));
|
|
965
918
|
}
|
|
966
|
-
function
|
|
919
|
+
function At(e, t, n, r) {
|
|
967
920
|
for (let i of t) {
|
|
968
|
-
if (
|
|
969
|
-
|
|
921
|
+
if (Pt(i.fill) !== null) {
|
|
922
|
+
kt(e, i.fill, jt(i.x0 + n, i.y0 + r, i.x1 + n, i.y1 + r));
|
|
970
923
|
continue;
|
|
971
924
|
}
|
|
972
925
|
let [t, o, s, c] = "color" in i.fill ? a(i.fill.color) : [
|
|
@@ -976,14 +929,14 @@ function It(e, t, n, r) {
|
|
|
976
929
|
1
|
|
977
930
|
], l;
|
|
978
931
|
for (;;) {
|
|
979
|
-
let a =
|
|
932
|
+
let a = B(e, 4);
|
|
980
933
|
if (e.drawBatch.pushRect(i.x0 + n, i.y0 + r, i.x1 - i.x0, i.y1 - i.y0, e.state.transform, t, o, s, c * (a.foldsAlpha ? e.state.alpha : 1))) break;
|
|
981
|
-
l =
|
|
934
|
+
l = M(e);
|
|
982
935
|
}
|
|
983
|
-
l !== void 0 &&
|
|
936
|
+
l !== void 0 && N(e, l);
|
|
984
937
|
}
|
|
985
938
|
}
|
|
986
|
-
function
|
|
939
|
+
function jt(e, t, n, r) {
|
|
987
940
|
return {
|
|
988
941
|
vertices: new Float32Array([
|
|
989
942
|
e,
|
|
@@ -1005,17 +958,17 @@ function Lt(e, t, n, r) {
|
|
|
1005
958
|
])
|
|
1006
959
|
};
|
|
1007
960
|
}
|
|
1008
|
-
var
|
|
1009
|
-
function
|
|
961
|
+
var Mt = .08;
|
|
962
|
+
function Nt(e, t, n, r) {
|
|
1010
963
|
if (t.source === "canvas") {
|
|
1011
964
|
if (!oe(e.textureCache, t.page)) return;
|
|
1012
965
|
} else if (!ie(t.family, t.weight, t.style, e.textureCache)) return;
|
|
1013
966
|
if (t.quads.length === 0) return;
|
|
1014
|
-
let i = t.source === "canvas" ? re(t.page) : se(t.family, t.weight, t.style), o = t.source === "canvas" ? ne :
|
|
967
|
+
let i = t.source === "canvas" ? re(t.page) : se(t.family, t.weight, t.style), o = t.source === "canvas" ? ne : te, s = ae(t.source === "canvas" ? "canvas" : "atlas", t.family, t.weight, t.style);
|
|
1015
968
|
if (!s) return;
|
|
1016
|
-
let c = t.synthetic.bold ?
|
|
969
|
+
let c = t.synthetic.bold ? Mt : 0, l = t.synthetic.italic ? Math.tan(g) : 0, u = Pt(t.fill);
|
|
1017
970
|
if (u !== null) {
|
|
1018
|
-
|
|
971
|
+
Ft(e, t, n, r, u, i, o, c, l, s);
|
|
1019
972
|
return;
|
|
1020
973
|
}
|
|
1021
974
|
let d = t.fill !== null && "color" in t.fill ? a(t.fill.color) : [
|
|
@@ -1023,43 +976,43 @@ function zt(e, t, n, r) {
|
|
|
1023
976
|
0,
|
|
1024
977
|
0,
|
|
1025
978
|
1
|
|
1026
|
-
], f = e.drawBatch, p = e.state.transform, { staged: m, slot: h } =
|
|
979
|
+
], f = e.drawBatch, p = e.state.transform, { staged: m, slot: h } = U(e, i, s, c), _ = d[3] * (m.foldsAlpha ? e.state.alpha : 1);
|
|
1027
980
|
for (let a of t.quads) {
|
|
1028
|
-
f.wouldOverflow(4) && (
|
|
981
|
+
f.wouldOverflow(4) && (q(e), {staged: m, slot: h} = U(e, i, s, c), _ = d[3] * (m.foldsAlpha ? e.state.alpha : 1));
|
|
1029
982
|
let t;
|
|
1030
|
-
for (; !f.pushGlyph(a.x0 + n, a.y0 + r, a.x1 + n, a.y1 + r, a.baselineY + r, l, p, a.u0, a.v0, a.u1, a.v1, d[0], d[1], d[2],
|
|
1031
|
-
t !== void 0 && (
|
|
983
|
+
for (; !f.pushGlyph(a.x0 + n, a.y0 + r, a.x1 + n, a.y1 + r, a.baselineY + r, l, p, a.u0, a.v0, a.u1, a.v1, d[0], d[1], d[2], _, h, o);) t = M(e), {staged: m, slot: h} = U(e, i, s, c), _ = d[3] * (m.foldsAlpha ? e.state.alpha : 1);
|
|
984
|
+
t !== void 0 && (N(e, t), {staged: m, slot: h} = U(e, i, s, c), _ = d[3] * (m.foldsAlpha ? e.state.alpha : 1));
|
|
1032
985
|
}
|
|
1033
986
|
}
|
|
1034
|
-
function
|
|
987
|
+
function Pt(e) {
|
|
1035
988
|
let t = e?.fill ?? "solid";
|
|
1036
989
|
return t === "pattern" ? "pattern" : t === "linear-gradient" || t === "radial-gradient" || t === "conic-gradient" ? "gradient" : t === "solid" ? null : "texture";
|
|
1037
990
|
}
|
|
1038
|
-
var
|
|
1039
|
-
function
|
|
991
|
+
var $ = 1;
|
|
992
|
+
function Ft(e, t, n, r, i, a, o, s, c, l) {
|
|
1040
993
|
let u = e.glyphPaintProgram?.(i);
|
|
1041
994
|
if (!u) return;
|
|
1042
|
-
|
|
995
|
+
F(e);
|
|
1043
996
|
let d = t.fill, f = e.state.transform, p;
|
|
1044
|
-
if (i === "pattern") p =
|
|
1045
|
-
else if (i === "gradient") p =
|
|
997
|
+
if (i === "pattern") p = dt(e, u, d, D);
|
|
998
|
+
else if (i === "gradient") p = ht(e, u, d, D);
|
|
1046
999
|
else {
|
|
1047
|
-
let i =
|
|
1048
|
-
p = i &&
|
|
1000
|
+
let i = zt(e, d, Lt(t, n, r, c, f));
|
|
1001
|
+
p = i && Bt(e, u, i);
|
|
1049
1002
|
}
|
|
1050
1003
|
if (!p) return;
|
|
1051
1004
|
let m = e.gl;
|
|
1052
|
-
e.textureCache.bind(a,
|
|
1005
|
+
e.textureCache.bind(a, $), m.uniform1i(u.uniform("u_atlas"), $), m.uniform1f(u.uniform("u_synthBold"), s), m.uniform2f(u.uniform("u_fieldScale"), l[0], l[1]), Z(e);
|
|
1053
1006
|
let h = e.drawBatch, g = h.clip;
|
|
1054
1007
|
h.clip = null;
|
|
1055
|
-
for (let i of t.quads) h.wouldOverflow(4) &&
|
|
1056
|
-
|
|
1008
|
+
for (let i of t.quads) h.wouldOverflow(4) && It(e), h.pushGlyph(i.x0 + n, i.y0 + r, i.x1 + n, i.y1 + r, i.baselineY + r, c, f, i.u0, i.v0, i.u1, i.v1, 1, 1, 1, 1, $, o);
|
|
1009
|
+
It(e), h.clip = g, m.activeTexture(m.TEXTURE0), m.bindVertexArray(null);
|
|
1057
1010
|
}
|
|
1058
|
-
function
|
|
1011
|
+
function It(e) {
|
|
1059
1012
|
let t = e.drawBatch;
|
|
1060
|
-
t.length !== 0 && (
|
|
1013
|
+
t.length !== 0 && (C(e, t.uploadAndBind(), e.gl.UNSIGNED_INT), t.reset());
|
|
1061
1014
|
}
|
|
1062
|
-
function
|
|
1015
|
+
function Lt(e, t, n, r, i) {
|
|
1063
1016
|
let a = {
|
|
1064
1017
|
x0: Infinity,
|
|
1065
1018
|
y0: Infinity,
|
|
@@ -1075,7 +1028,7 @@ function Wt(e, t, n, r, i) {
|
|
|
1075
1028
|
}
|
|
1076
1029
|
return a;
|
|
1077
1030
|
}
|
|
1078
|
-
var
|
|
1031
|
+
var Rt = {
|
|
1079
1032
|
vertices: new Float32Array([
|
|
1080
1033
|
0,
|
|
1081
1034
|
0,
|
|
@@ -1095,7 +1048,7 @@ var Gt = {
|
|
|
1095
1048
|
3
|
|
1096
1049
|
])
|
|
1097
1050
|
};
|
|
1098
|
-
function
|
|
1051
|
+
function zt(e, t, n) {
|
|
1099
1052
|
let r = e.paintScratch, i = l(t.fill)?.bind;
|
|
1100
1053
|
if (!r || !i) return null;
|
|
1101
1054
|
let a = e.deviceWidth && e.widthCss > 0 ? e.deviceWidth / e.widthCss : 1, o = e.deviceWidth ?? Math.round(e.widthCss), s = e.deviceHeight ?? Math.round(e.heightCss), c = Math.max(0, Math.floor(n.x0 * a)), u = Math.max(0, Math.floor(n.y0 * a)), d = e.imageCache.maxTextureSide, f = Math.min(d, Math.min(o, Math.ceil(n.x1 * a)) - c), p = Math.min(d, Math.min(s, Math.ceil(n.y1 * a)) - u);
|
|
@@ -1120,15 +1073,15 @@ function Kt(e, t, n) {
|
|
|
1120
1073
|
-1 - 2 * m / g,
|
|
1121
1074
|
-1 - 2 * h / _,
|
|
1122
1075
|
1
|
|
1123
|
-
]), b =
|
|
1076
|
+
]), b = it(e), ee = {
|
|
1124
1077
|
...b,
|
|
1125
1078
|
alpha: e.state.alpha,
|
|
1126
1079
|
maxTextureSize: b.maxTextureSize,
|
|
1127
|
-
setProjAndModel: (t) =>
|
|
1080
|
+
setProjAndModel: (t) => J(e, t, v, y)
|
|
1128
1081
|
}, x = e.gl, S = r.acquire(f, p), te = x.isEnabled(x.SCISSOR_TEST);
|
|
1129
1082
|
x.activeTexture(x.TEXTURE0), x.bindTexture(x.TEXTURE_2D, null), x.bindFramebuffer(x.FRAMEBUFFER, S.fbo), x.viewport(0, 0, f, p), x.disable(x.SCISSOR_TEST), x.disable(x.STENCIL_TEST), x.clear(x.COLOR_BUFFER_BIT), x.disable(x.BLEND);
|
|
1130
|
-
let
|
|
1131
|
-
return
|
|
1083
|
+
let ne = i(ee, t);
|
|
1084
|
+
return ne && (x.bindVertexArray(e.meshCache.uploadRecurring(Rt).vao), C(e, Rt.indices.length, x.UNSIGNED_INT), x.bindVertexArray(null)), x.enable(x.BLEND), Oe(e, o, s, te), ne ? {
|
|
1132
1085
|
texture: S.texture,
|
|
1133
1086
|
uvFromScreen: new Float32Array([
|
|
1134
1087
|
a / S.width,
|
|
@@ -1143,13 +1096,13 @@ function Kt(e, t, n) {
|
|
|
1143
1096
|
])
|
|
1144
1097
|
} : null;
|
|
1145
1098
|
}
|
|
1146
|
-
function
|
|
1099
|
+
function Bt(e, t, n) {
|
|
1147
1100
|
let r = e.gl;
|
|
1148
|
-
return r.useProgram(t.handle),
|
|
1101
|
+
return r.useProgram(t.handle), J(e, t, D), r.uniformMatrix3fv(t.uniform("u_worldInv"), !1, n.uvFromScreen), r.activeTexture(r.TEXTURE0), r.bindTexture(r.TEXTURE_2D, n.texture), r.uniform1i(t.uniform("u_sampler"), 0), t;
|
|
1149
1102
|
}
|
|
1150
|
-
function
|
|
1103
|
+
function Vt(e, t) {
|
|
1151
1104
|
e.imageCache.upload(t.image, t.image);
|
|
1152
|
-
let { staged: n, slot: r } =
|
|
1105
|
+
let { staged: n, slot: r } = H(e, t.image, t.sampling ?? "linear"), i = t.source, a = 0, o = 0, s = 1, c = 1;
|
|
1153
1106
|
if (i) {
|
|
1154
1107
|
let e = t.image.width, n = t.image.height;
|
|
1155
1108
|
a = i.x / e, s = (i.x + i.w) / e, o = i.y / n, c = (i.y + i.h) / n;
|
|
@@ -1162,21 +1115,21 @@ function Jt(e, t) {
|
|
|
1162
1115
|
let e = o;
|
|
1163
1116
|
o = c, c = e;
|
|
1164
1117
|
}
|
|
1165
|
-
e.drawBatch.pushQuad(t.x, t.y, t.w, t.h, e.state.transform, a, o, s, c, (t.opacity ?? 1) * (n.foldsAlpha ? e.state.alpha : 1), r) ||
|
|
1118
|
+
e.drawBatch.pushQuad(t.x, t.y, t.w, t.h, e.state.transform, a, o, s, c, (t.opacity ?? 1) * (n.foldsAlpha ? e.state.alpha : 1), r) || P(e, t, void 0, Vt);
|
|
1166
1119
|
}
|
|
1167
|
-
function
|
|
1120
|
+
function Ht(e, t) {
|
|
1168
1121
|
let n = t.sprites, r = Math.floor(n.length / u);
|
|
1169
1122
|
if (r === 0) return;
|
|
1170
1123
|
e.imageCache.upload(t.image, t.image);
|
|
1171
|
-
let i = t.sampling ?? "linear", { staged: a, slot: o } =
|
|
1124
|
+
let i = t.sampling ?? "linear", { staged: a, slot: o } = H(e, t.image, i), s = e.drawBatch, c = e.state.transform, l = a.foldsAlpha ? e.state.alpha : 1, d = t.image.width, f = t.image.height;
|
|
1172
1125
|
for (let p = 0, m = 0; p < r; p++, m += u) {
|
|
1173
|
-
s.wouldOverflow(4) && (
|
|
1126
|
+
s.wouldOverflow(4) && (q(e), {staged: a, slot: o} = H(e, t.image, i), l = a.foldsAlpha ? e.state.alpha : 1);
|
|
1174
1127
|
let r = n[m + 4], u = n[m + 5], p = n[m + 6], h = n[m + 7], g;
|
|
1175
|
-
for (; !s.pushQuad(n[m], n[m + 1], n[m + 2], n[m + 3], c, r / d, u / f, (r + p) / d, (u + h) / f, n[m + 8] * l, o);) g =
|
|
1176
|
-
g !== void 0 && (
|
|
1128
|
+
for (; !s.pushQuad(n[m], n[m + 1], n[m + 2], n[m + 3], c, r / d, u / f, (r + p) / d, (u + h) / f, n[m + 8] * l, o);) g = M(e), {staged: a, slot: o} = H(e, t.image, i), l = a.foldsAlpha ? e.state.alpha : 1;
|
|
1129
|
+
g !== void 0 && (N(e, g), {staged: a, slot: o} = H(e, t.image, i), l = a.foldsAlpha ? e.state.alpha : 1);
|
|
1177
1130
|
}
|
|
1178
1131
|
}
|
|
1179
1132
|
//#endregion
|
|
1180
|
-
export {
|
|
1133
|
+
export { Tt as OUTLINE_MIN_SCREEN_PX, A as dispatch, Ae as drawGroup, q as flushBatch, f as getMesh, o as mat3, z as meshBatching, vt as popClip, _t as pushClip, xe as setUniform, K as tryStageFill };
|
|
1181
1134
|
|
|
1182
1135
|
//# sourceMappingURL=draw.js.map
|