holostaff-widget 2.0.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/BufferResource-Bh7Dg2tm.js +535 -0
- package/dist/BufferResource-Bh7Dg2tm.js.map +1 -0
- package/dist/CanvasRenderer-DVQieOII.js +976 -0
- package/dist/CanvasRenderer-DVQieOII.js.map +1 -0
- package/dist/RenderTargetSystem-B-GzTxxb.js +2500 -0
- package/dist/RenderTargetSystem-B-GzTxxb.js.map +1 -0
- package/dist/WebGLRenderer-D18tg5um.js +2938 -0
- package/dist/WebGLRenderer-D18tg5um.js.map +1 -0
- package/dist/WebGPURenderer-BuntxQ1w.js +1723 -0
- package/dist/WebGPURenderer-BuntxQ1w.js.map +1 -0
- package/dist/assets/idle-loop-green-8.mp4 +0 -0
- package/dist/assets/idle-loop-green.mp4 +0 -0
- package/dist/assets/idle-loop.mp4 +0 -0
- package/dist/assets/idle-loop.webm +0 -0
- package/dist/browserAll-DgNyjpqs.js +1872 -0
- package/dist/browserAll-DgNyjpqs.js.map +1 -0
- package/dist/hs-widget.es.js +5 -0
- package/dist/hs-widget.es.js.map +1 -0
- package/dist/hs-widget.umd.js +1003 -0
- package/dist/hs-widget.umd.js.map +1 -0
- package/dist/index-DjIeNhPr.js +23003 -0
- package/dist/index-DjIeNhPr.js.map +1 -0
- package/dist/webworkerAll-DndJ9Gy-.js +525 -0
- package/dist/webworkerAll-DndJ9Gy-.js.map +1 -0
- package/package.json +37 -0
|
@@ -0,0 +1,976 @@
|
|
|
1
|
+
import { D as E, C as ee, c as D, d as Re, m as ce, M as F, e as R, G as je, w as Xe, T as He, f as ze, s as Je, h as Ke, F as Qe, i as Ze, j as et, A as tt, R as nt, k as he } from "./index-DjIeNhPr.js";
|
|
2
|
+
import { R as at, S as st, B as ot, a as rt, b as it, c as ct, A as lt, C as ht } from "./RenderTargetSystem-B-GzTxxb.js";
|
|
3
|
+
let Z;
|
|
4
|
+
function Ae(o) {
|
|
5
|
+
const e = E.get().createCanvas(6, 1), t = e.getContext("2d");
|
|
6
|
+
return t.fillStyle = o, t.fillRect(0, 0, 6, 1), e;
|
|
7
|
+
}
|
|
8
|
+
function Be() {
|
|
9
|
+
if (Z !== void 0)
|
|
10
|
+
return Z;
|
|
11
|
+
try {
|
|
12
|
+
const o = Ae("#ff00ff"), e = Ae("#ffff00"), a = E.get().createCanvas(6, 1).getContext("2d");
|
|
13
|
+
a.globalCompositeOperation = "multiply", a.drawImage(o, 0, 0), a.drawImage(e, 2, 0);
|
|
14
|
+
const n = a.getImageData(2, 0, 1, 1);
|
|
15
|
+
if (!n)
|
|
16
|
+
Z = !1;
|
|
17
|
+
else {
|
|
18
|
+
const s = n.data;
|
|
19
|
+
Z = s[0] === 255 && s[1] === 0 && s[2] === 0;
|
|
20
|
+
}
|
|
21
|
+
} catch {
|
|
22
|
+
Z = !1;
|
|
23
|
+
}
|
|
24
|
+
return Z;
|
|
25
|
+
}
|
|
26
|
+
const d = {
|
|
27
|
+
canvas: null,
|
|
28
|
+
convertTintToImage: !1,
|
|
29
|
+
cacheStepsPerColorChannel: 8,
|
|
30
|
+
canUseMultiply: Be(),
|
|
31
|
+
tintMethod: null,
|
|
32
|
+
_canvasSourceCache: /* @__PURE__ */ new WeakMap(),
|
|
33
|
+
_unpremultipliedCache: /* @__PURE__ */ new WeakMap(),
|
|
34
|
+
getCanvasSource: (o) => {
|
|
35
|
+
const e = o.source, t = e == null ? void 0 : e.resource;
|
|
36
|
+
if (!t)
|
|
37
|
+
return null;
|
|
38
|
+
const a = e.alphaMode === "premultiplied-alpha", n = e.resourceWidth ?? e.pixelWidth, s = e.resourceHeight ?? e.pixelHeight, r = n !== e.pixelWidth || s !== e.pixelHeight;
|
|
39
|
+
if (a) {
|
|
40
|
+
if ((t instanceof HTMLCanvasElement || typeof OffscreenCanvas < "u" && t instanceof OffscreenCanvas) && !r)
|
|
41
|
+
return t;
|
|
42
|
+
const i = d._unpremultipliedCache.get(e);
|
|
43
|
+
if ((i == null ? void 0 : i.resourceId) === e._resourceId)
|
|
44
|
+
return i.canvas;
|
|
45
|
+
}
|
|
46
|
+
if (t instanceof Uint8Array || t instanceof Uint8ClampedArray || t instanceof Int8Array || t instanceof Uint16Array || t instanceof Int16Array || t instanceof Uint32Array || t instanceof Int32Array || t instanceof Float32Array || t instanceof ArrayBuffer) {
|
|
47
|
+
const i = d._canvasSourceCache.get(e);
|
|
48
|
+
if ((i == null ? void 0 : i.resourceId) === e._resourceId)
|
|
49
|
+
return i.canvas;
|
|
50
|
+
const c = E.get().createCanvas(e.pixelWidth, e.pixelHeight), h = c.getContext("2d"), l = h.createImageData(e.pixelWidth, e.pixelHeight), f = l.data, x = t instanceof ArrayBuffer ? new Uint8Array(t) : new Uint8Array(t.buffer, t.byteOffset, t.byteLength);
|
|
51
|
+
if (e.format === "bgra8unorm")
|
|
52
|
+
for (let p = 0; p < f.length && p + 3 < x.length; p += 4)
|
|
53
|
+
f[p] = x[p + 2], f[p + 1] = x[p + 1], f[p + 2] = x[p], f[p + 3] = x[p + 3];
|
|
54
|
+
else
|
|
55
|
+
f.set(x.subarray(0, f.length));
|
|
56
|
+
return h.putImageData(l, 0, 0), d._canvasSourceCache.set(e, { canvas: c, resourceId: e._resourceId }), c;
|
|
57
|
+
}
|
|
58
|
+
if (a) {
|
|
59
|
+
const i = E.get().createCanvas(e.pixelWidth, e.pixelHeight), c = i.getContext("2d", { willReadFrequently: !0 });
|
|
60
|
+
i.width = e.pixelWidth, i.height = e.pixelHeight, c.drawImage(t, 0, 0);
|
|
61
|
+
const h = c.getImageData(0, 0, i.width, i.height), l = h.data;
|
|
62
|
+
for (let f = 0; f < l.length; f += 4) {
|
|
63
|
+
const x = l[f + 3];
|
|
64
|
+
if (x > 0) {
|
|
65
|
+
const p = 255 / x;
|
|
66
|
+
l[f] = Math.min(255, l[f] * p + 0.5), l[f + 1] = Math.min(255, l[f + 1] * p + 0.5), l[f + 2] = Math.min(255, l[f + 2] * p + 0.5);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return c.putImageData(h, 0, 0), d._unpremultipliedCache.set(e, { canvas: i, resourceId: e._resourceId }), i;
|
|
70
|
+
}
|
|
71
|
+
if (r) {
|
|
72
|
+
const i = d._canvasSourceCache.get(e);
|
|
73
|
+
if ((i == null ? void 0 : i.resourceId) === e._resourceId)
|
|
74
|
+
return i.canvas;
|
|
75
|
+
const c = E.get().createCanvas(e.pixelWidth, e.pixelHeight), h = c.getContext("2d");
|
|
76
|
+
return c.width = e.pixelWidth, c.height = e.pixelHeight, h.drawImage(t, 0, 0), d._canvasSourceCache.set(e, { canvas: c, resourceId: e._resourceId }), c;
|
|
77
|
+
}
|
|
78
|
+
return t;
|
|
79
|
+
},
|
|
80
|
+
getTintedCanvas: (o, e) => {
|
|
81
|
+
const t = o.texture, a = ee.shared.setValue(e).toHex(), n = t.tintCache || (t.tintCache = {}), s = n[a], r = t.source._resourceId;
|
|
82
|
+
if ((s == null ? void 0 : s.tintId) === r)
|
|
83
|
+
return s;
|
|
84
|
+
const i = s && "getContext" in s ? s : E.get().createCanvas();
|
|
85
|
+
return d.tintMethod(t, e, i), i.tintId = r, n[a] = i, n[a];
|
|
86
|
+
},
|
|
87
|
+
getTintedPattern: (o, e) => {
|
|
88
|
+
const t = ee.shared.setValue(e).toHex(), a = o.patternCache || (o.patternCache = {}), n = o.source._resourceId;
|
|
89
|
+
let s = a[t];
|
|
90
|
+
return (s == null ? void 0 : s.tintId) === n || (d.canvas || (d.canvas = E.get().createCanvas()), d.tintMethod(o, e, d.canvas), s = d.canvas.getContext("2d").createPattern(d.canvas, "repeat"), s.tintId = n, a[t] = s), s;
|
|
91
|
+
},
|
|
92
|
+
/**
|
|
93
|
+
* Applies a transform to a CanvasPattern.
|
|
94
|
+
* @param pattern - The pattern to apply the transform to.
|
|
95
|
+
* @param matrix - The matrix to apply.
|
|
96
|
+
* @param matrix.a
|
|
97
|
+
* @param matrix.b
|
|
98
|
+
* @param matrix.c
|
|
99
|
+
* @param matrix.d
|
|
100
|
+
* @param matrix.tx
|
|
101
|
+
* @param matrix.ty
|
|
102
|
+
* @param invert
|
|
103
|
+
*/
|
|
104
|
+
applyPatternTransform: (o, e, t = !0) => {
|
|
105
|
+
if (!e) return;
|
|
106
|
+
const a = o;
|
|
107
|
+
if (!a.setTransform) return;
|
|
108
|
+
const n = globalThis.DOMMatrix;
|
|
109
|
+
if (!n) return;
|
|
110
|
+
const s = new n([e.a, e.b, e.c, e.d, e.tx, e.ty]);
|
|
111
|
+
a.setTransform(t ? s.inverse() : s);
|
|
112
|
+
},
|
|
113
|
+
tintWithMultiply: (o, e, t) => {
|
|
114
|
+
const a = t.getContext("2d"), n = o.frame.clone(), s = o.source._resolution ?? o.source.resolution ?? 1, r = o.rotate;
|
|
115
|
+
n.x *= s, n.y *= s, n.width *= s, n.height *= s;
|
|
116
|
+
const i = D.isVertical(r), c = i ? n.height : n.width, h = i ? n.width : n.height;
|
|
117
|
+
t.width = Math.ceil(c), t.height = Math.ceil(h), a.save(), a.fillStyle = ee.shared.setValue(e).toHex(), a.fillRect(0, 0, c, h), a.globalCompositeOperation = "multiply";
|
|
118
|
+
const l = d.getCanvasSource(o);
|
|
119
|
+
if (!l) {
|
|
120
|
+
a.restore();
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
r && d._applyInverseRotation(a, r, n.width, n.height), a.drawImage(
|
|
124
|
+
l,
|
|
125
|
+
n.x,
|
|
126
|
+
n.y,
|
|
127
|
+
n.width,
|
|
128
|
+
n.height,
|
|
129
|
+
0,
|
|
130
|
+
0,
|
|
131
|
+
n.width,
|
|
132
|
+
n.height
|
|
133
|
+
), a.globalCompositeOperation = "destination-atop", a.drawImage(
|
|
134
|
+
l,
|
|
135
|
+
n.x,
|
|
136
|
+
n.y,
|
|
137
|
+
n.width,
|
|
138
|
+
n.height,
|
|
139
|
+
0,
|
|
140
|
+
0,
|
|
141
|
+
n.width,
|
|
142
|
+
n.height
|
|
143
|
+
), a.restore();
|
|
144
|
+
},
|
|
145
|
+
tintWithOverlay: (o, e, t) => {
|
|
146
|
+
const a = t.getContext("2d"), n = o.frame.clone(), s = o.source._resolution ?? o.source.resolution ?? 1, r = o.rotate;
|
|
147
|
+
n.x *= s, n.y *= s, n.width *= s, n.height *= s;
|
|
148
|
+
const i = D.isVertical(r), c = i ? n.height : n.width, h = i ? n.width : n.height;
|
|
149
|
+
t.width = Math.ceil(c), t.height = Math.ceil(h), a.save(), a.globalCompositeOperation = "copy", a.fillStyle = ee.shared.setValue(e).toHex(), a.fillRect(0, 0, c, h), a.globalCompositeOperation = "destination-atop";
|
|
150
|
+
const l = d.getCanvasSource(o);
|
|
151
|
+
if (!l) {
|
|
152
|
+
a.restore();
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
r && d._applyInverseRotation(a, r, n.width, n.height), a.drawImage(
|
|
156
|
+
l,
|
|
157
|
+
n.x,
|
|
158
|
+
n.y,
|
|
159
|
+
n.width,
|
|
160
|
+
n.height,
|
|
161
|
+
0,
|
|
162
|
+
0,
|
|
163
|
+
n.width,
|
|
164
|
+
n.height
|
|
165
|
+
), a.restore();
|
|
166
|
+
},
|
|
167
|
+
tintWithPerPixel: (o, e, t) => {
|
|
168
|
+
const a = t.getContext("2d"), n = o.frame.clone(), s = o.source._resolution ?? o.source.resolution ?? 1, r = o.rotate;
|
|
169
|
+
n.x *= s, n.y *= s, n.width *= s, n.height *= s;
|
|
170
|
+
const i = D.isVertical(r), c = i ? n.height : n.width, h = i ? n.width : n.height;
|
|
171
|
+
t.width = Math.ceil(c), t.height = Math.ceil(h), a.save(), a.globalCompositeOperation = "copy";
|
|
172
|
+
const l = d.getCanvasSource(o);
|
|
173
|
+
if (!l) {
|
|
174
|
+
a.restore();
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
r && d._applyInverseRotation(a, r, n.width, n.height), a.drawImage(
|
|
178
|
+
l,
|
|
179
|
+
n.x,
|
|
180
|
+
n.y,
|
|
181
|
+
n.width,
|
|
182
|
+
n.height,
|
|
183
|
+
0,
|
|
184
|
+
0,
|
|
185
|
+
n.width,
|
|
186
|
+
n.height
|
|
187
|
+
), a.restore();
|
|
188
|
+
const f = e >> 16 & 255, x = e >> 8 & 255, p = e & 255, y = a.getImageData(0, 0, c, h), T = y.data;
|
|
189
|
+
for (let v = 0; v < T.length; v += 4)
|
|
190
|
+
T[v] = T[v] * f / 255, T[v + 1] = T[v + 1] * x / 255, T[v + 2] = T[v + 2] * p / 255;
|
|
191
|
+
a.putImageData(y, 0, 0);
|
|
192
|
+
},
|
|
193
|
+
/**
|
|
194
|
+
* Applies inverse rotation transform to context for texture packer rotation compensation.
|
|
195
|
+
* Supports all 16 groupD8 symmetries (rotations and reflections).
|
|
196
|
+
* @param context - Canvas 2D context
|
|
197
|
+
* @param rotate - The groupD8 rotation value
|
|
198
|
+
* @param srcWidth - Source crop width (before rotation)
|
|
199
|
+
* @param srcHeight - Source crop height (before rotation)
|
|
200
|
+
*/
|
|
201
|
+
_applyInverseRotation: (o, e, t, a) => {
|
|
202
|
+
const n = D.inv(e), s = D.uX(n), r = D.uY(n), i = D.vX(n), c = D.vY(n), h = -Math.min(0, s * t, i * a, s * t + i * a), l = -Math.min(0, r * t, c * a, r * t + c * a);
|
|
203
|
+
o.transform(s, r, i, c, h, l);
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
d.tintMethod = d.canUseMultiply ? d.tintWithMultiply : d.tintWithPerPixel;
|
|
207
|
+
const xe = class z {
|
|
208
|
+
static _getPatternRepeat(e, t) {
|
|
209
|
+
const a = e && e !== "clamp-to-edge", n = t && t !== "clamp-to-edge";
|
|
210
|
+
return a && n ? "repeat" : a ? "repeat-x" : n ? "repeat-y" : "no-repeat";
|
|
211
|
+
}
|
|
212
|
+
start(e, t, a) {
|
|
213
|
+
}
|
|
214
|
+
execute(e, t) {
|
|
215
|
+
var i, c, h, l;
|
|
216
|
+
const a = t.elements;
|
|
217
|
+
if (!a || !a.length) return;
|
|
218
|
+
const n = e.renderer, s = n.canvasContext, r = s.activeContext;
|
|
219
|
+
for (let f = 0; f < a.length; f++) {
|
|
220
|
+
const x = a[f];
|
|
221
|
+
if (!x.packAsQuad) continue;
|
|
222
|
+
const p = x, y = p.texture, T = y ? d.getCanvasSource(y) : null;
|
|
223
|
+
if (!T) continue;
|
|
224
|
+
const v = y.source.style, H = s.smoothProperty, V = v.scaleMode !== "nearest";
|
|
225
|
+
r[H] !== V && (r[H] = V), s.setBlendMode(t.blendMode);
|
|
226
|
+
const G = ((i = n.globalUniforms.globalUniformData) == null ? void 0 : i.worldColor) ?? 4294967295, b = p.color, P = (G >>> 24 & 255) / 255, j = (b >>> 24 & 255) / 255, se = ((c = n.filter) == null ? void 0 : c.alphaMultiplier) ?? 1, te = P * j * se;
|
|
227
|
+
if (te <= 0) continue;
|
|
228
|
+
r.globalAlpha = te;
|
|
229
|
+
const ne = G & 16777215, J = b & 16777215, w = Re(ce(J, ne)), S = y.frame, I = v.addressModeU ?? v.addressMode, de = v.addressModeV ?? v.addressMode, ae = z._getPatternRepeat(I, de), q = y.source._resolution ?? y.source.resolution ?? 1, X = (l = (h = p.renderable) == null ? void 0 : h.renderGroup) == null ? void 0 : l.isCachedAsTexture, m = S.x * q, C = S.y * q, _ = S.width * q, L = S.height * q, A = p.bounds, k = n.renderTarget.renderTarget.isRoot, U = A.minX, O = A.minY, B = A.maxX - A.minX, W = A.maxY - A.minY, $ = y.rotate, u = y.uvs, N = Math.min(u.x0, u.x1, u.x2, u.x3, u.y0, u.y1, u.y2, u.y3), Y = Math.max(u.x0, u.x1, u.x2, u.x3, u.y0, u.y1, u.y2, u.y3), M = ae !== "no-repeat" && (N < 0 || Y > 1), pe = $ && !(!M && (w !== 16777215 || $));
|
|
230
|
+
pe ? (z._tempPatternMatrix.copyFrom(p.transform), D.matrixAppendRotationInv(
|
|
231
|
+
z._tempPatternMatrix,
|
|
232
|
+
$,
|
|
233
|
+
U,
|
|
234
|
+
O,
|
|
235
|
+
B,
|
|
236
|
+
W
|
|
237
|
+
), s.setContextTransform(
|
|
238
|
+
z._tempPatternMatrix,
|
|
239
|
+
p.roundPixels === 1,
|
|
240
|
+
void 0,
|
|
241
|
+
X && k
|
|
242
|
+
)) : s.setContextTransform(
|
|
243
|
+
p.transform,
|
|
244
|
+
p.roundPixels === 1,
|
|
245
|
+
void 0,
|
|
246
|
+
X && k
|
|
247
|
+
);
|
|
248
|
+
const oe = pe ? 0 : U, re = pe ? 0 : O, ue = B, fe = W;
|
|
249
|
+
if (M) {
|
|
250
|
+
let ge = T;
|
|
251
|
+
const K = w !== 16777215 && !$, Q = S.width <= y.source.width && S.height <= y.source.height;
|
|
252
|
+
K && Q && (ge = d.getTintedCanvas({ texture: y }, w));
|
|
253
|
+
const me = r.createPattern(ge, ae);
|
|
254
|
+
if (!me) continue;
|
|
255
|
+
const _e = ue, Pe = fe;
|
|
256
|
+
if (_e === 0 || Pe === 0) continue;
|
|
257
|
+
const Me = 1 / _e, be = 1 / Pe, we = (u.x1 - u.x0) * Me, ke = (u.y1 - u.y0) * Me, Se = (u.x3 - u.x0) * be, Ie = (u.y3 - u.y0) * be, Ne = u.x0 - we * oe - Se * re, Ye = u.y0 - ke * oe - Ie * re, ve = y.source.pixelWidth, ye = y.source.pixelHeight;
|
|
258
|
+
z._tempPatternMatrix.set(
|
|
259
|
+
we * ve,
|
|
260
|
+
ke * ye,
|
|
261
|
+
Se * ve,
|
|
262
|
+
Ie * ye,
|
|
263
|
+
Ne * ve,
|
|
264
|
+
Ye * ye
|
|
265
|
+
), d.applyPatternTransform(me, z._tempPatternMatrix), r.fillStyle = me, r.fillRect(oe, re, ue, fe);
|
|
266
|
+
} else {
|
|
267
|
+
const K = w !== 16777215 || $ ? d.getTintedCanvas({ texture: y }, w) : T, Q = K !== T;
|
|
268
|
+
r.drawImage(
|
|
269
|
+
K,
|
|
270
|
+
Q ? 0 : m,
|
|
271
|
+
Q ? 0 : C,
|
|
272
|
+
Q ? K.width : _,
|
|
273
|
+
Q ? K.height : L,
|
|
274
|
+
oe,
|
|
275
|
+
re,
|
|
276
|
+
ue,
|
|
277
|
+
fe
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
xe._tempPatternMatrix = new F();
|
|
284
|
+
xe.extension = {
|
|
285
|
+
type: [
|
|
286
|
+
R.CanvasPipesAdaptor
|
|
287
|
+
],
|
|
288
|
+
name: "batch"
|
|
289
|
+
};
|
|
290
|
+
let dt = xe;
|
|
291
|
+
class We {
|
|
292
|
+
constructor(e) {
|
|
293
|
+
this._colorStack = [], this._colorStackIndex = 0, this._currentColor = 0, this._renderer = e;
|
|
294
|
+
}
|
|
295
|
+
buildStart() {
|
|
296
|
+
this._colorStack[0] = 15, this._colorStackIndex = 1, this._currentColor = 15;
|
|
297
|
+
}
|
|
298
|
+
push(e, t, a) {
|
|
299
|
+
this._renderer.renderPipes.batch.break(a);
|
|
300
|
+
const n = this._colorStack;
|
|
301
|
+
n[this._colorStackIndex] = n[this._colorStackIndex - 1] & e.mask;
|
|
302
|
+
const s = this._colorStack[this._colorStackIndex];
|
|
303
|
+
s !== this._currentColor && (this._currentColor = s, a.add({
|
|
304
|
+
renderPipeId: "colorMask",
|
|
305
|
+
colorMask: s,
|
|
306
|
+
canBundle: !1
|
|
307
|
+
})), this._colorStackIndex++;
|
|
308
|
+
}
|
|
309
|
+
pop(e, t, a) {
|
|
310
|
+
this._renderer.renderPipes.batch.break(a);
|
|
311
|
+
const n = this._colorStack;
|
|
312
|
+
this._colorStackIndex--;
|
|
313
|
+
const s = n[this._colorStackIndex - 1];
|
|
314
|
+
s !== this._currentColor && (this._currentColor = s, a.add({
|
|
315
|
+
renderPipeId: "colorMask",
|
|
316
|
+
colorMask: s,
|
|
317
|
+
canBundle: !1
|
|
318
|
+
}));
|
|
319
|
+
}
|
|
320
|
+
execute(e) {
|
|
321
|
+
}
|
|
322
|
+
destroy() {
|
|
323
|
+
this._renderer = null, this._colorStack = null;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
We.extension = {
|
|
327
|
+
type: [
|
|
328
|
+
R.CanvasPipes
|
|
329
|
+
],
|
|
330
|
+
name: "colorMask"
|
|
331
|
+
};
|
|
332
|
+
function pt(o, e, t, a, n, s) {
|
|
333
|
+
s = Math.max(0, Math.min(s, Math.min(a, n) / 2)), o.moveTo(e + s, t), o.lineTo(e + a - s, t), o.quadraticCurveTo(e + a, t, e + a, t + s), o.lineTo(e + a, t + n - s), o.quadraticCurveTo(e + a, t + n, e + a - s, t + n), o.lineTo(e + s, t + n), o.quadraticCurveTo(e, t + n, e, t + n - s), o.lineTo(e, t + s), o.quadraticCurveTo(e, t, e + s, t);
|
|
334
|
+
}
|
|
335
|
+
function De(o, e) {
|
|
336
|
+
switch (e.type) {
|
|
337
|
+
case "rectangle": {
|
|
338
|
+
const t = e;
|
|
339
|
+
o.rect(t.x, t.y, t.width, t.height);
|
|
340
|
+
break;
|
|
341
|
+
}
|
|
342
|
+
case "roundedRectangle": {
|
|
343
|
+
const t = e;
|
|
344
|
+
pt(o, t.x, t.y, t.width, t.height, t.radius);
|
|
345
|
+
break;
|
|
346
|
+
}
|
|
347
|
+
case "circle": {
|
|
348
|
+
const t = e;
|
|
349
|
+
o.moveTo(t.x + t.radius, t.y), o.arc(t.x, t.y, t.radius, 0, Math.PI * 2);
|
|
350
|
+
break;
|
|
351
|
+
}
|
|
352
|
+
case "ellipse": {
|
|
353
|
+
const t = e;
|
|
354
|
+
o.ellipse ? (o.moveTo(t.x + t.halfWidth, t.y), o.ellipse(t.x, t.y, t.halfWidth, t.halfHeight, 0, 0, Math.PI * 2)) : (o.save(), o.translate(t.x, t.y), o.scale(t.halfWidth, t.halfHeight), o.moveTo(1, 0), o.arc(0, 0, 1, 0, Math.PI * 2), o.restore());
|
|
355
|
+
break;
|
|
356
|
+
}
|
|
357
|
+
case "triangle": {
|
|
358
|
+
const t = e;
|
|
359
|
+
o.moveTo(t.x, t.y), o.lineTo(t.x2, t.y2), o.lineTo(t.x3, t.y3), o.closePath();
|
|
360
|
+
break;
|
|
361
|
+
}
|
|
362
|
+
case "polygon":
|
|
363
|
+
default: {
|
|
364
|
+
const t = e, a = t.points;
|
|
365
|
+
if (!(a != null && a.length)) break;
|
|
366
|
+
o.moveTo(a[0], a[1]);
|
|
367
|
+
for (let n = 2; n < a.length; n += 2)
|
|
368
|
+
o.lineTo(a[n], a[n + 1]);
|
|
369
|
+
t.closePath && o.closePath();
|
|
370
|
+
break;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
function ut(o, e) {
|
|
375
|
+
if (!(e != null && e.length)) return !1;
|
|
376
|
+
for (let t = 0; t < e.length; t++) {
|
|
377
|
+
const a = e[t];
|
|
378
|
+
if (!(a != null && a.shape)) continue;
|
|
379
|
+
const n = a.transform, s = n && !n.isIdentity();
|
|
380
|
+
s && (o.save(), o.transform(n.a, n.b, n.c, n.d, n.tx, n.ty)), De(o, a.shape), s && o.restore();
|
|
381
|
+
}
|
|
382
|
+
return !0;
|
|
383
|
+
}
|
|
384
|
+
class Ge {
|
|
385
|
+
constructor(e) {
|
|
386
|
+
this._warnedMaskTypes = /* @__PURE__ */ new Set(), this._canvasMaskStack = [], this._renderer = e;
|
|
387
|
+
}
|
|
388
|
+
push(e, t, a) {
|
|
389
|
+
this._renderer.renderPipes.batch.break(a), a.add({
|
|
390
|
+
renderPipeId: "stencilMask",
|
|
391
|
+
action: "pushMaskBegin",
|
|
392
|
+
mask: e,
|
|
393
|
+
inverse: t._maskOptions.inverse,
|
|
394
|
+
canBundle: !1
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
pop(e, t, a) {
|
|
398
|
+
this._renderer.renderPipes.batch.break(a), a.add({
|
|
399
|
+
renderPipeId: "stencilMask",
|
|
400
|
+
action: "popMaskEnd",
|
|
401
|
+
mask: e,
|
|
402
|
+
inverse: t._maskOptions.inverse,
|
|
403
|
+
canBundle: !1
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
execute(e) {
|
|
407
|
+
var l, f, x;
|
|
408
|
+
if (e.action !== "pushMaskBegin" && e.action !== "popMaskEnd")
|
|
409
|
+
return;
|
|
410
|
+
const t = this._renderer, a = t.canvasContext, n = a == null ? void 0 : a.activeContext;
|
|
411
|
+
if (!n) return;
|
|
412
|
+
if (e.action === "popMaskEnd") {
|
|
413
|
+
this._canvasMaskStack.pop() && n.restore();
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
e.inverse && this._warnOnce(
|
|
417
|
+
"inverse",
|
|
418
|
+
"CanvasRenderer: inverse masks are not supported on Canvas2D; ignoring inverse flag."
|
|
419
|
+
);
|
|
420
|
+
const s = e.mask.mask;
|
|
421
|
+
if (!(s instanceof je)) {
|
|
422
|
+
this._warnOnce(
|
|
423
|
+
"nonGraphics",
|
|
424
|
+
"CanvasRenderer: only Graphics masks are supported in Canvas2D; skipping mask."
|
|
425
|
+
), this._canvasMaskStack.push(!1);
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
const r = s, i = (l = r.context) == null ? void 0 : l.instructions;
|
|
429
|
+
if (!(i != null && i.length)) {
|
|
430
|
+
this._canvasMaskStack.push(!1);
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
n.save(), a.setContextTransform(
|
|
434
|
+
r.groupTransform,
|
|
435
|
+
(t._roundPixels | r._roundPixels) === 1
|
|
436
|
+
), n.beginPath();
|
|
437
|
+
let c = !1, h = !1;
|
|
438
|
+
for (let p = 0; p < i.length; p++) {
|
|
439
|
+
const y = i[p], T = y.action;
|
|
440
|
+
if (T !== "fill" && T !== "stroke") continue;
|
|
441
|
+
const v = y.data, H = (f = v == null ? void 0 : v.path) == null ? void 0 : f.shapePath;
|
|
442
|
+
if (!((x = H == null ? void 0 : H.shapePrimitives) != null && x.length)) continue;
|
|
443
|
+
const V = H.shapePrimitives;
|
|
444
|
+
for (let G = 0; G < V.length; G++) {
|
|
445
|
+
const b = V[G];
|
|
446
|
+
if (!(b != null && b.shape)) continue;
|
|
447
|
+
const P = b.transform, j = P && !P.isIdentity();
|
|
448
|
+
j && (n.save(), n.transform(P.a, P.b, P.c, P.d, P.tx, P.ty)), De(n, b.shape), h = ut(n, b.holes) || h, c = !0, j && n.restore();
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
if (!c) {
|
|
452
|
+
n.restore(), this._canvasMaskStack.push(!1);
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
h ? n.clip("evenodd") : n.clip(), this._canvasMaskStack.push(!0);
|
|
456
|
+
}
|
|
457
|
+
destroy() {
|
|
458
|
+
this._renderer = null, this._warnedMaskTypes = null, this._canvasMaskStack = null;
|
|
459
|
+
}
|
|
460
|
+
_warnOnce(e, t) {
|
|
461
|
+
this._warnedMaskTypes.has(e) || (this._warnedMaskTypes.add(e), Xe(t));
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
Ge.extension = {
|
|
465
|
+
type: [
|
|
466
|
+
R.CanvasPipes
|
|
467
|
+
],
|
|
468
|
+
name: "stencilMask"
|
|
469
|
+
};
|
|
470
|
+
const g = "source-over";
|
|
471
|
+
function ft() {
|
|
472
|
+
const o = Be(), e = /* @__PURE__ */ Object.create(null);
|
|
473
|
+
return e.inherit = g, e.none = g, e.normal = "source-over", e.add = "lighter", e.multiply = o ? "multiply" : g, e.screen = o ? "screen" : g, e.overlay = o ? "overlay" : g, e.darken = o ? "darken" : g, e.lighten = o ? "lighten" : g, e["color-dodge"] = o ? "color-dodge" : g, e["color-burn"] = o ? "color-burn" : g, e["hard-light"] = o ? "hard-light" : g, e["soft-light"] = o ? "soft-light" : g, e.difference = o ? "difference" : g, e.exclusion = o ? "exclusion" : g, e.saturation = o ? "saturation" : g, e.color = o ? "color" : g, e.luminosity = o ? "luminosity" : g, e["linear-burn"] = o ? "color-burn" : g, e["linear-dodge"] = o ? "color-dodge" : g, e["linear-light"] = o ? "hard-light" : g, e["pin-light"] = o ? "hard-light" : g, e["vivid-light"] = o ? "hard-light" : g, e["hard-mix"] = g, e.negation = o ? "difference" : g, e["normal-npm"] = e.normal, e["add-npm"] = e.add, e["screen-npm"] = e.screen, e.erase = "destination-out", e.subtract = g, e.divide = g, e.min = g, e.max = g, e;
|
|
474
|
+
}
|
|
475
|
+
const gt = new F();
|
|
476
|
+
class Ue {
|
|
477
|
+
/**
|
|
478
|
+
* @param renderer - The owning CanvasRenderer.
|
|
479
|
+
*/
|
|
480
|
+
constructor(e) {
|
|
481
|
+
this.activeResolution = 1, this.smoothProperty = "imageSmoothingEnabled", this.blendModes = ft(), this._activeBlendMode = "normal", this._projTransform = null, this._outerBlend = !1, this._warnedBlendModes = /* @__PURE__ */ new Set(), this._renderer = e;
|
|
482
|
+
}
|
|
483
|
+
resolutionChange(e) {
|
|
484
|
+
this.activeResolution = e;
|
|
485
|
+
}
|
|
486
|
+
/** Initializes the root context and smoothing flag selection. */
|
|
487
|
+
init() {
|
|
488
|
+
const e = this._renderer.background.alpha < 1;
|
|
489
|
+
if (this.rootContext = this._renderer.canvas.getContext(
|
|
490
|
+
"2d",
|
|
491
|
+
{ alpha: e }
|
|
492
|
+
), this.activeContext = this.rootContext, this.activeResolution = this._renderer.resolution, !this.rootContext.imageSmoothingEnabled) {
|
|
493
|
+
const t = this.rootContext;
|
|
494
|
+
t.webkitImageSmoothingEnabled ? this.smoothProperty = "webkitImageSmoothingEnabled" : t.mozImageSmoothingEnabled ? this.smoothProperty = "mozImageSmoothingEnabled" : t.oImageSmoothingEnabled ? this.smoothProperty = "oImageSmoothingEnabled" : t.msImageSmoothingEnabled && (this.smoothProperty = "msImageSmoothingEnabled");
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Sets the current transform on the active context.
|
|
499
|
+
* @param transform - Transform to apply.
|
|
500
|
+
* @param roundPixels - Whether to round translation to integers.
|
|
501
|
+
* @param localResolution - Optional local resolution multiplier.
|
|
502
|
+
* @param skipGlobalTransform - If true, skip applying the global world transform matrix.
|
|
503
|
+
*/
|
|
504
|
+
setContextTransform(e, t, a, n) {
|
|
505
|
+
var h;
|
|
506
|
+
const s = n ? F.IDENTITY : ((h = this._renderer.globalUniforms.globalUniformData) == null ? void 0 : h.worldTransformMatrix) || F.IDENTITY;
|
|
507
|
+
let r = gt;
|
|
508
|
+
r.copyFrom(s), r.append(e);
|
|
509
|
+
const i = this._projTransform, c = this.activeResolution;
|
|
510
|
+
if (a = a || c, i) {
|
|
511
|
+
const l = F.shared;
|
|
512
|
+
l.copyFrom(r), l.prepend(i), r = l;
|
|
513
|
+
}
|
|
514
|
+
t ? this.activeContext.setTransform(
|
|
515
|
+
r.a * a,
|
|
516
|
+
r.b * a,
|
|
517
|
+
r.c * a,
|
|
518
|
+
r.d * a,
|
|
519
|
+
r.tx * c | 0,
|
|
520
|
+
r.ty * c | 0
|
|
521
|
+
) : this.activeContext.setTransform(
|
|
522
|
+
r.a * a,
|
|
523
|
+
r.b * a,
|
|
524
|
+
r.c * a,
|
|
525
|
+
r.d * a,
|
|
526
|
+
r.tx * c,
|
|
527
|
+
r.ty * c
|
|
528
|
+
);
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Clears the current render target, optionally filling with a color.
|
|
532
|
+
* @param clearColor - Color to fill after clearing.
|
|
533
|
+
* @param alpha - Alpha override for the clear color.
|
|
534
|
+
*/
|
|
535
|
+
clear(e, t) {
|
|
536
|
+
const a = this.activeContext, n = this._renderer;
|
|
537
|
+
if (a.clearRect(0, 0, n.width, n.height), e) {
|
|
538
|
+
const s = ee.shared.setValue(e);
|
|
539
|
+
a.globalAlpha = t ?? s.alpha, a.fillStyle = s.toHex(), a.fillRect(0, 0, n.width, n.height), a.globalAlpha = 1;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* Sets the active blend mode.
|
|
544
|
+
* @param blendMode - Pixi blend mode.
|
|
545
|
+
*/
|
|
546
|
+
setBlendMode(e) {
|
|
547
|
+
if (this._activeBlendMode === e) return;
|
|
548
|
+
this._activeBlendMode = e, this._outerBlend = !1;
|
|
549
|
+
const t = this.blendModes[e];
|
|
550
|
+
if (!t) {
|
|
551
|
+
this._warnedBlendModes.has(e) || (console.warn(
|
|
552
|
+
`CanvasRenderer: blend mode "${e}" is not supported in Canvas2D; falling back to "source-over".`
|
|
553
|
+
), this._warnedBlendModes.add(e)), this.activeContext.globalCompositeOperation = "source-over";
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
this.activeContext.globalCompositeOperation = t;
|
|
557
|
+
}
|
|
558
|
+
/** Releases context references. */
|
|
559
|
+
destroy() {
|
|
560
|
+
this.rootContext = null, this.activeContext = null, this._warnedBlendModes.clear();
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
Ue.extension = {
|
|
564
|
+
type: [
|
|
565
|
+
R.CanvasSystem
|
|
566
|
+
],
|
|
567
|
+
name: "canvasContext"
|
|
568
|
+
};
|
|
569
|
+
class Oe {
|
|
570
|
+
constructor() {
|
|
571
|
+
this.maxTextures = 16, this.maxBatchableTextures = 16, this.maxUniformBindings = 0;
|
|
572
|
+
}
|
|
573
|
+
init() {
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
Oe.extension = {
|
|
577
|
+
type: [
|
|
578
|
+
R.CanvasSystem
|
|
579
|
+
],
|
|
580
|
+
name: "limits"
|
|
581
|
+
};
|
|
582
|
+
const mt = "#808080", ie = new F(), vt = new F(), yt = new F(), Ce = new F();
|
|
583
|
+
function Ct(o, e, t) {
|
|
584
|
+
o.beginPath();
|
|
585
|
+
for (let a = 0; a < t.length; a += 3) {
|
|
586
|
+
const n = t[a] * 2, s = t[a + 1] * 2, r = t[a + 2] * 2;
|
|
587
|
+
o.moveTo(e[n], e[n + 1]), o.lineTo(e[s], e[s + 1]), o.lineTo(e[r], e[r + 1]), o.closePath();
|
|
588
|
+
}
|
|
589
|
+
o.fill();
|
|
590
|
+
}
|
|
591
|
+
function xt(o) {
|
|
592
|
+
return `#${(o & 16777215).toString(16).padStart(6, "0")}`;
|
|
593
|
+
}
|
|
594
|
+
function Tt(o, e, t, a, n, s) {
|
|
595
|
+
s = Math.max(0, Math.min(s, Math.min(a, n) / 2)), o.moveTo(e + s, t), o.lineTo(e + a - s, t), o.quadraticCurveTo(e + a, t, e + a, t + s), o.lineTo(e + a, t + n - s), o.quadraticCurveTo(e + a, t + n, e + a - s, t + n), o.lineTo(e + s, t + n), o.quadraticCurveTo(e, t + n, e, t + n - s), o.lineTo(e, t + s), o.quadraticCurveTo(e, t, e + s, t);
|
|
596
|
+
}
|
|
597
|
+
function le(o, e) {
|
|
598
|
+
switch (e.type) {
|
|
599
|
+
case "rectangle": {
|
|
600
|
+
const t = e;
|
|
601
|
+
o.rect(t.x, t.y, t.width, t.height);
|
|
602
|
+
break;
|
|
603
|
+
}
|
|
604
|
+
case "roundedRectangle": {
|
|
605
|
+
const t = e;
|
|
606
|
+
Tt(o, t.x, t.y, t.width, t.height, t.radius);
|
|
607
|
+
break;
|
|
608
|
+
}
|
|
609
|
+
case "circle": {
|
|
610
|
+
const t = e;
|
|
611
|
+
o.arc(t.x, t.y, t.radius, 0, Math.PI * 2);
|
|
612
|
+
break;
|
|
613
|
+
}
|
|
614
|
+
case "ellipse": {
|
|
615
|
+
const t = e;
|
|
616
|
+
o.ellipse ? o.ellipse(t.x, t.y, t.halfWidth, t.halfHeight, 0, 0, Math.PI * 2) : (o.save(), o.translate(t.x, t.y), o.scale(t.halfWidth, t.halfHeight), o.arc(0, 0, 1, 0, Math.PI * 2), o.restore());
|
|
617
|
+
break;
|
|
618
|
+
}
|
|
619
|
+
case "triangle": {
|
|
620
|
+
const t = e;
|
|
621
|
+
o.moveTo(t.x, t.y), o.lineTo(t.x2, t.y2), o.lineTo(t.x3, t.y3), o.closePath();
|
|
622
|
+
break;
|
|
623
|
+
}
|
|
624
|
+
case "polygon":
|
|
625
|
+
default: {
|
|
626
|
+
const t = e, a = t.points;
|
|
627
|
+
if (!(a != null && a.length)) break;
|
|
628
|
+
o.moveTo(a[0], a[1]);
|
|
629
|
+
for (let n = 2; n < a.length; n += 2)
|
|
630
|
+
o.lineTo(a[n], a[n + 1]);
|
|
631
|
+
t.closePath && o.closePath();
|
|
632
|
+
break;
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
function _t(o, e) {
|
|
637
|
+
if (!(e != null && e.length)) return !1;
|
|
638
|
+
for (let t = 0; t < e.length; t++) {
|
|
639
|
+
const a = e[t];
|
|
640
|
+
if (!(a != null && a.shape)) continue;
|
|
641
|
+
const n = a.transform, s = n && !n.isIdentity();
|
|
642
|
+
s && (o.save(), o.transform(n.a, n.b, n.c, n.d, n.tx, n.ty)), le(o, a.shape), s && o.restore();
|
|
643
|
+
}
|
|
644
|
+
return !0;
|
|
645
|
+
}
|
|
646
|
+
function Pt(o, e, t, a) {
|
|
647
|
+
const n = o.fill;
|
|
648
|
+
if (n instanceof Qe) {
|
|
649
|
+
n.buildGradient();
|
|
650
|
+
const r = n.texture;
|
|
651
|
+
if (r) {
|
|
652
|
+
const i = d.getTintedPattern(r, e), c = t ? Ce.copyFrom(t).scale(r.source.pixelWidth, r.source.pixelHeight) : Ce.copyFrom(n.transform);
|
|
653
|
+
return a && !o.textureSpace && c.append(a), d.applyPatternTransform(i, c), i;
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
if (n instanceof Ze) {
|
|
657
|
+
const r = d.getTintedPattern(n.texture, e);
|
|
658
|
+
return d.applyPatternTransform(r, n.transform), r;
|
|
659
|
+
}
|
|
660
|
+
const s = o.texture;
|
|
661
|
+
if (s && s !== He.WHITE) {
|
|
662
|
+
if (!s.source.resource)
|
|
663
|
+
return mt;
|
|
664
|
+
const r = d.getTintedPattern(s, e), i = t ? Ce.copyFrom(t).scale(s.source.pixelWidth, s.source.pixelHeight) : o.matrix;
|
|
665
|
+
return d.applyPatternTransform(r, i), r;
|
|
666
|
+
}
|
|
667
|
+
return xt(e);
|
|
668
|
+
}
|
|
669
|
+
class Ee {
|
|
670
|
+
constructor() {
|
|
671
|
+
this.shader = null;
|
|
672
|
+
}
|
|
673
|
+
contextChange(e) {
|
|
674
|
+
}
|
|
675
|
+
execute(e, t) {
|
|
676
|
+
var V, G, b, P, j, se, te;
|
|
677
|
+
const a = e.renderer, n = a.canvasContext, s = n.activeContext, r = t.groupTransform, i = ((V = a.globalUniforms.globalUniformData) == null ? void 0 : V.worldColor) ?? 4294967295, c = t.groupColorAlpha, h = (i >>> 24 & 255) / 255, l = (c >>> 24 & 255) / 255, f = ((G = a.filter) == null ? void 0 : G.alphaMultiplier) ?? 1, x = h * l * f;
|
|
678
|
+
if (x <= 0) return;
|
|
679
|
+
const p = i & 16777215, y = c & 16777215, T = Re(ce(y, p)), v = a._roundPixels | t._roundPixels;
|
|
680
|
+
s.save(), n.setContextTransform(r, v === 1), n.setBlendMode(t.groupBlendMode);
|
|
681
|
+
const H = t.context.instructions;
|
|
682
|
+
for (let ne = 0; ne < H.length; ne++) {
|
|
683
|
+
const J = H[ne];
|
|
684
|
+
if (J.action === "texture") {
|
|
685
|
+
const m = J.data, C = m.image, _ = C ? d.getCanvasSource(C) : null;
|
|
686
|
+
if (!_) continue;
|
|
687
|
+
const L = m.alpha * x;
|
|
688
|
+
if (L <= 0) continue;
|
|
689
|
+
const A = ce(m.style, T);
|
|
690
|
+
s.globalAlpha = L;
|
|
691
|
+
let k = _;
|
|
692
|
+
A !== 16777215 && (k = d.getTintedCanvas({ texture: C }, A));
|
|
693
|
+
const U = C.frame, O = C.source._resolution ?? C.source.resolution ?? 1;
|
|
694
|
+
let B = U.x * O, W = U.y * O;
|
|
695
|
+
const $ = U.width * O, u = U.height * O;
|
|
696
|
+
k !== _ && (B = 0, W = 0);
|
|
697
|
+
const N = m.transform, Y = N && !N.isIdentity(), M = C.rotate;
|
|
698
|
+
Y || M ? (ie.copyFrom(r), Y && ie.append(N), M && D.matrixAppendRotationInv(ie, M, m.dx, m.dy, m.dw, m.dh), n.setContextTransform(ie, v === 1)) : n.setContextTransform(r, v === 1), s.drawImage(
|
|
699
|
+
k,
|
|
700
|
+
B,
|
|
701
|
+
W,
|
|
702
|
+
k === _ ? $ : k.width,
|
|
703
|
+
k === _ ? u : k.height,
|
|
704
|
+
M ? 0 : m.dx,
|
|
705
|
+
M ? 0 : m.dy,
|
|
706
|
+
m.dw,
|
|
707
|
+
m.dh
|
|
708
|
+
), (Y || M) && n.setContextTransform(r, v === 1);
|
|
709
|
+
continue;
|
|
710
|
+
}
|
|
711
|
+
const w = J.data, S = (b = w == null ? void 0 : w.path) == null ? void 0 : b.shapePath;
|
|
712
|
+
if (!((P = S == null ? void 0 : S.shapePrimitives) != null && P.length)) continue;
|
|
713
|
+
const I = w.style, de = ce(I.color, T), ae = I.alpha * x;
|
|
714
|
+
if (ae <= 0) continue;
|
|
715
|
+
const q = J.action === "stroke";
|
|
716
|
+
if (s.globalAlpha = ae, q) {
|
|
717
|
+
const m = I;
|
|
718
|
+
s.lineWidth = m.width, s.lineCap = m.cap, s.lineJoin = m.join, s.miterLimit = m.miterLimit;
|
|
719
|
+
}
|
|
720
|
+
const X = S.shapePrimitives;
|
|
721
|
+
if (!q && ((te = (se = (j = w.hole) == null ? void 0 : j.shapePath) == null ? void 0 : se.shapePrimitives) != null && te.length)) {
|
|
722
|
+
const m = X[X.length - 1];
|
|
723
|
+
m.holes = w.hole.shapePath.shapePrimitives;
|
|
724
|
+
}
|
|
725
|
+
for (let m = 0; m < X.length; m++) {
|
|
726
|
+
const C = X[m];
|
|
727
|
+
if (!(C != null && C.shape)) continue;
|
|
728
|
+
const _ = C.transform, L = _ && !_.isIdentity(), A = I.texture && I.texture !== He.WHITE, k = I.textureSpace === "global" ? _ : null, U = A ? ze(vt, I, C.shape, k) : null, O = L ? yt.copyFrom(r).append(_) : r, B = Pt(
|
|
729
|
+
I,
|
|
730
|
+
de,
|
|
731
|
+
U,
|
|
732
|
+
O
|
|
733
|
+
);
|
|
734
|
+
if (L && (s.save(), s.transform(_.a, _.b, _.c, _.d, _.tx, _.ty)), q) {
|
|
735
|
+
const W = I;
|
|
736
|
+
if (W.alignment !== 0.5 && !W.pixelLine) {
|
|
737
|
+
const u = [], N = [], Y = [], M = Je[C.shape.type];
|
|
738
|
+
if (M != null && M.build(C.shape, u)) {
|
|
739
|
+
const Te = C.shape.closePath ?? !0;
|
|
740
|
+
Ke(u, W, !1, Te, N, Y), s.fillStyle = B, Ct(s, N, Y);
|
|
741
|
+
} else
|
|
742
|
+
s.strokeStyle = B, s.beginPath(), le(s, C.shape), s.stroke();
|
|
743
|
+
} else
|
|
744
|
+
s.strokeStyle = B, s.beginPath(), le(s, C.shape), s.stroke();
|
|
745
|
+
} else
|
|
746
|
+
s.fillStyle = B, s.beginPath(), le(s, C.shape), _t(s, C.holes) ? s.fill("evenodd") : s.fill();
|
|
747
|
+
L && s.restore();
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
s.restore();
|
|
751
|
+
}
|
|
752
|
+
destroy() {
|
|
753
|
+
this.shader = null;
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
Ee.extension = {
|
|
757
|
+
type: [
|
|
758
|
+
R.CanvasPipesAdaptor
|
|
759
|
+
],
|
|
760
|
+
name: "graphics"
|
|
761
|
+
};
|
|
762
|
+
class Mt {
|
|
763
|
+
/**
|
|
764
|
+
* Initializes the adaptor.
|
|
765
|
+
* @param renderer - Canvas renderer instance.
|
|
766
|
+
* @param renderTargetSystem - The render target system.
|
|
767
|
+
* @advanced
|
|
768
|
+
*/
|
|
769
|
+
init(e, t) {
|
|
770
|
+
this._renderer = e, this._renderTargetSystem = t;
|
|
771
|
+
}
|
|
772
|
+
/**
|
|
773
|
+
* Creates a GPU render target for canvas.
|
|
774
|
+
* @param renderTarget - Render target to initialize.
|
|
775
|
+
* @advanced
|
|
776
|
+
*/
|
|
777
|
+
initGpuRenderTarget(e) {
|
|
778
|
+
const t = e.colorTexture, { canvas: a, context: n } = this._ensureCanvas(t);
|
|
779
|
+
return {
|
|
780
|
+
canvas: a,
|
|
781
|
+
context: n,
|
|
782
|
+
width: a.width,
|
|
783
|
+
height: a.height
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
/**
|
|
787
|
+
* Resizes the backing canvas for a render target.
|
|
788
|
+
* @param renderTarget - Render target to resize.
|
|
789
|
+
* @advanced
|
|
790
|
+
*/
|
|
791
|
+
resizeGpuRenderTarget(e) {
|
|
792
|
+
const t = e.colorTexture, { canvas: a } = this._ensureCanvas(t);
|
|
793
|
+
a.width = e.pixelWidth, a.height = e.pixelHeight;
|
|
794
|
+
}
|
|
795
|
+
/**
|
|
796
|
+
* Starts a render pass on the canvas target.
|
|
797
|
+
* @param renderTarget - Target to render to.
|
|
798
|
+
* @param clear - Clear mode.
|
|
799
|
+
* @param clearColor - Optional clear color.
|
|
800
|
+
* @param viewport - Optional viewport.
|
|
801
|
+
* @advanced
|
|
802
|
+
*/
|
|
803
|
+
startRenderPass(e, t, a, n) {
|
|
804
|
+
const s = this._renderTargetSystem.getGpuRenderTarget(e);
|
|
805
|
+
this._renderer.canvasContext.activeContext = s.context, this._renderer.canvasContext.activeResolution = e.resolution, t && this.clear(e, t, a, n);
|
|
806
|
+
}
|
|
807
|
+
/**
|
|
808
|
+
* Clears the render target.
|
|
809
|
+
* @param renderTarget - Target to clear.
|
|
810
|
+
* @param _clear - Clear mode (unused).
|
|
811
|
+
* @param clearColor - Optional clear color.
|
|
812
|
+
* @param viewport - Optional viewport rectangle.
|
|
813
|
+
* @advanced
|
|
814
|
+
*/
|
|
815
|
+
clear(e, t, a, n) {
|
|
816
|
+
const r = this._renderTargetSystem.getGpuRenderTarget(e).context, i = n || { x: 0, y: 0, width: e.pixelWidth, height: e.pixelHeight };
|
|
817
|
+
if (r.setTransform(1, 0, 0, 1, 0, 0), r.clearRect(i.x, i.y, i.width, i.height), a) {
|
|
818
|
+
const c = ee.shared.setValue(a);
|
|
819
|
+
c.alpha > 0 && (r.globalAlpha = c.alpha, r.fillStyle = c.toHex(), r.fillRect(i.x, i.y, i.width, i.height), r.globalAlpha = 1);
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
/**
|
|
823
|
+
* Finishes the render pass (no-op for canvas).
|
|
824
|
+
* @advanced
|
|
825
|
+
*/
|
|
826
|
+
finishRenderPass() {
|
|
827
|
+
}
|
|
828
|
+
/**
|
|
829
|
+
* Copies a render target into a texture source.
|
|
830
|
+
* @param {RenderTarget} sourceRenderSurfaceTexture - Source render target.
|
|
831
|
+
* @param {Texture} destinationTexture - Destination texture.
|
|
832
|
+
* @param {object} originSrc - Source origin.
|
|
833
|
+
* @param {number} originSrc.x - Source x origin.
|
|
834
|
+
* @param {number} originSrc.y - Source y origin.
|
|
835
|
+
* @param {object} size - Copy size.
|
|
836
|
+
* @param {number} size.width - Copy width.
|
|
837
|
+
* @param {number} size.height - Copy height.
|
|
838
|
+
* @param {object} [originDest] - Destination origin.
|
|
839
|
+
* @param {number} originDest.x - Destination x origin.
|
|
840
|
+
* @param {number} originDest.y - Destination y origin.
|
|
841
|
+
* @advanced
|
|
842
|
+
*/
|
|
843
|
+
copyToTexture(e, t, a, n, s) {
|
|
844
|
+
const i = this._renderTargetSystem.getGpuRenderTarget(e).canvas, c = t.source, { context: h } = this._ensureCanvas(c), l = (s == null ? void 0 : s.x) ?? 0, f = (s == null ? void 0 : s.y) ?? 0;
|
|
845
|
+
return h.drawImage(
|
|
846
|
+
i,
|
|
847
|
+
a.x,
|
|
848
|
+
a.y,
|
|
849
|
+
n.width,
|
|
850
|
+
n.height,
|
|
851
|
+
l,
|
|
852
|
+
f,
|
|
853
|
+
n.width,
|
|
854
|
+
n.height
|
|
855
|
+
), c.update(), t;
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* Destroys a GPU render target (no-op for canvas).
|
|
859
|
+
* @param _gpuRenderTarget - Target to destroy.
|
|
860
|
+
* @advanced
|
|
861
|
+
*/
|
|
862
|
+
destroyGpuRenderTarget(e) {
|
|
863
|
+
}
|
|
864
|
+
_ensureCanvas(e) {
|
|
865
|
+
let t = e.resource;
|
|
866
|
+
(!t || !et.test(t)) && (t = E.get().createCanvas(e.pixelWidth, e.pixelHeight), e.resource = t), (t.width !== e.pixelWidth || t.height !== e.pixelHeight) && (t.width = e.pixelWidth, t.height = e.pixelHeight);
|
|
867
|
+
const a = t.getContext("2d");
|
|
868
|
+
return { canvas: t, context: a };
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
class Fe extends at {
|
|
872
|
+
constructor(e) {
|
|
873
|
+
super(e), this.adaptor = new Mt(), this.adaptor.init(e, this);
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
Fe.extension = {
|
|
877
|
+
type: [R.CanvasSystem],
|
|
878
|
+
name: "renderTarget"
|
|
879
|
+
};
|
|
880
|
+
class Ve {
|
|
881
|
+
/**
|
|
882
|
+
* @param renderer - The owning CanvasRenderer.
|
|
883
|
+
*/
|
|
884
|
+
constructor(e) {
|
|
885
|
+
}
|
|
886
|
+
/** Initializes the system (no-op for canvas). */
|
|
887
|
+
init() {
|
|
888
|
+
}
|
|
889
|
+
/**
|
|
890
|
+
* Initializes a texture source (no-op for canvas).
|
|
891
|
+
* @param _source - Texture source.
|
|
892
|
+
*/
|
|
893
|
+
initSource(e) {
|
|
894
|
+
}
|
|
895
|
+
/**
|
|
896
|
+
* Creates a canvas containing the texture's frame.
|
|
897
|
+
* @param texture - Texture to render.
|
|
898
|
+
*/
|
|
899
|
+
generateCanvas(e) {
|
|
900
|
+
const t = E.get().createCanvas(), a = t.getContext("2d"), n = d.getCanvasSource(e);
|
|
901
|
+
if (!n)
|
|
902
|
+
return t;
|
|
903
|
+
const s = e.frame, r = e.source._resolution ?? e.source.resolution ?? 1, i = s.x * r, c = s.y * r, h = s.width * r, l = s.height * r;
|
|
904
|
+
return t.width = Math.ceil(h), t.height = Math.ceil(l), a.drawImage(
|
|
905
|
+
n,
|
|
906
|
+
i,
|
|
907
|
+
c,
|
|
908
|
+
h,
|
|
909
|
+
l,
|
|
910
|
+
0,
|
|
911
|
+
0,
|
|
912
|
+
h,
|
|
913
|
+
l
|
|
914
|
+
), t;
|
|
915
|
+
}
|
|
916
|
+
/**
|
|
917
|
+
* Reads pixel data from a texture.
|
|
918
|
+
* @param texture - Texture to read.
|
|
919
|
+
*/
|
|
920
|
+
getPixels(e) {
|
|
921
|
+
const t = this.generateCanvas(e);
|
|
922
|
+
return {
|
|
923
|
+
pixels: t.getContext("2d", { willReadFrequently: !0 }).getImageData(0, 0, t.width, t.height).data,
|
|
924
|
+
width: t.width,
|
|
925
|
+
height: t.height
|
|
926
|
+
};
|
|
927
|
+
}
|
|
928
|
+
/** Destroys the system (no-op for canvas). */
|
|
929
|
+
destroy() {
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
Ve.extension = {
|
|
933
|
+
type: [
|
|
934
|
+
R.CanvasSystem
|
|
935
|
+
],
|
|
936
|
+
name: "texture"
|
|
937
|
+
};
|
|
938
|
+
const bt = [
|
|
939
|
+
...st,
|
|
940
|
+
Ue,
|
|
941
|
+
Oe,
|
|
942
|
+
Ve,
|
|
943
|
+
Fe
|
|
944
|
+
], wt = [
|
|
945
|
+
ot,
|
|
946
|
+
rt,
|
|
947
|
+
it,
|
|
948
|
+
ct,
|
|
949
|
+
lt,
|
|
950
|
+
Ge,
|
|
951
|
+
We,
|
|
952
|
+
ht
|
|
953
|
+
], kt = [
|
|
954
|
+
dt,
|
|
955
|
+
Ee
|
|
956
|
+
], qe = [], Le = [], $e = [];
|
|
957
|
+
he.handleByNamedList(R.CanvasSystem, qe);
|
|
958
|
+
he.handleByNamedList(R.CanvasPipes, Le);
|
|
959
|
+
he.handleByNamedList(R.CanvasPipesAdaptor, $e);
|
|
960
|
+
he.add(...bt, ...wt, ...kt);
|
|
961
|
+
class At extends tt {
|
|
962
|
+
constructor() {
|
|
963
|
+
const e = {
|
|
964
|
+
name: "canvas",
|
|
965
|
+
type: nt.CANVAS,
|
|
966
|
+
systems: qe,
|
|
967
|
+
renderPipes: Le,
|
|
968
|
+
renderPipeAdaptors: $e
|
|
969
|
+
};
|
|
970
|
+
super(e);
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
export {
|
|
974
|
+
At as CanvasRenderer
|
|
975
|
+
};
|
|
976
|
+
//# sourceMappingURL=CanvasRenderer-DVQieOII.js.map
|