@tradecanvas/core 1.10.0 → 1.12.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/README.md +2 -4
- package/dist/{WebGLSeriesRenderer-DQOPCwno.js → WebGLSeriesRenderer-CLVnGxIS.js} +335 -198
- package/dist/WebGLSeriesRenderer-CLVnGxIS.js.map +1 -0
- package/dist/WebGLSeriesRenderer-rB3-CqXS.cjs +429 -0
- package/dist/WebGLSeriesRenderer-rB3-CqXS.cjs.map +1 -0
- package/dist/charts/BaselineRenderer.d.ts.map +1 -1
- package/dist/charts/DepthHeatmapBuffer.d.ts +6 -3
- package/dist/charts/DepthHeatmapBuffer.d.ts.map +1 -1
- package/dist/charts/KagiRenderer.d.ts.map +1 -1
- package/dist/charts/MarketProfileRenderer.d.ts +2 -0
- package/dist/charts/MarketProfileRenderer.d.ts.map +1 -1
- package/dist/charts/PointAndFigureRenderer.d.ts.map +1 -1
- package/dist/charts/VolumeCandleRenderer.d.ts.map +1 -1
- package/dist/charts/pixelGrid.d.ts +10 -0
- package/dist/charts/pixelGrid.d.ts.map +1 -1
- package/dist/engine/RenderEngine.d.ts +15 -4
- package/dist/engine/RenderEngine.d.ts.map +1 -1
- package/dist/engine/gpu.d.ts +18 -3
- package/dist/engine/gpu.d.ts.map +1 -1
- package/dist/engine/gpuContexts.d.ts +23 -0
- package/dist/engine/gpuContexts.d.ts.map +1 -0
- package/dist/engine/index.d.ts +3 -1
- package/dist/engine/index.d.ts.map +1 -1
- package/dist/engine/loadWebGL.d.ts +15 -2
- package/dist/engine/loadWebGL.d.ts.map +1 -1
- package/dist/gridLines-CVQJ3gzb.cjs +2 -0
- package/dist/gridLines-CVQJ3gzb.cjs.map +1 -0
- package/dist/{gridLines-kFhXyH-u.js → gridLines-ovHZBvAe.js} +61 -24
- package/dist/gridLines-ovHZBvAe.js.map +1 -0
- package/dist/index.cjs +6 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3327 -2543
- package/dist/index.js.map +1 -1
- package/dist/indicators/index.d.ts +13 -1
- package/dist/indicators/index.d.ts.map +1 -1
- package/dist/indicators/math.d.ts +2 -0
- package/dist/indicators/math.d.ts.map +1 -1
- package/dist/indicators/overlay/HammingMA.d.ts +19 -0
- package/dist/indicators/overlay/HammingMA.d.ts.map +1 -0
- package/dist/indicators/overlay/MAChannel.d.ts +13 -0
- package/dist/indicators/overlay/MAChannel.d.ts.map +1 -0
- package/dist/indicators/overlay/MACross.d.ts.map +1 -1
- package/dist/indicators/overlay/MovingAverageSets.d.ts +20 -0
- package/dist/indicators/overlay/MovingAverageSets.d.ts.map +1 -0
- package/dist/indicators/overlay/PivotPoints.d.ts +5 -0
- package/dist/indicators/overlay/PivotPoints.d.ts.map +1 -1
- package/dist/indicators/overlay/PriceAverages.d.ts +25 -0
- package/dist/indicators/overlay/PriceAverages.d.ts.map +1 -0
- package/dist/indicators/overlay/VolatilityIndex.d.ts +13 -0
- package/dist/indicators/overlay/VolatilityIndex.d.ts.map +1 -0
- package/dist/indicators/panel/AccumulativeSwingIndex.d.ts +13 -0
- package/dist/indicators/panel/AccumulativeSwingIndex.d.ts.map +1 -0
- package/dist/indicators/panel/AdvanceDecline.d.ts +18 -0
- package/dist/indicators/panel/AdvanceDecline.d.ts.map +1 -0
- package/dist/indicators/panel/ChopZone.d.ts +17 -0
- package/dist/indicators/panel/ChopZone.d.ts.map +1 -0
- package/dist/indicators/panel/MajorityRule.d.ts +15 -0
- package/dist/indicators/panel/MajorityRule.d.ts.map +1 -0
- package/dist/indicators/panel/PriceOscillator.d.ts +8 -0
- package/dist/indicators/panel/PriceOscillator.d.ts.map +1 -0
- package/dist/indicators/panel/SMIErgodic.d.ts +12 -0
- package/dist/indicators/panel/SMIErgodic.d.ts.map +1 -0
- package/dist/indicators/panel/VolatilityEstimators.d.ts +29 -0
- package/dist/indicators/panel/VolatilityEstimators.d.ts.map +1 -0
- package/dist/indicators/registry.d.ts.map +1 -1
- package/dist/indicators/symbols/symbolIndicators.d.ts +27 -0
- package/dist/indicators/symbols/symbolIndicators.d.ts.map +1 -1
- package/dist/webgl/WebGLSeriesRenderer.d.ts +31 -12
- package/dist/webgl/WebGLSeriesRenderer.d.ts.map +1 -1
- package/dist/webgl/commandDrawer.d.ts.map +1 -1
- package/dist/webgl/recorder.d.ts +18 -1
- package/dist/webgl/recorder.d.ts.map +1 -1
- package/dist/webgl/shaders.d.ts +8 -7
- package/dist/webgl/shaders.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/WebGLSeriesRenderer-DQOPCwno.js.map +0 -1
- package/dist/WebGLSeriesRenderer-DspCYR38.cjs +0 -429
- package/dist/WebGLSeriesRenderer-DspCYR38.cjs.map +0 -1
- package/dist/gridLines-J41F0DQ6.cjs +0 -2
- package/dist/gridLines-J41F0DQ6.cjs.map +0 -1
- package/dist/gridLines-kFhXyH-u.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { resolveVolumeColors as
|
|
3
|
-
var
|
|
1
|
+
import { c as e, d as t, f as n, l as r, r as i, t as a } from "./gridLines-ovHZBvAe.js";
|
|
2
|
+
import { resolveVolumeColors as o } from "@tradecanvas/commons";
|
|
3
|
+
var s = (e, t) => e.time === t.time && e.open === t.open && e.high === t.high && e.low === t.low && e.close === t.close && e.volume === t.volume, c = class {
|
|
4
4
|
buffer = new Float32Array();
|
|
5
5
|
count = 0;
|
|
6
6
|
basePrice = 0;
|
|
@@ -24,12 +24,12 @@ var a = (e, t) => e.time === t.time && e.open === t.open && e.high === t.high &&
|
|
|
24
24
|
to: 0
|
|
25
25
|
};
|
|
26
26
|
let n = this.count;
|
|
27
|
-
if (!(e === this.source && n > 0 && t >= n && this.samples.every(({ index: t, bar: n }) =>
|
|
27
|
+
if (!(e === this.source && n > 0 && t >= n && this.samples.every(({ index: t, bar: n }) => s(e[t], n)))) return this.basePrice = e[t - 1].close, this.ensure(t), this.write(e, 0, t), this.remember(e), {
|
|
28
28
|
full: !0,
|
|
29
29
|
from: 0,
|
|
30
30
|
to: t
|
|
31
31
|
};
|
|
32
|
-
let r = this.last !== null &&
|
|
32
|
+
let r = this.last !== null && s(e[n - 1], this.last) ? n : n - 1;
|
|
33
33
|
return t > this.buffer.length / 6 ? (this.ensure(t), this.write(e, 0, t), this.remember(e), {
|
|
34
34
|
full: !0,
|
|
35
35
|
from: 0,
|
|
@@ -62,11 +62,11 @@ var a = (e, t) => e.time === t.time && e.open === t.open && e.high === t.high &&
|
|
|
62
62
|
bar: { ...e[t] }
|
|
63
63
|
})), this.last = { ...e[t - 1] }, this.source = e;
|
|
64
64
|
}
|
|
65
|
-
},
|
|
66
|
-
function
|
|
65
|
+
}, l = /* @__PURE__ */ new Map(), u;
|
|
66
|
+
function d(e, t) {
|
|
67
67
|
return e.endsWith("%") ? parseFloat(e) / 100 : parseFloat(e) / t;
|
|
68
68
|
}
|
|
69
|
-
function
|
|
69
|
+
function f(e) {
|
|
70
70
|
let t = e.trim();
|
|
71
71
|
if (t.toLowerCase() === "transparent") return [
|
|
72
72
|
0,
|
|
@@ -88,28 +88,28 @@ function u(e) {
|
|
|
88
88
|
}
|
|
89
89
|
let r = /^rgba?\(\s*([\d.]+%?)[\s,]+([\d.]+%?)[\s,]+([\d.]+%?)(?:\s*[,/]\s*([\d.]+%?))?\s*\)$/i.exec(t);
|
|
90
90
|
return r ? [
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
r[4] === void 0 ? 1 :
|
|
91
|
+
d(r[1], 255),
|
|
92
|
+
d(r[2], 255),
|
|
93
|
+
d(r[3], 255),
|
|
94
|
+
r[4] === void 0 ? 1 : d(r[4], 1)
|
|
95
95
|
] : null;
|
|
96
96
|
}
|
|
97
|
-
function
|
|
98
|
-
if (
|
|
97
|
+
function p() {
|
|
98
|
+
if (u !== void 0) return u;
|
|
99
99
|
try {
|
|
100
|
-
|
|
100
|
+
u = typeof OffscreenCanvas < "u" ? new OffscreenCanvas(1, 1).getContext("2d") : typeof document < "u" ? document.createElement("canvas").getContext("2d") : null;
|
|
101
101
|
} catch {
|
|
102
|
-
|
|
102
|
+
u = null;
|
|
103
103
|
}
|
|
104
|
-
return
|
|
104
|
+
return u;
|
|
105
105
|
}
|
|
106
|
-
function
|
|
107
|
-
let t =
|
|
106
|
+
function m(e) {
|
|
107
|
+
let t = p();
|
|
108
108
|
if (!t) return null;
|
|
109
109
|
t.fillStyle = "#000", t.fillStyle = e;
|
|
110
110
|
let n = String(t.fillStyle);
|
|
111
111
|
if (t.fillStyle = "#fff", t.fillStyle = e, String(t.fillStyle) !== n) return null;
|
|
112
|
-
let r =
|
|
112
|
+
let r = f(n);
|
|
113
113
|
if (r) return r;
|
|
114
114
|
t.clearRect(0, 0, 1, 1), t.fillRect(0, 0, 1, 1);
|
|
115
115
|
let i = t.getImageData(0, 0, 1, 1).data;
|
|
@@ -120,23 +120,23 @@ function f(e) {
|
|
|
120
120
|
i[3] / 255
|
|
121
121
|
];
|
|
122
122
|
}
|
|
123
|
-
var
|
|
124
|
-
function
|
|
125
|
-
let t =
|
|
123
|
+
var h = /* @__PURE__ */ new Set();
|
|
124
|
+
function g(e) {
|
|
125
|
+
let t = l.get(e);
|
|
126
126
|
if (t) return t;
|
|
127
|
-
if (
|
|
128
|
-
let n =
|
|
129
|
-
return
|
|
127
|
+
if (h.has(e)) return null;
|
|
128
|
+
let n = f(e) ?? m(e);
|
|
129
|
+
return l.size > 256 && l.clear(), h.size > 256 && h.clear(), n ? l.set(e, n) : h.add(e), n;
|
|
130
130
|
}
|
|
131
|
-
function
|
|
132
|
-
return
|
|
131
|
+
function _(e) {
|
|
132
|
+
return g(e) ?? [
|
|
133
133
|
0,
|
|
134
134
|
0,
|
|
135
135
|
0,
|
|
136
136
|
0
|
|
137
137
|
];
|
|
138
138
|
}
|
|
139
|
-
function
|
|
139
|
+
function v([e, t, n, r]) {
|
|
140
140
|
return [
|
|
141
141
|
e * r,
|
|
142
142
|
t * r,
|
|
@@ -146,7 +146,7 @@ function g([e, t, n, r]) {
|
|
|
146
146
|
}
|
|
147
147
|
//#endregion
|
|
148
148
|
//#region src/webgl/yMapping.ts
|
|
149
|
-
function
|
|
149
|
+
function ee(e, t) {
|
|
150
150
|
let { min: n, max: r } = e.priceRange, { y: i, height: a } = e.chartRect, o = +(e.invertScale === !0), s = {
|
|
151
151
|
log: 0,
|
|
152
152
|
invert: o,
|
|
@@ -185,7 +185,7 @@ function _(e, t) {
|
|
|
185
185
|
}
|
|
186
186
|
//#endregion
|
|
187
187
|
//#region src/webgl/glKit.ts
|
|
188
|
-
var
|
|
188
|
+
var te = class {
|
|
189
189
|
constructor(e) {
|
|
190
190
|
this.gl = e;
|
|
191
191
|
}
|
|
@@ -253,14 +253,14 @@ var v = class {
|
|
|
253
253
|
};
|
|
254
254
|
//#endregion
|
|
255
255
|
//#region src/webgl/polygonSpans.ts
|
|
256
|
-
function
|
|
256
|
+
function ne(e) {
|
|
257
257
|
let t = e.length / 2;
|
|
258
258
|
if (t < 3) return [];
|
|
259
259
|
let n = 0, r = 0;
|
|
260
260
|
for (let i = 1; i < t; i++) e[2 * i] < e[2 * n] && (n = i), e[2 * i] > e[2 * r] && (r = i);
|
|
261
261
|
if (e[2 * n] === e[2 * r]) return [];
|
|
262
262
|
let i = b(e, n, r, 1, t), a = b(e, n, r, -1, t);
|
|
263
|
-
return !i || !a ? null :
|
|
263
|
+
return !i || !a ? null : re(i, a);
|
|
264
264
|
}
|
|
265
265
|
function y(e) {
|
|
266
266
|
let t = 0, n = e.length / 2;
|
|
@@ -290,7 +290,7 @@ var x = class {
|
|
|
290
290
|
return [s(e), s(t)];
|
|
291
291
|
}
|
|
292
292
|
};
|
|
293
|
-
function
|
|
293
|
+
function re(e, t) {
|
|
294
294
|
let n = /* @__PURE__ */ new Set();
|
|
295
295
|
for (let t = 0; t < e.length; t += 2) n.add(e[t]);
|
|
296
296
|
for (let e = 0; e < t.length; e += 2) n.add(t[e]);
|
|
@@ -303,7 +303,7 @@ function te(e, t) {
|
|
|
303
303
|
}
|
|
304
304
|
//#endregion
|
|
305
305
|
//#region src/webgl/recordedShaders.ts
|
|
306
|
-
var S = "#version 300 es\nprecision highp float;\nuniform vec2 u_canvas;\nuniform vec4 u_clip;\n\nvec4 toClip(vec2 dev) {\n return vec4(dev.x / u_canvas.x * 2.0 - 1.0, 1.0 - dev.y / u_canvas.y * 2.0, 0.0, 1.0);\n}\n", C = "\nvec2 corner(int k) {\n if (k == 0) return vec2(0.0, 0.0);\n if (k == 1 || k == 4) return vec2(1.0, 0.0);\n if (k == 2 || k == 3) return vec2(0.0, 1.0);\n return vec2(1.0, 1.0);\n}\nconst vec4 NOWHERE = vec4(-2.0, -2.0, 0.0, 1.0);\n", w = "\n// This fragment's pixel centre in device pixels, y down.\nvec2 pixelCentre() { return vec2(gl_FragCoord.x, u_canvas.y - gl_FragCoord.y); }\n\n// The share of the pixel centred at p inside the clip.\nfloat clipCoverage(vec2 p) {\n vec2 lo = p - 0.5;\n vec2 c = clamp(min(lo + 1.0, u_clip.zw) - max(lo, u_clip.xy), 0.0, 1.0);\n return c.x * c.y;\n}\n",
|
|
306
|
+
var S = "#version 300 es\nprecision highp float;\nuniform vec2 u_canvas;\nuniform vec4 u_clip;\n\nvec4 toClip(vec2 dev) {\n return vec4(dev.x / u_canvas.x * 2.0 - 1.0, 1.0 - dev.y / u_canvas.y * 2.0, 0.0, 1.0);\n}\n", C = "\nvec2 corner(int k) {\n if (k == 0) return vec2(0.0, 0.0);\n if (k == 1 || k == 4) return vec2(1.0, 0.0);\n if (k == 2 || k == 3) return vec2(0.0, 1.0);\n return vec2(1.0, 1.0);\n}\nconst vec4 NOWHERE = vec4(-2.0, -2.0, 0.0, 1.0);\n", w = "\n// This fragment's pixel centre in device pixels, y down.\nvec2 pixelCentre() { return vec2(gl_FragCoord.x, u_canvas.y - gl_FragCoord.y); }\n\n// The share of the pixel centred at p inside the clip.\nfloat clipCoverage(vec2 p) {\n vec2 lo = p - 0.5;\n vec2 c = clamp(min(lo + 1.0, u_clip.zw) - max(lo, u_clip.xy), 0.0, 1.0);\n return c.x * c.y;\n}\n", ie = `${S}${C}
|
|
307
307
|
uniform float u_hw;
|
|
308
308
|
in vec4 a_p0;
|
|
309
309
|
in vec4 a_p1;
|
|
@@ -332,7 +332,7 @@ void main() {
|
|
|
332
332
|
vec2 pos = mix(a - dir * m, b + dir * m, cr.x) + n * mix(-m, m, cr.y);
|
|
333
333
|
gl_Position = toClip(pos);
|
|
334
334
|
}
|
|
335
|
-
`,
|
|
335
|
+
`, ae = `${S}${w}
|
|
336
336
|
uniform vec4 u_color;
|
|
337
337
|
uniform float u_hw;
|
|
338
338
|
uniform int u_cap;
|
|
@@ -411,7 +411,7 @@ void main() {
|
|
|
411
411
|
if (cov <= 0.0) discard;
|
|
412
412
|
outColor = u_color * (cov * clipCov);
|
|
413
413
|
}
|
|
414
|
-
`,
|
|
414
|
+
`, oe = `${S}${C}
|
|
415
415
|
in vec2 a_x;
|
|
416
416
|
in vec4 a_ab;
|
|
417
417
|
in vec2 a_ends;
|
|
@@ -428,7 +428,7 @@ void main() {
|
|
|
428
428
|
vec2 cr = corner(gl_VertexID % 6);
|
|
429
429
|
gl_Position = toClip(mix(vec2(floor(a_x.x), floor(lo) - 1.0), vec2(ceil(a_x.y), ceil(hi) + 1.0), cr));
|
|
430
430
|
}
|
|
431
|
-
`,
|
|
431
|
+
`, se = `${S}${w}
|
|
432
432
|
uniform int u_kind;
|
|
433
433
|
uniform vec4 u_color;
|
|
434
434
|
uniform vec4 u_line;
|
|
@@ -486,7 +486,7 @@ void main() {
|
|
|
486
486
|
vec4 color = u_kind == 1 ? gradient(p) : u_color;
|
|
487
487
|
outColor = color * cov;
|
|
488
488
|
}
|
|
489
|
-
`,
|
|
489
|
+
`, ce = `${S}${C}
|
|
490
490
|
in vec3 a_disc;
|
|
491
491
|
in vec4 a_color;
|
|
492
492
|
flat out vec3 v_disc;
|
|
@@ -497,7 +497,7 @@ void main() {
|
|
|
497
497
|
float m = a_disc.z + 1.0;
|
|
498
498
|
gl_Position = toClip(mix(a_disc.xy - m, a_disc.xy + m, corner(gl_VertexID % 6)));
|
|
499
499
|
}
|
|
500
|
-
`,
|
|
500
|
+
`, le = `${S}${w}
|
|
501
501
|
flat in vec3 v_disc;
|
|
502
502
|
flat in vec4 v_color;
|
|
503
503
|
out vec4 outColor;
|
|
@@ -507,29 +507,36 @@ void main() {
|
|
|
507
507
|
if (cov <= 0.0) discard;
|
|
508
508
|
outColor = v_color * cov;
|
|
509
509
|
}
|
|
510
|
-
`, T = 4, E = T * 4, D = 32, O = 7, k = O * 4,
|
|
510
|
+
`, T = 4, E = T * 4, D = 32, O = 7, k = O * 4, ue = class {
|
|
511
511
|
stroke;
|
|
512
512
|
span;
|
|
513
513
|
disc;
|
|
514
514
|
buffer;
|
|
515
515
|
constructor(e) {
|
|
516
|
-
this.kit = e, this.stroke = e.program(
|
|
516
|
+
this.kit = e, this.stroke = e.program(ie, ae, [
|
|
517
517
|
"a_p0",
|
|
518
518
|
"a_p1",
|
|
519
519
|
"a_p2",
|
|
520
520
|
"a_p3",
|
|
521
521
|
"a_p4",
|
|
522
522
|
"a_p5"
|
|
523
|
-
]), this.span = e.program(
|
|
523
|
+
]), this.span = e.program(oe, se, [
|
|
524
524
|
"a_x",
|
|
525
525
|
"a_ab",
|
|
526
526
|
"a_ends"
|
|
527
|
-
]), this.disc = e.program(
|
|
527
|
+
]), this.disc = e.program(ce, le, ["a_disc", "a_color"]), this.buffer = e.buffer();
|
|
528
528
|
}
|
|
529
529
|
draw(e, t, n, r) {
|
|
530
530
|
let i = this.kit.gl;
|
|
531
531
|
i.enable(i.BLEND);
|
|
532
|
-
for (let a
|
|
532
|
+
for (let a = 0; a < e.length; a++) {
|
|
533
|
+
let o = e[a];
|
|
534
|
+
if (i.blendFunc(i.ONE, i.ONE_MINUS_SRC_ALPHA), i.disable(i.SCISSOR_TEST), o.type === "rects") {
|
|
535
|
+
let t = [o.values];
|
|
536
|
+
for (; e[a + 1]?.type === "rects";) t.push(e[++a].values);
|
|
537
|
+
this.drawRects(t, r);
|
|
538
|
+
} else o.type === "stroke" ? this.drawStroke(o, t, n) : o.type === "fill" ? this.drawFill(o, t, n) : this.drawDiscs(o.values, o.clip, t, n);
|
|
539
|
+
}
|
|
533
540
|
i.disable(i.SCISSOR_TEST);
|
|
534
541
|
}
|
|
535
542
|
destroy() {
|
|
@@ -554,8 +561,10 @@ void main() {
|
|
|
554
561
|
]), !0) : !1;
|
|
555
562
|
}
|
|
556
563
|
drawRects(e, t) {
|
|
557
|
-
let n =
|
|
558
|
-
for (let t
|
|
564
|
+
let n = 0;
|
|
565
|
+
for (let t of e) n += t.length / 8;
|
|
566
|
+
let r = new Float32Array(n * 10), i = 0;
|
|
567
|
+
for (let t of e) for (let e = 0; e < t.length; e += 8, i++) for (let n = 0; n < 8; n++) r[i * 10 + n] = t[e + n];
|
|
559
568
|
t(r, n);
|
|
560
569
|
}
|
|
561
570
|
drawStroke(e, t, n) {
|
|
@@ -610,13 +619,13 @@ void main() {
|
|
|
610
619
|
let i = this.disc;
|
|
611
620
|
this.common(i, t, n, r) && (this.upload(new Float32Array(e)), this.kit.attrib(i, "a_disc", 3, k, 0), this.kit.attrib(i, "a_color", 4, k, 12), this.kit.gl.drawArraysInstanced(this.kit.gl.TRIANGLES, 0, 6, e.length / O));
|
|
612
621
|
}
|
|
613
|
-
},
|
|
622
|
+
}, A = (e, t) => ({
|
|
614
623
|
x0: Math.max(e.x0, t.x0),
|
|
615
624
|
y0: Math.max(e.y0, t.y0),
|
|
616
625
|
x1: Math.min(e.x1, t.x1),
|
|
617
626
|
y1: Math.min(e.y1, t.y1)
|
|
618
|
-
}),
|
|
619
|
-
function
|
|
627
|
+
}), j = (e) => !(e.x1 > e.x0 && e.y1 > e.y0);
|
|
628
|
+
function M(e, t = 0) {
|
|
620
629
|
let n = Infinity, r = Infinity, i = -Infinity, a = -Infinity;
|
|
621
630
|
for (let t = 0; t < e.length; t += 2) {
|
|
622
631
|
let o = e[t], s = e[t + 1];
|
|
@@ -629,7 +638,7 @@ function N(e, t = 0) {
|
|
|
629
638
|
y1: a + t
|
|
630
639
|
};
|
|
631
640
|
}
|
|
632
|
-
function
|
|
641
|
+
function N(e) {
|
|
633
642
|
let t = [...e].sort((e, t) => e.x0 - t.x0), n = [];
|
|
634
643
|
for (let e of t) {
|
|
635
644
|
for (let t = n.length - 1; t >= 0; t--) n[t].x1 <= e.x0 && n.splice(t, 1);
|
|
@@ -640,7 +649,7 @@ function P(e) {
|
|
|
640
649
|
}
|
|
641
650
|
//#endregion
|
|
642
651
|
//#region src/webgl/recordedPath.ts
|
|
643
|
-
var
|
|
652
|
+
var P = class {
|
|
644
653
|
stops = [];
|
|
645
654
|
constructor(e, t, n, r) {
|
|
646
655
|
this.x0 = e, this.y0 = t, this.x1 = n, this.y1 = r;
|
|
@@ -652,14 +661,14 @@ var F = class {
|
|
|
652
661
|
color: t
|
|
653
662
|
});
|
|
654
663
|
}
|
|
655
|
-
},
|
|
664
|
+
}, F = typeof Path2D == "function" ? Path2D : class {}, I = class e extends F {
|
|
656
665
|
calls = [];
|
|
657
666
|
unsupported = !1;
|
|
658
667
|
constructor(t) {
|
|
659
668
|
super(t), t instanceof e ? (this.calls.push(...t.calls), this.unsupported = t.unsupported) : t !== void 0 && (this.unsupported = !0);
|
|
660
669
|
}
|
|
661
670
|
note(e, t, n = t) {
|
|
662
|
-
this.calls.push([e, t]),
|
|
671
|
+
this.calls.push([e, t]), F.prototype[e]?.apply(this, n);
|
|
663
672
|
}
|
|
664
673
|
unfollowed(e, t) {
|
|
665
674
|
this.unsupported = !0, this.note(e, [], t);
|
|
@@ -719,12 +728,12 @@ var F = class {
|
|
|
719
728
|
this.unfollowed("roundRect", e);
|
|
720
729
|
}
|
|
721
730
|
addPath(t, n) {
|
|
722
|
-
!(t instanceof e) || n !== void 0 ? this.unsupported = !0 : (this.calls.push(...t.calls), this.unsupported ||= t.unsupported),
|
|
731
|
+
!(t instanceof e) || n !== void 0 ? this.unsupported = !0 : (this.calls.push(...t.calls), this.unsupported ||= t.unsupported), F.prototype.addPath?.call(this, t, n);
|
|
723
732
|
}
|
|
724
733
|
};
|
|
725
|
-
function
|
|
734
|
+
function de(e) {
|
|
726
735
|
let t = globalThis, n = Object.prototype.hasOwnProperty.call(t, "Path2D"), r = t.Path2D;
|
|
727
|
-
t.Path2D =
|
|
736
|
+
t.Path2D = I;
|
|
728
737
|
try {
|
|
729
738
|
e();
|
|
730
739
|
} finally {
|
|
@@ -733,24 +742,24 @@ function ce(e) {
|
|
|
733
742
|
}
|
|
734
743
|
//#endregion
|
|
735
744
|
//#region src/webgl/strokeGeometry.ts
|
|
736
|
-
var
|
|
737
|
-
function
|
|
745
|
+
var fe = .25;
|
|
746
|
+
function pe(e, t, n, r) {
|
|
738
747
|
if (n === "round") return !1;
|
|
739
748
|
let i = e.points, a = i.length / 2, o = +!e.closed, s = e.closed ? a : a - 1;
|
|
740
749
|
for (let e = o; e < s; e++) {
|
|
741
750
|
let o = (e - 1 + a) % a, s = (e + 1) % a, c = i[2 * e] - i[2 * o], l = i[2 * e + 1] - i[2 * o + 1], u = i[2 * s] - i[2 * e], d = i[2 * s + 1] - i[2 * e + 1], f = Math.hypot(c, l), p = Math.hypot(u, d);
|
|
742
751
|
if (f === 0 || p === 0) continue;
|
|
743
752
|
let m = Math.max(-1, Math.min(1, (c * u + l * d) / (f * p))), h = Math.sqrt((1 + m) / 2);
|
|
744
|
-
if ((n === "miter" && h > 0 && 1 / h <= r ? t * (1 / h - 1) : t * (1 - h)) >
|
|
753
|
+
if ((n === "miter" && h > 0 && 1 / h <= r ? t * (1 / h - 1) : t * (1 - h)) > fe) return !0;
|
|
745
754
|
}
|
|
746
755
|
return !1;
|
|
747
756
|
}
|
|
748
|
-
function
|
|
757
|
+
function me(e, t) {
|
|
749
758
|
let n = e.points;
|
|
750
759
|
for (let e = 2; e < n.length; e += 2) if (Math.hypot(n[e] - n[e - 2], n[e + 1] - n[e - 1]) < t) return !0;
|
|
751
760
|
return !1;
|
|
752
761
|
}
|
|
753
|
-
function
|
|
762
|
+
function he(e) {
|
|
754
763
|
let t = [], n = () => t.push(0, 0, -1, 0);
|
|
755
764
|
n(), n();
|
|
756
765
|
for (let { points: r, closed: i } of e) {
|
|
@@ -764,12 +773,12 @@ function fe(e) {
|
|
|
764
773
|
}
|
|
765
774
|
//#endregion
|
|
766
775
|
//#region src/webgl/recorder.ts
|
|
767
|
-
var
|
|
768
|
-
function
|
|
776
|
+
var L = Math.PI * 2;
|
|
777
|
+
function ge(e, t) {
|
|
769
778
|
let n = 2 * Math.sqrt(Math.max(.2 / Math.max(e, .1), 1e-6));
|
|
770
779
|
return Math.min(512, Math.max(4, Math.ceil(Math.abs(t) / Math.min(n, Math.PI / 4))));
|
|
771
780
|
}
|
|
772
|
-
var
|
|
781
|
+
var R = new Set([
|
|
773
782
|
"fillStyle",
|
|
774
783
|
"strokeStyle",
|
|
775
784
|
"lineWidth",
|
|
@@ -788,21 +797,24 @@ var z = new Set([
|
|
|
788
797
|
"shadowOffsetX",
|
|
789
798
|
"shadowOffsetY",
|
|
790
799
|
"filter"
|
|
791
|
-
]),
|
|
800
|
+
]), z = new Set([
|
|
792
801
|
"fontKerning",
|
|
793
802
|
"fontStretch",
|
|
794
803
|
"fontVariantCaps",
|
|
795
804
|
"letterSpacing",
|
|
796
805
|
"wordSpacing",
|
|
797
806
|
"textRendering"
|
|
798
|
-
]),
|
|
807
|
+
]), B = new Set(["imageSmoothingEnabled", "imageSmoothingQuality"]), V = (e) => !!(e.rect || e.circle) || e.points.length >= 6, _e = class {
|
|
799
808
|
commands = [];
|
|
800
809
|
ctx;
|
|
801
810
|
texts = [];
|
|
811
|
+
takesText = !0;
|
|
802
812
|
state;
|
|
803
813
|
stack = [];
|
|
804
814
|
path = [];
|
|
805
815
|
ok = !0;
|
|
816
|
+
stepStart = 0;
|
|
817
|
+
solid = null;
|
|
806
818
|
constructor(e, t) {
|
|
807
819
|
this.dpr = e, this.measure = t, this.reset({
|
|
808
820
|
x0: 0,
|
|
@@ -811,29 +823,29 @@ var z = new Set([
|
|
|
811
823
|
y1: Infinity
|
|
812
824
|
}), this.ctx = this.proxy();
|
|
813
825
|
}
|
|
814
|
-
region(e) {
|
|
815
|
-
let
|
|
816
|
-
x0: e.x *
|
|
817
|
-
y0: e.y *
|
|
818
|
-
x1: (e.x + e.width) *
|
|
819
|
-
y1: (e.y + e.height) *
|
|
820
|
-
},
|
|
826
|
+
region(e, t) {
|
|
827
|
+
let n = this.dpr, r = {
|
|
828
|
+
x0: e.x * n,
|
|
829
|
+
y0: e.y * n,
|
|
830
|
+
x1: (e.x + e.width) * n,
|
|
831
|
+
y1: (e.y + e.height) * n
|
|
832
|
+
}, i = [], a = t?.text !== !1;
|
|
821
833
|
return {
|
|
822
834
|
step: (e) => {
|
|
823
|
-
this.reset(
|
|
835
|
+
this.reset(r), this.texts = i, this.takesText = a;
|
|
824
836
|
let t = {
|
|
825
837
|
commands: this.commands.length,
|
|
826
|
-
texts:
|
|
838
|
+
texts: i.length
|
|
827
839
|
};
|
|
828
|
-
this.ok = !0;
|
|
840
|
+
this.stepStart = t.commands, this.ok = !0;
|
|
829
841
|
try {
|
|
830
|
-
|
|
842
|
+
de(() => e(this.ctx));
|
|
831
843
|
} catch {
|
|
832
844
|
this.ok = !1;
|
|
833
845
|
}
|
|
834
|
-
return this.ok ? !0 : (this.commands.length = t.commands,
|
|
846
|
+
return this.ok ? !0 : (this.commands.length = t.commands, i.length = t.texts, !1);
|
|
835
847
|
},
|
|
836
|
-
drawText: (e) =>
|
|
848
|
+
drawText: (e) => ve(e, i)
|
|
837
849
|
};
|
|
838
850
|
}
|
|
839
851
|
reset(e) {
|
|
@@ -967,14 +979,14 @@ var z = new Set([
|
|
|
967
979
|
].every(Number.isFinite)) return;
|
|
968
980
|
if (n < 0) throw new DOMException("negative radius", "IndexSizeError");
|
|
969
981
|
let o = i - r;
|
|
970
|
-
o = !a && o >=
|
|
971
|
-
let s = this.current(), c = this.state.transform, l = e + n * Math.cos(r), u = t + n * Math.sin(r), d = !s || s.closed || s.points.length === 2 && Math.abs(s.points[0] - (c[0] * l + c[2] * u + c[4])) < 1e-6 && Math.abs(s.points[1] - (c[1] * l + c[3] * u + c[5])) < 1e-6, f =
|
|
982
|
+
o = !a && o >= L ? L : a && -o >= L ? -L : a ? -(((r - i) % L + L) % L) : (o % L + L) % L;
|
|
983
|
+
let s = this.current(), c = this.state.transform, l = e + n * Math.cos(r), u = t + n * Math.sin(r), d = !s || s.closed || s.points.length === 2 && Math.abs(s.points[0] - (c[0] * l + c[2] * u + c[4])) < 1e-6 && Math.abs(s.points[1] - (c[1] * l + c[3] * u + c[5])) < 1e-6, f = ge(n * Math.abs(c[0]), o);
|
|
972
984
|
for (let i = 0; i <= f; i++) {
|
|
973
985
|
let a = r + o * i / f;
|
|
974
986
|
this.lineTo(e + n * Math.cos(a), t + n * Math.sin(a));
|
|
975
987
|
}
|
|
976
988
|
let p = this.current();
|
|
977
|
-
Math.abs(o) >=
|
|
989
|
+
Math.abs(o) >= L - 1e-9 && d && this.uniform() && p && (p.circle = {
|
|
978
990
|
x: c[0] * e + c[4],
|
|
979
991
|
y: c[3] * t + c[5],
|
|
980
992
|
r: n * Math.abs(c[0])
|
|
@@ -1013,7 +1025,7 @@ var z = new Set([
|
|
|
1013
1025
|
this.path = [], e(), t(), this.path = n;
|
|
1014
1026
|
}
|
|
1015
1027
|
onPath(e, t) {
|
|
1016
|
-
if (!(e instanceof
|
|
1028
|
+
if (!(e instanceof I) || e.unsupported) return this.unsupported();
|
|
1017
1029
|
this.withPath(() => {
|
|
1018
1030
|
for (let [t, n] of e.calls) t === "moveTo" ? this.moveTo(n[0], n[1]) : t === "lineTo" ? this.lineTo(n[0], n[1]) : t === "closePath" ? this.closePath() : t === "rect" ? this.rect(n[0], n[1], n[2], n[3]) : t === "arc" ? this.arc(n[0], n[1], n[2], n[3], n[4], !!n[5]) : t === "quadraticCurveTo" ? this.curve([n[0], n[1]], [n[2], n[3]]) : t === "bezierCurveTo" && this.curve([
|
|
1019
1031
|
n[0],
|
|
@@ -1023,21 +1035,34 @@ var z = new Set([
|
|
|
1023
1035
|
], [n[4], n[5]]);
|
|
1024
1036
|
}, t);
|
|
1025
1037
|
}
|
|
1038
|
+
baseColor(e) {
|
|
1039
|
+
let t = this.solid;
|
|
1040
|
+
if (t && t.style === e) return t.color;
|
|
1041
|
+
let n = v(_(e));
|
|
1042
|
+
return this.solid = {
|
|
1043
|
+
style: e,
|
|
1044
|
+
color: n
|
|
1045
|
+
}, n;
|
|
1046
|
+
}
|
|
1047
|
+
alpha() {
|
|
1048
|
+
return Math.max(0, Math.min(1, this.state.globalAlpha));
|
|
1049
|
+
}
|
|
1050
|
+
solidColor(e) {
|
|
1051
|
+
let t = this.baseColor(e), n = this.alpha();
|
|
1052
|
+
return [
|
|
1053
|
+
t[0] * n,
|
|
1054
|
+
t[1] * n,
|
|
1055
|
+
t[2] * n,
|
|
1056
|
+
t[3] * n
|
|
1057
|
+
];
|
|
1058
|
+
}
|
|
1026
1059
|
paint(e) {
|
|
1027
|
-
let t =
|
|
1028
|
-
if (typeof e == "string") {
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
n[0] * t,
|
|
1034
|
-
n[1] * t,
|
|
1035
|
-
n[2] * t,
|
|
1036
|
-
n[3] * t
|
|
1037
|
-
]
|
|
1038
|
-
};
|
|
1039
|
-
}
|
|
1040
|
-
if (!(e instanceof F)) return null;
|
|
1060
|
+
let t = this.alpha();
|
|
1061
|
+
if (typeof e == "string") return {
|
|
1062
|
+
kind: "solid",
|
|
1063
|
+
color: this.solidColor(e)
|
|
1064
|
+
};
|
|
1065
|
+
if (!(e instanceof P)) return null;
|
|
1041
1066
|
if (e.stops.length === 0) return {
|
|
1042
1067
|
kind: "solid",
|
|
1043
1068
|
color: [
|
|
@@ -1051,7 +1076,7 @@ var z = new Set([
|
|
|
1051
1076
|
let n = this.state.transform, r = e.x0 === e.x1 || e.y0 === e.y1;
|
|
1052
1077
|
if (!this.axisAligned() || !this.uniform() && !r) return null;
|
|
1053
1078
|
let i = [...e.stops].sort((e, t) => e.offset - t.offset).map((e) => {
|
|
1054
|
-
let n =
|
|
1079
|
+
let n = _(e.color);
|
|
1055
1080
|
return {
|
|
1056
1081
|
offset: e.offset,
|
|
1057
1082
|
color: [
|
|
@@ -1073,15 +1098,15 @@ var z = new Set([
|
|
|
1073
1098
|
}
|
|
1074
1099
|
plain() {
|
|
1075
1100
|
let e = this.state;
|
|
1076
|
-
return e.globalCompositeOperation !== "source-over" || e.filter !== "none" ? !1 :
|
|
1101
|
+
return e.globalCompositeOperation !== "source-over" || e.filter !== "none" ? !1 : e.shadowBlur === 0 && e.shadowOffsetX === 0 && e.shadowOffsetY === 0 ? !0 : !(_(e.shadowColor)[3] > 0);
|
|
1077
1102
|
}
|
|
1078
1103
|
fill(e = "nonzero") {
|
|
1079
1104
|
if (!this.plain()) return this.unsupported();
|
|
1080
1105
|
let t = this.paint(this.state.fillStyle);
|
|
1081
1106
|
if (!t) return this.unsupported();
|
|
1082
|
-
let n = this.path.filter(
|
|
1107
|
+
let n = this.path.filter(V);
|
|
1083
1108
|
if (n.length === 0 || t.kind === "solid" && t.color[3] === 0) return;
|
|
1084
|
-
if (n.length > 1 &&
|
|
1109
|
+
if (n.length > 1 && N(n.map((e) => M(e.points)))) {
|
|
1085
1110
|
let r = t.kind === "solid" && t.color[3] >= 1, i = Math.sign(y(n[0].points));
|
|
1086
1111
|
if (!r || e !== "nonzero" || n.some((e) => Math.sign(y(e.points)) !== i)) return this.unsupported();
|
|
1087
1112
|
}
|
|
@@ -1098,17 +1123,17 @@ var z = new Set([
|
|
|
1098
1123
|
}
|
|
1099
1124
|
let r = [];
|
|
1100
1125
|
for (let e of n) {
|
|
1101
|
-
let t =
|
|
1126
|
+
let t = ne(e.points);
|
|
1102
1127
|
if (!t) return this.unsupported();
|
|
1103
1128
|
for (let e of t) r.push(e);
|
|
1104
1129
|
}
|
|
1105
|
-
let i =
|
|
1130
|
+
let i = M(n.flatMap((e) => e.points)), a = A({
|
|
1106
1131
|
x0: Math.floor(i.x0),
|
|
1107
1132
|
y0: Math.floor(i.y0),
|
|
1108
1133
|
x1: Math.ceil(i.x1),
|
|
1109
1134
|
y1: Math.ceil(i.y1)
|
|
1110
1135
|
}, this.state.clip);
|
|
1111
|
-
r.length > 0 && !
|
|
1136
|
+
r.length > 0 && !j(a) && this.commands.push({
|
|
1112
1137
|
type: "fill",
|
|
1113
1138
|
spans: r,
|
|
1114
1139
|
bounds: a,
|
|
@@ -1117,16 +1142,40 @@ var z = new Set([
|
|
|
1117
1142
|
});
|
|
1118
1143
|
}
|
|
1119
1144
|
fillRects(e, t) {
|
|
1120
|
-
let n
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1145
|
+
for (let n of e) this.pushRect(n.rect, t);
|
|
1146
|
+
}
|
|
1147
|
+
pushRect(e, t, n = 1) {
|
|
1148
|
+
let r = this.state.clip, i = Math.max(e.x0, r.x0), a = Math.max(e.y0, r.y0), o = Math.min(e.x1, r.x1), s = Math.min(e.y1, r.y1);
|
|
1149
|
+
if (!(o > i && s > a)) return;
|
|
1150
|
+
let c = this.commands[this.commands.length - 1], l = c && c.type === "rects" && this.commands.length > this.stepStart ? c.values : null, u = t[0] * n, d = t[1] * n, f = t[2] * n, p = t[3] * n;
|
|
1151
|
+
l ? l.push(i, a, o, s, u, d, f, p) : this.commands.push({
|
|
1126
1152
|
type: "rects",
|
|
1127
|
-
values:
|
|
1153
|
+
values: [
|
|
1154
|
+
i,
|
|
1155
|
+
a,
|
|
1156
|
+
o,
|
|
1157
|
+
s,
|
|
1158
|
+
u,
|
|
1159
|
+
d,
|
|
1160
|
+
f,
|
|
1161
|
+
p
|
|
1162
|
+
]
|
|
1128
1163
|
});
|
|
1129
1164
|
}
|
|
1165
|
+
fillRect(e, t, n, r) {
|
|
1166
|
+
let i = this.state.fillStyle;
|
|
1167
|
+
if (typeof i != "string" || !this.axisAligned() || !this.plain()) return this.withPath(() => this.rect(e, t, n, r), () => this.fill());
|
|
1168
|
+
if (!(Number.isFinite(e) && Number.isFinite(t) && Number.isFinite(n) && Number.isFinite(r))) return;
|
|
1169
|
+
let a = this.baseColor(i), o = this.alpha();
|
|
1170
|
+
if (a[3] * o === 0) return;
|
|
1171
|
+
let s = this.state.transform, c = s[0] * e + s[4], l = s[0] * (e + n) + s[4], u = s[3] * t + s[5], d = s[3] * (t + r) + s[5];
|
|
1172
|
+
this.pushRect({
|
|
1173
|
+
x0: Math.min(c, l),
|
|
1174
|
+
y0: Math.min(u, d),
|
|
1175
|
+
x1: Math.max(c, l),
|
|
1176
|
+
y1: Math.max(u, d)
|
|
1177
|
+
}, a, o);
|
|
1178
|
+
}
|
|
1130
1179
|
stroke() {
|
|
1131
1180
|
if (!this.plain()) return this.unsupported();
|
|
1132
1181
|
let e = this.paint(this.state.strokeStyle);
|
|
@@ -1139,7 +1188,7 @@ var z = new Set([
|
|
|
1139
1188
|
let o = t.lineCap === "round" ? 1 : t.lineCap === "square" ? 2 : 0;
|
|
1140
1189
|
this.commands.push({
|
|
1141
1190
|
type: "stroke",
|
|
1142
|
-
points:
|
|
1191
|
+
points: he(i),
|
|
1143
1192
|
color: e.color,
|
|
1144
1193
|
width: r,
|
|
1145
1194
|
cap: o,
|
|
@@ -1157,17 +1206,18 @@ var z = new Set([
|
|
|
1157
1206
|
}
|
|
1158
1207
|
drawsAlike(e, t, n) {
|
|
1159
1208
|
let r = this.state, i = t / 2;
|
|
1160
|
-
if (t > 1 && e.some((e) =>
|
|
1209
|
+
if (t > 1 && e.some((e) => pe(e, i, r.lineJoin, r.miterLimit))) return !1;
|
|
1161
1210
|
let a = i + (r.lineCap === "butt" ? 0 : i);
|
|
1162
|
-
return !(e.length > 1 &&
|
|
1211
|
+
return !(e.length > 1 && N(e.map((e) => M(e.points, a))) || n < 1 && e.some((e) => me(e, t)));
|
|
1163
1212
|
}
|
|
1164
1213
|
clip() {
|
|
1165
|
-
let e = this.path.filter(
|
|
1214
|
+
let e = this.path.filter(V);
|
|
1166
1215
|
if (e.length !== 1 || !e[0].rect) return this.unsupported();
|
|
1167
|
-
this.state.clip =
|
|
1216
|
+
this.state.clip = A(this.state.clip, e[0].rect);
|
|
1168
1217
|
}
|
|
1169
1218
|
text(e, t, n, r, i) {
|
|
1170
|
-
|
|
1219
|
+
let a = e ? this.state.strokeStyle : this.state.fillStyle;
|
|
1220
|
+
if (!this.takesText || typeof a != "string" || !this.plain()) return this.unsupported();
|
|
1171
1221
|
this.texts.push({
|
|
1172
1222
|
stroke: e,
|
|
1173
1223
|
text: String(t),
|
|
@@ -1213,7 +1263,7 @@ var z = new Set([
|
|
|
1213
1263
|
fill: (e, t) => typeof e == "object" ? this.onPath(e, () => this.fill(t)) : this.fill(e),
|
|
1214
1264
|
stroke: (e) => e ? this.onPath(e, () => this.stroke()) : this.stroke(),
|
|
1215
1265
|
clip: (e) => typeof e == "object" ? this.onPath(e, () => this.clip()) : this.clip(),
|
|
1216
|
-
fillRect: (e, t, n, r) => this.
|
|
1266
|
+
fillRect: (e, t, n, r) => this.fillRect(e, t, n, r),
|
|
1217
1267
|
strokeRect: (e, t, n, r) => this.withPath(() => this.rect(e, t, n, r), () => this.stroke()),
|
|
1218
1268
|
fillText: (e, t, n, r) => this.text(!1, e, t, n, r),
|
|
1219
1269
|
strokeText: (e, t, n, r) => this.text(!0, e, t, n, r),
|
|
@@ -1261,7 +1311,7 @@ var z = new Set([
|
|
|
1261
1311
|
isIdentity: t === 1 && n === 0 && r === 0 && i === 1 && a === 0 && o === 0
|
|
1262
1312
|
};
|
|
1263
1313
|
},
|
|
1264
|
-
createLinearGradient: (e, t, n, r) => new
|
|
1314
|
+
createLinearGradient: (e, t, n, r) => new P(e, t, n, r)
|
|
1265
1315
|
}), t;
|
|
1266
1316
|
}
|
|
1267
1317
|
proxy() {
|
|
@@ -1270,10 +1320,10 @@ var z = new Set([
|
|
|
1270
1320
|
get: (t, n) => {
|
|
1271
1321
|
if (typeof n == "string") {
|
|
1272
1322
|
if (n in e) return e[n];
|
|
1273
|
-
if (
|
|
1274
|
-
if (
|
|
1323
|
+
if (R.has(n)) return this.state[n];
|
|
1324
|
+
if (z.has(n)) return this.state.textExtras[n];
|
|
1275
1325
|
if (n === "canvas") return this.measure?.canvas;
|
|
1276
|
-
if (!
|
|
1326
|
+
if (!B.has(n)) return this.unsupported(), () => void 0;
|
|
1277
1327
|
}
|
|
1278
1328
|
},
|
|
1279
1329
|
set: (e, t, n) => (typeof t == "string" && this.setProp(t, n), !0)
|
|
@@ -1281,24 +1331,66 @@ var z = new Set([
|
|
|
1281
1331
|
}
|
|
1282
1332
|
setProp(e, t) {
|
|
1283
1333
|
let n = this.state;
|
|
1284
|
-
e === "lineWidth" || e === "miterLimit" ? typeof t == "number" && Number.isFinite(t) && t > 0 && (n[e] = t) : e === "globalAlpha" ? typeof t == "number" && Number.isFinite(t) && t >= 0 && t <= 1 && (n.globalAlpha = t) : e === "fillStyle" || e === "strokeStyle" ? t instanceof
|
|
1334
|
+
e === "lineWidth" || e === "miterLimit" ? typeof t == "number" && Number.isFinite(t) && t > 0 && (n[e] = t) : e === "globalAlpha" ? typeof t == "number" && Number.isFinite(t) && t >= 0 && t <= 1 && (n.globalAlpha = t) : e === "fillStyle" || e === "strokeStyle" ? t instanceof P ? n[e] = t : typeof t == "string" ? g(t) && (n[e] = t) : this.unsupported() : R.has(e) ? n[e] = t : z.has(e) ? this.state.textExtras[e] = t : B.has(e) || this.unsupported();
|
|
1285
1335
|
}
|
|
1286
1336
|
};
|
|
1287
|
-
function
|
|
1337
|
+
function ve(e, t) {
|
|
1288
1338
|
for (let n of t) {
|
|
1289
1339
|
let t = n.state;
|
|
1290
|
-
if (
|
|
1340
|
+
if (j(t.clip)) continue;
|
|
1291
1341
|
e.save(), e.setTransform(1, 0, 0, 1, 0, 0), Number.isFinite(t.clip.x1) && Number.isFinite(t.clip.y1) && (e.beginPath(), e.rect(t.clip.x0, t.clip.y0, t.clip.x1 - t.clip.x0, t.clip.y1 - t.clip.y0), e.clip());
|
|
1292
1342
|
let [r, i, a, o, s, c] = t.transform;
|
|
1293
1343
|
e.setTransform(r, i, a, o, s, c), e.font = t.font, e.textAlign = t.textAlign, e.textBaseline = t.textBaseline, e.direction = t.direction, e.globalAlpha = t.globalAlpha, Object.assign(e, t.textExtras), n.stroke ? (e.strokeStyle = t.strokeStyle, e.lineWidth = t.lineWidth, e.strokeText(n.text, n.x, n.y, n.maxWidth)) : (e.fillStyle = t.fillStyle, e.fillText(n.text, n.x, n.y, n.maxWidth)), e.restore();
|
|
1294
1344
|
}
|
|
1295
1345
|
}
|
|
1296
|
-
function
|
|
1297
|
-
return new
|
|
1346
|
+
function ye(e, t) {
|
|
1347
|
+
return new _e(e, t);
|
|
1298
1348
|
}
|
|
1299
1349
|
//#endregion
|
|
1300
1350
|
//#region src/webgl/shaders.ts
|
|
1301
|
-
var
|
|
1351
|
+
var H = `#version 300 es
|
|
1352
|
+
precision highp float;
|
|
1353
|
+
uniform vec2 u_canvas;
|
|
1354
|
+
uniform float u_dpr;
|
|
1355
|
+
uniform int u_log;
|
|
1356
|
+
uniform int u_invert;
|
|
1357
|
+
uniform float u_yA;
|
|
1358
|
+
uniform float u_yB;
|
|
1359
|
+
uniform float u_logOffset;
|
|
1360
|
+
uniform float u_min;
|
|
1361
|
+
uniform float u_logFloor;
|
|
1362
|
+
uniform float u_logK;
|
|
1363
|
+
uniform float u_top;
|
|
1364
|
+
uniform float u_bottom;
|
|
1365
|
+
out vec4 v_color;
|
|
1366
|
+
|
|
1367
|
+
// A price (relative to the base price) to a CSS-pixel y, as priceToYMapper
|
|
1368
|
+
// does; mappedY in yMapping.ts is the same steps in TypeScript.
|
|
1369
|
+
float cssY(float rel) {
|
|
1370
|
+
if (u_log == 1) {
|
|
1371
|
+
float v = log(max(1.0 + (rel + u_logOffset) / u_min, u_logFloor)) * u_logK;
|
|
1372
|
+
return u_invert == 1 ? u_top + v : u_bottom - v;
|
|
1373
|
+
}
|
|
1374
|
+
return u_yA + rel * u_yB;
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1377
|
+
float snap(float v) { return floor(v + ${t.toFixed(4)}); }
|
|
1378
|
+
|
|
1379
|
+
vec4 toClip(vec2 dev) {
|
|
1380
|
+
return vec4(dev.x / u_canvas.x * 2.0 - 1.0, 1.0 - dev.y / u_canvas.y * 2.0, 0.0, 1.0);
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
// The corners of a quad as two triangles.
|
|
1384
|
+
vec2 corner(int k) {
|
|
1385
|
+
if (k == 0) return vec2(0.0, 0.0);
|
|
1386
|
+
if (k == 1 || k == 4) return vec2(1.0, 0.0);
|
|
1387
|
+
if (k == 2 || k == 3) return vec2(0.0, 1.0);
|
|
1388
|
+
return vec2(1.0, 1.0);
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
// Nothing to draw: every vertex at one point off the canvas.
|
|
1392
|
+
const vec4 NOWHERE = vec4(-2.0, -2.0, 0.0, 1.0);
|
|
1393
|
+
`, be = `${H}
|
|
1302
1394
|
in vec4 a_ohlc;
|
|
1303
1395
|
in vec2 a_vd;
|
|
1304
1396
|
uniform float u_x0;
|
|
@@ -1339,7 +1431,7 @@ void main() {
|
|
|
1339
1431
|
}
|
|
1340
1432
|
gl_Position = toClip(vec2(left + cr.x * width, top + cr.y * height));
|
|
1341
1433
|
}
|
|
1342
|
-
`,
|
|
1434
|
+
`, xe = `${H}
|
|
1343
1435
|
in vec4 a_ohlc;
|
|
1344
1436
|
in vec2 a_vd;
|
|
1345
1437
|
uniform float u_x0;
|
|
@@ -1361,7 +1453,7 @@ void main() {
|
|
|
1361
1453
|
v_color = a_vd.y > 0.5 ? u_volUp : u_volDown;
|
|
1362
1454
|
gl_Position = toClip(vec2(left + cr.x * u_body, top + cr.y * (bottom - top)));
|
|
1363
1455
|
}
|
|
1364
|
-
`,
|
|
1456
|
+
`, Se = `${H}
|
|
1365
1457
|
in vec4 a_col;
|
|
1366
1458
|
in float a_up;
|
|
1367
1459
|
uniform vec4 u_upBody;
|
|
@@ -1376,7 +1468,7 @@ void main() {
|
|
|
1376
1468
|
v_color = a_up > 0.5 ? u_upBody : u_downBody;
|
|
1377
1469
|
gl_Position = toClip(vec2(left + cr.x * width, min(t, b) + cr.y * max(abs(b - t), 1.0)));
|
|
1378
1470
|
}
|
|
1379
|
-
`,
|
|
1471
|
+
`, Ce = `${H}
|
|
1380
1472
|
in vec4 a_col;
|
|
1381
1473
|
in float a_up;
|
|
1382
1474
|
uniform float u_volBottom;
|
|
@@ -1394,7 +1486,7 @@ void main() {
|
|
|
1394
1486
|
v_color = a_up > 0.5 ? u_volUp : u_volDown;
|
|
1395
1487
|
gl_Position = toClip(vec2(left + cr.x * width, top + cr.y * (bottom - top)));
|
|
1396
1488
|
}
|
|
1397
|
-
`,
|
|
1489
|
+
`, we = `${H}
|
|
1398
1490
|
in vec4 a_rect;
|
|
1399
1491
|
in vec4 a_color;
|
|
1400
1492
|
in vec2 a_dash;
|
|
@@ -1408,7 +1500,7 @@ void main() {
|
|
|
1408
1500
|
v_color = a_color;
|
|
1409
1501
|
gl_Position = toClip(mix(floor(v_rect.xy), ceil(v_rect.zw), cr));
|
|
1410
1502
|
}
|
|
1411
|
-
`,
|
|
1503
|
+
`, Te = "#version 300 es\nprecision highp float;\nuniform vec2 u_canvas;\nuniform int u_union;\nin vec4 v_color;\nflat in vec4 v_rect;\nflat in vec2 v_dash;\nout vec4 outColor;\n\n// The share of rows [y, y + 1] inside the rectangle and, dashed, on a dash.\nfloat rows(float y) {\n float lo = max(y, v_rect.y);\n float hi = min(y + 1.0, v_rect.w);\n if (hi <= lo) return 0.0;\n if (v_dash.x <= 0.0) return hi - lo;\n // A dash period is longer than a device pixel, so the row meets the dash\n // of the period it starts in and the next (a third to spare).\n float period = v_dash.x + v_dash.y;\n float first = v_rect.y + floor((lo - v_rect.y) / period) * period;\n float on = 0.0;\n for (int i = 0; i < 3; i++) {\n float start = first + float(i) * period;\n on += max(0.0, min(hi, start + v_dash.x) - max(lo, start));\n }\n return on;\n}\n\nvoid main() {\n // This pixel's top-left corner in device pixels, y down.\n vec2 p = vec2(floor(gl_FragCoord.x), u_canvas.y - floor(gl_FragCoord.y) - 1.0);\n float coverage = clamp(min(p.x + 1.0, v_rect.z) - max(p.x, v_rect.x), 0.0, 1.0) * rows(p.y);\n outColor = u_union == 1 ? vec4(v_color.rgb * coverage, coverage) : v_color * coverage;\n}\n", U = "#version 300 es\nprecision highp float;\nuniform vec2 u_canvas;\nuniform vec4 u_clip;\nin vec4 v_color;\nout vec4 outColor;\n\nvoid main() {\n vec2 p = vec2(floor(gl_FragCoord.x), u_canvas.y - floor(gl_FragCoord.y) - 1.0);\n vec2 c = clamp(min(p + 1.0, u_clip.zw) - max(p, u_clip.xy), 0.0, 1.0);\n outColor = v_color * (c.x * c.y);\n}\n", W = 24, G = 5, K = G * 4, q = 10, J = q * 4, Y = () => {}, X = [
|
|
1412
1504
|
"a_ohlc",
|
|
1413
1505
|
"a_vd",
|
|
1414
1506
|
"a_col",
|
|
@@ -1416,7 +1508,7 @@ void main() {
|
|
|
1416
1508
|
"a_rect",
|
|
1417
1509
|
"a_color",
|
|
1418
1510
|
"a_dash"
|
|
1419
|
-
],
|
|
1511
|
+
], Ee = class t {
|
|
1420
1512
|
label;
|
|
1421
1513
|
gl;
|
|
1422
1514
|
kit;
|
|
@@ -1429,10 +1521,10 @@ void main() {
|
|
|
1429
1521
|
seriesBuffer;
|
|
1430
1522
|
columnBuffer;
|
|
1431
1523
|
rectBuffer;
|
|
1432
|
-
uploads = new
|
|
1524
|
+
uploads = new c();
|
|
1433
1525
|
gpuFloats = 0;
|
|
1434
|
-
columns = new Float32Array(4096 *
|
|
1435
|
-
rectValues = new Float32Array(64 *
|
|
1526
|
+
columns = new Float32Array(4096 * G);
|
|
1527
|
+
rectValues = new Float32Array(64 * q);
|
|
1436
1528
|
clip = [
|
|
1437
1529
|
0,
|
|
1438
1530
|
0,
|
|
@@ -1441,11 +1533,13 @@ void main() {
|
|
|
1441
1533
|
];
|
|
1442
1534
|
lost = !1;
|
|
1443
1535
|
lostCallback = null;
|
|
1536
|
+
restoredCallback = null;
|
|
1537
|
+
release = Y;
|
|
1444
1538
|
static create(e = {}) {
|
|
1445
1539
|
if (typeof document > "u") return null;
|
|
1446
|
-
let
|
|
1540
|
+
let n = document.createElement("canvas"), r = null;
|
|
1447
1541
|
try {
|
|
1448
|
-
|
|
1542
|
+
r = n.getContext("webgl2", {
|
|
1449
1543
|
alpha: !0,
|
|
1450
1544
|
premultipliedAlpha: !0,
|
|
1451
1545
|
antialias: !1,
|
|
@@ -1457,19 +1551,35 @@ void main() {
|
|
|
1457
1551
|
} catch (e) {
|
|
1458
1552
|
return $(e), null;
|
|
1459
1553
|
}
|
|
1460
|
-
if (!
|
|
1554
|
+
if (!r) return null;
|
|
1461
1555
|
try {
|
|
1462
|
-
|
|
1556
|
+
let i = new t(n, r);
|
|
1557
|
+
return i.release = e.release ?? Y, i;
|
|
1463
1558
|
} catch (e) {
|
|
1464
|
-
return $(e), Q(
|
|
1559
|
+
return $(e), Q(r), null;
|
|
1465
1560
|
}
|
|
1466
1561
|
}
|
|
1467
1562
|
constructor(e, t) {
|
|
1468
|
-
this.canvas = e, this.gl = t, this.kit = new
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
let
|
|
1472
|
-
|
|
1563
|
+
this.canvas = e, this.gl = t, this.kit = new te(t), this.label = De(t), this.build(), e.addEventListener("webglcontextlost", this.handleLost), e.addEventListener("webglcontextrestored", this.handleRestored);
|
|
1564
|
+
}
|
|
1565
|
+
build() {
|
|
1566
|
+
let e = this.kit;
|
|
1567
|
+
Object.assign(this, {
|
|
1568
|
+
candleBars: e.program(be, U, X),
|
|
1569
|
+
volumeBars: e.program(xe, U, X),
|
|
1570
|
+
candleColumns: e.program(Se, U, X),
|
|
1571
|
+
volumeColumns: e.program(Ce, U, X),
|
|
1572
|
+
rects: e.program(we, Te, X),
|
|
1573
|
+
seriesBuffer: e.buffer(),
|
|
1574
|
+
columnBuffer: e.buffer(),
|
|
1575
|
+
rectBuffer: e.buffer(),
|
|
1576
|
+
drawer: new ue(e),
|
|
1577
|
+
uploads: new c(),
|
|
1578
|
+
gpuFloats: 0
|
|
1579
|
+
});
|
|
1580
|
+
}
|
|
1581
|
+
onRestored(e) {
|
|
1582
|
+
this.restoredCallback = e;
|
|
1473
1583
|
}
|
|
1474
1584
|
onLost(e) {
|
|
1475
1585
|
this.lostCallback = e, (this.lost || this.gl.isContextLost()) && (this.lost = !0, queueMicrotask(() => {
|
|
@@ -1477,7 +1587,7 @@ void main() {
|
|
|
1477
1587
|
}));
|
|
1478
1588
|
}
|
|
1479
1589
|
recorder(e, t) {
|
|
1480
|
-
return
|
|
1590
|
+
return ye(e, t);
|
|
1481
1591
|
}
|
|
1482
1592
|
render(e) {
|
|
1483
1593
|
let t = this.gl;
|
|
@@ -1485,21 +1595,23 @@ void main() {
|
|
|
1485
1595
|
series: !1,
|
|
1486
1596
|
volume: !1,
|
|
1487
1597
|
background: !1,
|
|
1488
|
-
recorded: !1
|
|
1598
|
+
recorded: !1,
|
|
1599
|
+
under: !1
|
|
1489
1600
|
};
|
|
1490
|
-
let n =
|
|
1601
|
+
let n = Z(e.recorded) ? e.recorded : null, r = Z(e.under) ? e.under : null, i = {
|
|
1491
1602
|
series: e.candles,
|
|
1492
1603
|
volume: e.volume !== null,
|
|
1493
1604
|
background: e.background !== null,
|
|
1494
|
-
recorded: n !== null
|
|
1605
|
+
recorded: n !== null,
|
|
1606
|
+
under: r !== null
|
|
1495
1607
|
};
|
|
1496
|
-
return t.viewport(0, 0, this.canvas.width, this.canvas.height), t.disable(t.SCISSOR_TEST), t.clearColor(0, 0, 0, 0), t.clear(t.COLOR_BUFFER_BIT), t.enable(t.BLEND), e.background && this.drawBackground(e, e.background),
|
|
1608
|
+
return t.viewport(0, 0, this.canvas.width, this.canvas.height), t.disable(t.SCISSOR_TEST), t.clearColor(0, 0, 0, 0), t.clear(t.COLOR_BUFFER_BIT), t.enable(t.BLEND), e.background && this.drawBackground(e, e.background), r && this.drawRecorded(e, r), this.drawSeries(e), n && this.drawRecorded(e, n), i;
|
|
1497
1609
|
}
|
|
1498
|
-
drawSeries(
|
|
1499
|
-
let
|
|
1500
|
-
if (
|
|
1501
|
-
this.syncSeries(
|
|
1502
|
-
let o = Math.max(0, i.visibleRange.from), s = Math.min(i.visibleRange.to,
|
|
1610
|
+
drawSeries(e) {
|
|
1611
|
+
let t = this.gl, { data: n, viewport: i, dpr: a } = e;
|
|
1612
|
+
if (n.length === 0 || !e.candles && !e.volume) return;
|
|
1613
|
+
this.syncSeries(e);
|
|
1614
|
+
let o = Math.max(0, i.visibleRange.from), s = Math.min(i.visibleRange.to, n.length - 1);
|
|
1503
1615
|
if (s < o) return;
|
|
1504
1616
|
let { chartRect: c } = i;
|
|
1505
1617
|
this.clip = [
|
|
@@ -1509,20 +1621,24 @@ void main() {
|
|
|
1509
1621
|
(c.y + c.height) * a
|
|
1510
1622
|
];
|
|
1511
1623
|
let l = Math.floor(this.clip[0]), u = Math.floor(this.clip[1]), d = Math.ceil(this.clip[2]) - l, f = Math.ceil(this.clip[3]) - u;
|
|
1512
|
-
|
|
1513
|
-
let p =
|
|
1514
|
-
|
|
1624
|
+
t.enable(t.SCISSOR_TEST), t.scissor(l, this.canvas.height - u - f, Math.max(0, d), Math.max(0, f)), t.blendFunc(t.ONE, t.ONE_MINUS_SRC_ALPHA);
|
|
1625
|
+
let p = r(i), m = p ? this.buildColumns(e, o, s) : 0;
|
|
1626
|
+
e.volume && this.drawVolume(e, o, s, p, m);
|
|
1515
1627
|
let { min: h, max: g } = i.priceRange;
|
|
1516
|
-
|
|
1628
|
+
e.candles && g - h !== 0 && this.drawCandles(e, o, s, p, m), t.disable(t.SCISSOR_TEST);
|
|
1629
|
+
}
|
|
1630
|
+
drawRecorded(e, t) {
|
|
1631
|
+
t.commands.length !== 0 && this.drawer.draw(t.commands, this.canvas.width, this.canvas.height, (t, n) => this.drawRecordedRects(e, t, n));
|
|
1517
1632
|
}
|
|
1518
1633
|
drawRecordedRects(e, t, n) {
|
|
1519
1634
|
let r = this.gl, i = this.use(this.rects, e);
|
|
1520
1635
|
this.kit.float(i, "u_dpr", 1), this.kit.int(i, "u_union", 0), r.bindBuffer(r.ARRAY_BUFFER, this.rectBuffer), r.bufferData(r.ARRAY_BUFFER, t, r.STREAM_DRAW), this.bindRects(i, 0), r.drawArraysInstanced(r.TRIANGLES, 0, 6, n);
|
|
1521
1636
|
}
|
|
1522
1637
|
destroy() {
|
|
1523
|
-
this.canvas.removeEventListener("webglcontextlost", this.handleLost), this.lostCallback = null;
|
|
1638
|
+
this.canvas.removeEventListener("webglcontextlost", this.handleLost), this.canvas.removeEventListener("webglcontextrestored", this.handleRestored), this.lostCallback = null, this.restoredCallback = null, this.release(), this.release = Y;
|
|
1524
1639
|
let e = this.gl;
|
|
1525
|
-
if (
|
|
1640
|
+
if (e.isContextLost()) this.canvas.addEventListener("webglcontextrestored", () => Q(e), { once: !0 });
|
|
1641
|
+
else {
|
|
1526
1642
|
for (let e of [
|
|
1527
1643
|
this.candleBars,
|
|
1528
1644
|
this.volumeBars,
|
|
@@ -1535,85 +1651,100 @@ void main() {
|
|
|
1535
1651
|
this.canvas.remove();
|
|
1536
1652
|
}
|
|
1537
1653
|
handleLost = (e) => {
|
|
1538
|
-
e.preventDefault(), !this.lost && (this.lost = !0, this.lostCallback?.());
|
|
1654
|
+
e.preventDefault(), !this.lost && (this.lost = !0, this.release(), this.release = Y, this.lostCallback?.());
|
|
1655
|
+
};
|
|
1656
|
+
handleRestored = () => {
|
|
1657
|
+
if (!this.lost || this.gl.isContextLost()) return;
|
|
1658
|
+
let e = i();
|
|
1659
|
+
if (!e) {
|
|
1660
|
+
Q(this.gl);
|
|
1661
|
+
return;
|
|
1662
|
+
}
|
|
1663
|
+
try {
|
|
1664
|
+
this.build();
|
|
1665
|
+
} catch (t) {
|
|
1666
|
+
e(), $(t), Q(this.gl);
|
|
1667
|
+
return;
|
|
1668
|
+
}
|
|
1669
|
+
this.release = e, this.lost = !1, this.restoredCallback?.();
|
|
1539
1670
|
};
|
|
1540
1671
|
syncSeries(e) {
|
|
1541
1672
|
let t = this.gl, n = this.uploads.sync(e.data), r = this.uploads.values;
|
|
1542
|
-
t.bindBuffer(t.ARRAY_BUFFER, this.seriesBuffer), n.full || r.length !== this.gpuFloats ? (t.bufferData(t.ARRAY_BUFFER, r, t.DYNAMIC_DRAW), this.gpuFloats = r.length) : n.to > n.from && t.bufferSubData(t.ARRAY_BUFFER, n.from *
|
|
1673
|
+
t.bindBuffer(t.ARRAY_BUFFER, this.seriesBuffer), n.full || r.length !== this.gpuFloats ? (t.bufferData(t.ARRAY_BUFFER, r, t.DYNAMIC_DRAW), this.gpuFloats = r.length) : n.to > n.from && t.bufferSubData(t.ARRAY_BUFFER, n.from * W, r, n.from * 6, (n.to - n.from) * 6);
|
|
1543
1674
|
}
|
|
1544
|
-
buildColumns(
|
|
1545
|
-
let { viewport: i, data: a } =
|
|
1546
|
-
|
|
1547
|
-
if ((l + 1) *
|
|
1675
|
+
buildColumns(t, n, r) {
|
|
1676
|
+
let { viewport: i, data: a } = t, o = i.barWidth + i.barSpacing, s = -i.offset + i.chartRect.x + i.barWidth / 2, c = this.uploads.base, l = 0;
|
|
1677
|
+
e(a, n, r, (e) => e * o + s, (e) => {
|
|
1678
|
+
if ((l + 1) * G > this.columns.length) {
|
|
1548
1679
|
let e = new Float32Array(this.columns.length * 2);
|
|
1549
1680
|
e.set(this.columns), this.columns = e;
|
|
1550
1681
|
}
|
|
1551
|
-
let t = l *
|
|
1682
|
+
let t = l * G;
|
|
1552
1683
|
this.columns[t] = e.x, this.columns[t + 1] = e.high - c, this.columns[t + 2] = e.low - c, this.columns[t + 3] = e.volume, this.columns[t + 4] = +(e.close >= e.open), l++;
|
|
1553
1684
|
});
|
|
1554
1685
|
let u = this.gl;
|
|
1555
|
-
return u.bindBuffer(u.ARRAY_BUFFER, this.columnBuffer), u.bufferData(u.ARRAY_BUFFER, this.columns.subarray(0, l *
|
|
1686
|
+
return u.bindBuffer(u.ARRAY_BUFFER, this.columnBuffer), u.bufferData(u.ARRAY_BUFFER, this.columns.subarray(0, l * G), u.STREAM_DRAW), l;
|
|
1556
1687
|
}
|
|
1557
1688
|
drawBackground(e, t) {
|
|
1558
|
-
let { viewport: n, theme:
|
|
1689
|
+
let { viewport: n, theme: r } = e, i = t.grid ? a(n) : {
|
|
1559
1690
|
horizontal: [],
|
|
1560
1691
|
vertical: []
|
|
1561
|
-
}, o =
|
|
1692
|
+
}, o = i.horizontal.length + i.vertical.length, s = o + t.rects.length;
|
|
1562
1693
|
if (s === 0) return;
|
|
1563
|
-
this.rectValues.length < s *
|
|
1694
|
+
this.rectValues.length < s * q && (this.rectValues = new Float32Array(s * q * 2));
|
|
1564
1695
|
let c = this.rectValues, l = 0, u = (e, t, n, r, i, a, o) => {
|
|
1565
1696
|
c[l++] = e, c[l++] = t, c[l++] = n, c[l++] = r;
|
|
1566
1697
|
for (let e = 0; e < 4; e++) c[l++] = i[e] * a;
|
|
1567
1698
|
c[l++] = o ? o[0] : 0, c[l++] = o ? o[1] : 0;
|
|
1568
|
-
}, d =
|
|
1569
|
-
for (let e of
|
|
1570
|
-
for (let e of
|
|
1699
|
+
}, d = v(_(r.grid)), { chartRect: f } = n;
|
|
1700
|
+
for (let e of i.horizontal) u(f.x, e - .5, f.x + f.width, e + .5, d, 1);
|
|
1701
|
+
for (let e of i.vertical) u(e - .5, f.y, e + .5, f.y + f.height, d, 1);
|
|
1571
1702
|
let p = "", m = d;
|
|
1572
|
-
for (let e of t.rects) e.color !== p && (p = e.color, m =
|
|
1573
|
-
let
|
|
1574
|
-
|
|
1703
|
+
for (let e of t.rects) e.color !== p && (p = e.color, m = v(_(e.color))), u(e.x, e.y, e.x + e.width, e.y + e.height, m, e.alpha, e.dash);
|
|
1704
|
+
let h = this.gl, g = this.use(this.rects, e);
|
|
1705
|
+
h.bindBuffer(h.ARRAY_BUFFER, this.rectBuffer), h.bufferData(h.ARRAY_BUFFER, c.subarray(0, l), h.STREAM_DRAW), o > 0 && (h.uniform1i(this.loc(g, "u_union"), 1), h.blendColor(0, 0, 0, d[3]), h.blendFuncSeparate(h.ONE, h.ONE_MINUS_SRC_ALPHA, h.CONSTANT_ALPHA, h.ONE_MINUS_SRC_ALPHA), this.bindRects(g, 0), h.drawArraysInstanced(h.TRIANGLES, 0, 6, o)), t.rects.length > 0 && (h.uniform1i(this.loc(g, "u_union"), 0), h.blendFunc(h.ONE, h.ONE_MINUS_SRC_ALPHA), this.bindRects(g, o), h.drawArraysInstanced(h.TRIANGLES, 0, 6, t.rects.length));
|
|
1575
1706
|
}
|
|
1576
1707
|
drawCandles(e, t, n, r, i) {
|
|
1577
|
-
let { theme: a, viewport: o, dpr: s } = e, c =
|
|
1708
|
+
let { theme: a, viewport: o, dpr: s } = e, c = v(_(a.candleUp)), l = v(_(a.candleDown));
|
|
1578
1709
|
if (r) {
|
|
1579
1710
|
let t = this.use(this.candleColumns, e);
|
|
1580
1711
|
this.vec4(t, "u_upBody", c), this.vec4(t, "u_downBody", l), this.bindColumns(t), this.gl.drawArraysInstanced(this.gl.TRIANGLES, 0, 6, i);
|
|
1581
1712
|
return;
|
|
1582
1713
|
}
|
|
1583
1714
|
let u = this.use(this.candleBars, e);
|
|
1584
|
-
this.barUniforms(u, o, t, s), this.vec4(u, "u_upBody", c), this.vec4(u, "u_downBody", l), this.vec4(u, "u_upWick",
|
|
1715
|
+
this.barUniforms(u, o, t, s), this.vec4(u, "u_upBody", c), this.vec4(u, "u_downBody", l), this.vec4(u, "u_upWick", v(_(a.candleUpWick))), this.vec4(u, "u_downWick", v(_(a.candleDownWick))), this.bindBars(u, t), this.gl.drawArraysInstanced(this.gl.TRIANGLES, 0, 12, n - t + 1);
|
|
1585
1716
|
}
|
|
1586
|
-
drawVolume(e, t, n, r,
|
|
1587
|
-
let { data:
|
|
1588
|
-
for (let e = t; e <= n; e++)
|
|
1717
|
+
drawVolume(e, t, n, r, i) {
|
|
1718
|
+
let { data: a, viewport: s, theme: c, dpr: l } = e, u = 0;
|
|
1719
|
+
for (let e = t; e <= n; e++) a[e].volume > u && (u = a[e].volume);
|
|
1589
1720
|
if (u === 0) return;
|
|
1590
|
-
let { chartRect: d } = s, f =
|
|
1591
|
-
if (this.float(p, "u_volBottom", d.y + d.height), this.float(p, "u_volScale", d.height * (e.volume?.heightRatio ?? .15) / u), this.vec4(p, "u_volUp",
|
|
1592
|
-
this.bindColumns(p), this.gl.drawArraysInstanced(this.gl.TRIANGLES, 0, 6,
|
|
1721
|
+
let { chartRect: d } = s, f = o(c), p = this.use(r ? this.volumeColumns : this.volumeBars, e);
|
|
1722
|
+
if (this.float(p, "u_volBottom", d.y + d.height), this.float(p, "u_volScale", d.height * (e.volume?.heightRatio ?? .15) / u), this.vec4(p, "u_volUp", v(_(f.up))), this.vec4(p, "u_volDown", v(_(f.down))), r) {
|
|
1723
|
+
this.bindColumns(p), this.gl.drawArraysInstanced(this.gl.TRIANGLES, 0, 6, i);
|
|
1593
1724
|
return;
|
|
1594
1725
|
}
|
|
1595
1726
|
this.barUniforms(p, s, t, l), this.bindBars(p, t), this.gl.drawArraysInstanced(this.gl.TRIANGLES, 0, 6, n - t + 1);
|
|
1596
1727
|
}
|
|
1597
|
-
barUniforms(e,
|
|
1598
|
-
let a =
|
|
1728
|
+
barUniforms(e, t, r, i) {
|
|
1729
|
+
let a = t.barWidth + t.barSpacing, o = -t.offset + t.chartRect.x + t.barWidth / 2, { body: s, wick: c } = n(t.barWidth, i);
|
|
1599
1730
|
this.float(e, "u_x0", r * a + o), this.float(e, "u_unit", a), this.float(e, "u_wick", c), this.float(e, "u_body", s);
|
|
1600
1731
|
}
|
|
1601
1732
|
use(e, t) {
|
|
1602
1733
|
let n = this.gl;
|
|
1603
1734
|
this.kit.use(e), n.uniform2f(this.loc(e, "u_canvas"), this.canvas.width, this.canvas.height), this.vec4(e, "u_clip", this.clip), this.float(e, "u_dpr", t.dpr);
|
|
1604
|
-
let r =
|
|
1735
|
+
let r = ee(t.viewport, this.uploads.base);
|
|
1605
1736
|
return n.uniform1i(this.loc(e, "u_log"), r.log), n.uniform1i(this.loc(e, "u_invert"), r.invert), this.float(e, "u_yA", r.yA), this.float(e, "u_yB", r.yB), this.float(e, "u_logOffset", r.logOffset), this.float(e, "u_min", r.min), this.float(e, "u_logFloor", r.logFloor), this.float(e, "u_logK", r.logK), this.float(e, "u_top", r.top), this.float(e, "u_bottom", r.bottom), e;
|
|
1606
1737
|
}
|
|
1607
1738
|
bindBars(e, t) {
|
|
1608
1739
|
let n = this.gl;
|
|
1609
|
-
n.bindBuffer(n.ARRAY_BUFFER, this.seriesBuffer), this.attrib(e, "a_ohlc", 4,
|
|
1740
|
+
n.bindBuffer(n.ARRAY_BUFFER, this.seriesBuffer), this.attrib(e, "a_ohlc", 4, W, t * W), this.attrib(e, "a_vd", 2, W, t * W + 16);
|
|
1610
1741
|
}
|
|
1611
1742
|
bindRects(e, t) {
|
|
1612
|
-
this.attrib(e, "a_rect", 4,
|
|
1743
|
+
this.attrib(e, "a_rect", 4, J, t * J), this.attrib(e, "a_color", 4, J, t * J + 16), this.attrib(e, "a_dash", 2, J, t * J + 32);
|
|
1613
1744
|
}
|
|
1614
1745
|
bindColumns(e) {
|
|
1615
1746
|
let t = this.gl;
|
|
1616
|
-
t.bindBuffer(t.ARRAY_BUFFER, this.columnBuffer), this.attrib(e, "a_col", 4,
|
|
1747
|
+
t.bindBuffer(t.ARRAY_BUFFER, this.columnBuffer), this.attrib(e, "a_col", 4, K, 0), this.attrib(e, "a_up", 1, K, 16);
|
|
1617
1748
|
}
|
|
1618
1749
|
attrib(e, t, n, r, i) {
|
|
1619
1750
|
this.kit.attrib(e, t, n, r, i);
|
|
@@ -1628,9 +1759,15 @@ void main() {
|
|
|
1628
1759
|
return this.kit.loc(e, t);
|
|
1629
1760
|
}
|
|
1630
1761
|
};
|
|
1631
|
-
function
|
|
1762
|
+
function Z(e) {
|
|
1632
1763
|
return typeof e == "object" && !!e && Array.isArray(e.commands);
|
|
1633
1764
|
}
|
|
1765
|
+
function De(e) {
|
|
1766
|
+
let t = String(e.getParameter(e.RENDERER));
|
|
1767
|
+
if (t && t !== "WebKit WebGL") return t;
|
|
1768
|
+
let n = e.getExtension("WEBGL_debug_renderer_info");
|
|
1769
|
+
return n ? String(e.getParameter(n.UNMASKED_RENDERER_WEBGL)) : t;
|
|
1770
|
+
}
|
|
1634
1771
|
function Q(e) {
|
|
1635
1772
|
e.getExtension("WEBGL_lose_context")?.loseContext();
|
|
1636
1773
|
}
|
|
@@ -1638,6 +1775,6 @@ function $(e) {
|
|
|
1638
1775
|
console.warn("TradeCanvas: WebGL renderer unavailable, drawing with Canvas 2D.", e);
|
|
1639
1776
|
}
|
|
1640
1777
|
//#endregion
|
|
1641
|
-
export {
|
|
1778
|
+
export { Ee as WebGLSeriesRenderer };
|
|
1642
1779
|
|
|
1643
|
-
//# sourceMappingURL=WebGLSeriesRenderer-
|
|
1780
|
+
//# sourceMappingURL=WebGLSeriesRenderer-CLVnGxIS.js.map
|