dsh-quay-bot 1.0.2 → 1.0.6
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 +28 -105
- package/botscreen/requirements.txt +1 -1
- package/client.js +123 -53
- package/cordis.patch.yml +1 -1
- package/host/api.js +4 -0
- package/host/remote.js +285 -8
- package/host/screen.js +22 -86
- package/package.json +34 -32
- package/remote/bin/dsh-remote.mjs +435 -0
- package/remote/package.json +27 -0
- package/remote/src/config.mjs +183 -0
- package/remote/src/crypto.mjs +220 -0
- package/remote/src/keys.mjs +226 -0
- package/remote/src/proxy.mjs +1028 -0
- package/remote/src/sessions.mjs +163 -0
- package/remote/src/shim.js +838 -0
- package/remote/src/supervisor.mjs +207 -0
- package/remote/src/tunnel.mjs +533 -0
- package/remote/src/upstream.mjs +403 -0
- package/remote/src/util.mjs +149 -0
- package/remote/src/ws.mjs +313 -0
- package/LICENSE +0 -21
- package/avatar/build.mjs +0 -81
- package/avatar/gallery/droid.json +0 -14
- package/avatar/gallery/ghost.json +0 -14
- package/avatar/gallery/grok-pod.json +0 -14
- package/avatar/gallery/guardian.json +0 -14
- package/avatar/gallery/mecha.json +0 -14
- package/avatar/gallery/mochi.json +0 -14
- package/avatar/gallery/neko.json +0 -14
- package/avatar/gallery/orbiter.json +0 -14
- package/avatar/gallery/relay.json +0 -14
- package/avatar/gallery/spark.json +0 -14
- package/avatar/src/bot/clay.ts +0 -135
- package/avatar/src/bot/effects.ts +0 -100
- package/avatar/src/bot/grok-bot.ts +0 -626
- package/avatar/src/bot/index.ts +0 -15
- package/avatar/src/bot/palettes.ts +0 -62
- package/avatar/src/bot/ring.ts +0 -219
- package/avatar/src/bot/scheduler.ts +0 -239
- package/avatar/src/bot/shapes.ts +0 -277
- package/avatar/src/bot/spring.ts +0 -196
- package/avatar/src/core/color.ts +0 -92
- package/avatar/src/core/eyes.ts +0 -297
- package/avatar/src/core/field.ts +0 -482
- package/avatar/src/core/frame.ts +0 -655
- package/avatar/src/core/fx.ts +0 -375
- package/avatar/src/core/index.ts +0 -49
- package/avatar/src/core/paint.ts +0 -331
- package/avatar/src/core/path.ts +0 -495
- package/avatar/src/core/pose.ts +0 -581
- package/avatar/src/core/svg.ts +0 -98
- package/avatar/src/core/types.ts +0 -153
- package/avatar/src/core/validate.ts +0 -296
- package/avatar/src/core/volume.ts +0 -681
- package/avatar/src/entry.ts +0 -260
- package/bin/doctor.mjs +0 -148
- package/botscreen/requirements-offline.txt +0 -11
- package/market/index.json +0 -41
- package/vendor/pip/pip-25.1.1-py3-none-any.whl +0 -0
- package/vendor/pip/setuptools-78.1.1-py3-none-any.whl +0 -0
package/avatar/src/core/paint.ts
DELETED
|
@@ -1,331 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* canvas 渲染器:把一帧扁平数据画到一张 canvas 上,所以无论展示多少截面,
|
|
3
|
-
* 一个头像只占一个合成层和一张小位图。
|
|
4
|
-
*
|
|
5
|
-
* 位图只覆盖这一帧真正画到的范围(再加一点余量),并随尺寸与像素比变化重建;
|
|
6
|
-
* 一个宽度变化频繁的头像不会因为“预留所有可能视角”而付出三倍显存。
|
|
7
|
-
*/
|
|
8
|
-
import type { Frame, FrameShape, Matrix } from './frame.ts';
|
|
9
|
-
import { avatarExtent } from './frame.ts';
|
|
10
|
-
import type { AvatarDefinition } from './types.ts';
|
|
11
|
-
import type { Box } from './fx.ts';
|
|
12
|
-
import { applyClayToCanvas, createClayScratch, type ClayScratch } from '../bot/clay.ts';
|
|
13
|
-
|
|
14
|
-
/** 位图布局时给动态余量留的边,viewBox 单位。 */
|
|
15
|
-
export const FIT_SLACK = 8;
|
|
16
|
-
/** 位图边缘保留的抗锯齿余量。 */
|
|
17
|
-
export const FIT_PAD = 1;
|
|
18
|
-
|
|
19
|
-
export interface Square {
|
|
20
|
-
x: number;
|
|
21
|
-
y: number;
|
|
22
|
-
size: number;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface Bounds2 {
|
|
26
|
-
x0: number;
|
|
27
|
-
y0: number;
|
|
28
|
-
x1: number;
|
|
29
|
-
y1: number;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const EMPTY: Bounds2 = { x0: Infinity, y0: Infinity, x1: -Infinity, y1: -Infinity };
|
|
33
|
-
|
|
34
|
-
interface Section {
|
|
35
|
-
rule: CanvasFillRule;
|
|
36
|
-
path: Path2D;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const sections = new Map<string, Section>();
|
|
40
|
-
|
|
41
|
-
/** 每帧的变换(已含 root 动作)与它画到的范围(以及身体切片的实际投影包围盒)。 */
|
|
42
|
-
export function placement(frame: Frame): { matrices: Matrix[]; bounds: Bounds2; sliceBounds: Bounds2 } {
|
|
43
|
-
const boxes = new Map<string, Box>();
|
|
44
|
-
for (const p of frame.paths) boxes.set(p.id, p.box);
|
|
45
|
-
for (const s of frame.shapes) if (s.kind === 'mark') boxes.set(s.id, s.box);
|
|
46
|
-
const [ra, rb, rc, rd, re, rf] = frame.root;
|
|
47
|
-
const bounds: Bounds2 = { ...EMPTY };
|
|
48
|
-
const sliceBounds: Bounds2 = { ...EMPTY };
|
|
49
|
-
const add = (target: Bounds2, m: Matrix, x: number, y: number) => {
|
|
50
|
-
const X = m[0] * x + m[2] * y + m[4];
|
|
51
|
-
const Y = m[1] * x + m[3] * y + m[5];
|
|
52
|
-
if (X < target.x0) target.x0 = X;
|
|
53
|
-
if (X > target.x1) target.x1 = X;
|
|
54
|
-
if (Y < target.y0) target.y0 = Y;
|
|
55
|
-
if (Y > target.y1) target.y1 = Y;
|
|
56
|
-
};
|
|
57
|
-
const matrices = frame.shapes.map((shape) => {
|
|
58
|
-
const [a, b, c, d, e, f] = shape.matrix;
|
|
59
|
-
const m: Matrix = [ra * a + rc * b, rb * a + rd * b, ra * c + rc * d, rb * c + rd * d, ra * e + rc * f + re, rb * e + rd * f + rf];
|
|
60
|
-
const box =
|
|
61
|
-
shape.kind === 'slice'
|
|
62
|
-
? boxes.get(shape.path)
|
|
63
|
-
: shape.kind === 'mark'
|
|
64
|
-
? boxes.get(shape.id)
|
|
65
|
-
: shape.kind === 'eye'
|
|
66
|
-
? eyeBox(shape)
|
|
67
|
-
: shape.box;
|
|
68
|
-
if (box) {
|
|
69
|
-
add(bounds, m, box.x, box.y);
|
|
70
|
-
add(bounds, m, box.x + box.w, box.y);
|
|
71
|
-
add(bounds, m, box.x, box.y + box.h);
|
|
72
|
-
add(bounds, m, box.x + box.w, box.y + box.h);
|
|
73
|
-
if (shape.kind === 'slice') {
|
|
74
|
-
add(sliceBounds, m, box.x, box.y);
|
|
75
|
-
add(sliceBounds, m, box.x + box.w, box.y);
|
|
76
|
-
add(sliceBounds, m, box.x, box.y + box.h);
|
|
77
|
-
add(sliceBounds, m, box.x + box.w, box.y + box.h);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return m;
|
|
81
|
-
});
|
|
82
|
-
return { matrices, bounds, sliceBounds };
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/** 一条路径(绝对坐标)的包围盒;点成对读取,描边宽度另外加。 */
|
|
86
|
-
function boxOfPath(d: string, pad = 0): Box {
|
|
87
|
-
const nums = (d.match(/-?\d*\.?\d+/g) ?? []).map(Number);
|
|
88
|
-
let minX = Infinity;
|
|
89
|
-
let minY = Infinity;
|
|
90
|
-
let maxX = -Infinity;
|
|
91
|
-
let maxY = -Infinity;
|
|
92
|
-
for (let k = 0; k + 1 < nums.length; k += 2) {
|
|
93
|
-
const x = nums[k];
|
|
94
|
-
const y = nums[k + 1];
|
|
95
|
-
if (!Number.isFinite(x) || !Number.isFinite(y)) continue;
|
|
96
|
-
if (x < minX) minX = x;
|
|
97
|
-
if (y < minY) minY = y;
|
|
98
|
-
if (x > maxX) maxX = x;
|
|
99
|
-
if (y > maxY) maxY = y;
|
|
100
|
-
}
|
|
101
|
-
if (!Number.isFinite(minX)) return { x: 0, y: 0, w: 0, h: 0 };
|
|
102
|
-
return { x: minX - pad, y: minY - pad, w: maxX - minX + 2 * pad, h: maxY - minY + 2 * pad };
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function eyeBox(shape: Extract<FrameShape, { kind: 'eye' }>): Box {
|
|
106
|
-
const mark = shape.mark;
|
|
107
|
-
if (mark.shape === 'pill') return { x: mark.x, y: mark.y, w: mark.width, h: mark.height };
|
|
108
|
-
return boxOfPath(mark.d, mark.shape === 'arc' ? mark.strokeWidth / 2 : 0);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/** 布局用的方形:`prev` 还能装下 `b` 就用它,否则长到装下并加余量;不超过 `cap`。 */
|
|
112
|
-
export function fitSquare(prev: Square | null, b: Bounds2, cap: Square): Square {
|
|
113
|
-
if (!(b.x0 <= b.x1 && b.y0 <= b.y1)) return prev ?? cap;
|
|
114
|
-
if (prev && b.x0 - FIT_PAD >= prev.x && b.y0 - FIT_PAD >= prev.y && b.x1 + FIT_PAD <= prev.x + prev.size && b.y1 + FIT_PAD <= prev.y + prev.size) {
|
|
115
|
-
return prev;
|
|
116
|
-
}
|
|
117
|
-
let x0 = b.x0 - FIT_SLACK;
|
|
118
|
-
let y0 = b.y0 - FIT_SLACK;
|
|
119
|
-
let x1 = b.x1 + FIT_SLACK;
|
|
120
|
-
let y1 = b.y1 + FIT_SLACK;
|
|
121
|
-
if (prev) {
|
|
122
|
-
x0 = Math.min(x0, prev.x);
|
|
123
|
-
y0 = Math.min(y0, prev.y);
|
|
124
|
-
x1 = Math.max(x1, prev.x + prev.size);
|
|
125
|
-
y1 = Math.max(y1, prev.y + prev.size);
|
|
126
|
-
}
|
|
127
|
-
const size = Math.max(x1 - x0, y1 - y0);
|
|
128
|
-
const inCap = b.x0 >= cap.x && b.y0 >= cap.y && b.x1 <= cap.x + cap.size && b.y1 <= cap.y + cap.size;
|
|
129
|
-
if (size >= cap.size && inCap) return cap;
|
|
130
|
-
return { x: (x0 + x1 - size) / 2, y: (y0 + y1 - size) / 2, size };
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export interface Surface {
|
|
134
|
-
canvas: HTMLCanvasElement;
|
|
135
|
-
ctx: CanvasRenderingContext2D | null;
|
|
136
|
-
cap: Square;
|
|
137
|
-
fit: Square | null;
|
|
138
|
-
layout: string;
|
|
139
|
-
left: number;
|
|
140
|
-
top: number;
|
|
141
|
-
clay: ClayScratch | null;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export function mountCanvas(canvas: HTMLCanvasElement, definition: AvatarDefinition, depth?: number): Surface {
|
|
145
|
-
canvas.setAttribute('aria-hidden', 'true');
|
|
146
|
-
return {
|
|
147
|
-
canvas,
|
|
148
|
-
ctx: canvas.getContext('2d'),
|
|
149
|
-
cap: avatarExtent(definition, depth),
|
|
150
|
-
fit: null,
|
|
151
|
-
layout: '',
|
|
152
|
-
left: 0,
|
|
153
|
-
top: 0,
|
|
154
|
-
clay: createClayScratch(),
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/** 切换形象或深度时复用已有 Surface 与离屏黏土画布,避免重建 DOM Canvas 引起首帧掉帧。 */
|
|
159
|
-
export function remountCanvas(surface: Surface, definition: AvatarDefinition, depth?: number): Surface {
|
|
160
|
-
surface.cap = avatarExtent(definition, depth);
|
|
161
|
-
// 若当前已分配的位图能继续装下新轮廓,保留 surface.fit,避免重新分配 GPU 画布纹理。
|
|
162
|
-
if (surface.fit) {
|
|
163
|
-
const c = surface.cap;
|
|
164
|
-
const f = surface.fit;
|
|
165
|
-
if (f.x < c.x - 16 || f.y < c.y - 16 || f.size > c.size * 1.45) {
|
|
166
|
-
surface.fit = null;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
return surface;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/** 画一帧,宽度 `size` CSS px。 */
|
|
173
|
-
export function paintFrame(surface: Surface, frame: Frame, size: number): void {
|
|
174
|
-
const { canvas, ctx } = surface;
|
|
175
|
-
if (!ctx || size <= 0) return;
|
|
176
|
-
const dpr = window.devicePixelRatio || 1;
|
|
177
|
-
const scale = (size / 100) * dpr;
|
|
178
|
-
const layout = `${size}|${dpr}`;
|
|
179
|
-
if (sections.size > 4096) sections.clear();
|
|
180
|
-
for (const { id, d, evenOdd } of frame.paths) {
|
|
181
|
-
if (!sections.has(id)) sections.set(id, { rule: evenOdd ? 'evenodd' : 'nonzero', path: new Path2D(d) });
|
|
182
|
-
}
|
|
183
|
-
const { matrices, bounds, sliceBounds } = placement(frame);
|
|
184
|
-
const fit = fitSquare(surface.layout === layout ? surface.fit : null, bounds, surface.cap);
|
|
185
|
-
if (surface.layout === layout && fit === surface.fit) {
|
|
186
|
-
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
187
|
-
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
188
|
-
} else {
|
|
189
|
-
// 整设备像素,位图永不重采样。设置宽高本身会清空画布。
|
|
190
|
-
surface.layout = layout;
|
|
191
|
-
surface.fit = fit;
|
|
192
|
-
surface.left = Math.floor(fit.x * scale);
|
|
193
|
-
surface.top = Math.floor(fit.y * scale);
|
|
194
|
-
const bitmap = Math.ceil(fit.size * scale) + 1;
|
|
195
|
-
canvas.width = canvas.height = bitmap;
|
|
196
|
-
canvas.style.left = `${surface.left / dpr}px`;
|
|
197
|
-
canvas.style.top = `${surface.top / dpr}px`;
|
|
198
|
-
canvas.style.width = canvas.style.height = `${bitmap / dpr}px`;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
const clay = frame.clay ? surface.clay : null;
|
|
202
|
-
let clayReady = false;
|
|
203
|
-
let baseBodyDrawn = false;
|
|
204
|
-
if (clay && sliceBounds.x0 <= sliceBounds.x1) {
|
|
205
|
-
if (clay.body.width !== canvas.width || clay.body.height !== canvas.height) {
|
|
206
|
-
clay.body.width = canvas.width;
|
|
207
|
-
clay.body.height = canvas.height;
|
|
208
|
-
} else {
|
|
209
|
-
clay.bodyCtx.setTransform(1, 0, 0, 1, 0, 0);
|
|
210
|
-
clay.bodyCtx.clearRect(0, 0, clay.body.width, clay.body.height);
|
|
211
|
-
}
|
|
212
|
-
// 一次性把全部身体切片合集画到 clay.body,确保侧面旋转且与眼睛穿插时仍保持无缝的整体黏土质感。
|
|
213
|
-
for (let i = 0; i < frame.shapes.length; i++) {
|
|
214
|
-
const shape = frame.shapes[i];
|
|
215
|
-
if (shape.kind !== 'slice') continue;
|
|
216
|
-
const section = sections.get(shape.path);
|
|
217
|
-
if (!section) continue;
|
|
218
|
-
const m = matrices[i];
|
|
219
|
-
clay.bodyCtx.setTransform(scale * m[0], scale * m[1], scale * m[2], scale * m[3], scale * m[4] - surface.left, scale * m[5] - surface.top);
|
|
220
|
-
clay.bodyCtx.fillStyle = frame.color;
|
|
221
|
-
clay.bodyCtx.fill(section.path, section.rule);
|
|
222
|
-
clayReady = true;
|
|
223
|
-
}
|
|
224
|
-
if (clayReady) {
|
|
225
|
-
const cx = ((sliceBounds.x0 + sliceBounds.x1) * 0.5) * scale - surface.left;
|
|
226
|
-
const cy = ((sliceBounds.y0 + sliceBounds.y1) * 0.5) * scale - surface.top;
|
|
227
|
-
const rx = ((sliceBounds.x1 - sliceBounds.x0) * 0.5) * scale;
|
|
228
|
-
const ry = ((sliceBounds.y1 - sliceBounds.y0) * 0.5) * scale;
|
|
229
|
-
applyClayToCanvas(clay, canvas.width, canvas.height, cx, cy, rx, ry, frame.highlight, frame.shadow);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
ctx.lineCap = 'round';
|
|
234
|
-
let i = 0;
|
|
235
|
-
while (i < frame.shapes.length) {
|
|
236
|
-
const shape = frame.shapes[i];
|
|
237
|
-
if (shape.kind === 'slice') {
|
|
238
|
-
if (clay && clayReady) {
|
|
239
|
-
if (!baseBodyDrawn) {
|
|
240
|
-
baseBodyDrawn = true;
|
|
241
|
-
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
242
|
-
ctx.drawImage(clay.body, 0, 0);
|
|
243
|
-
while (i < frame.shapes.length && frame.shapes[i].kind === 'slice') i++;
|
|
244
|
-
continue;
|
|
245
|
-
}
|
|
246
|
-
// 侧转时如果眼/高光穿插在前后切片之间,把在眼之后的这段切片从已着色 clay.body 中扣出覆盖,既遮挡后眼又无缝隙。
|
|
247
|
-
if (clay.front.width !== canvas.width || clay.front.height !== canvas.height) {
|
|
248
|
-
clay.front.width = canvas.width;
|
|
249
|
-
clay.front.height = canvas.height;
|
|
250
|
-
} else {
|
|
251
|
-
clay.frontCtx.setTransform(1, 0, 0, 1, 0, 0);
|
|
252
|
-
clay.frontCtx.clearRect(0, 0, clay.front.width, clay.front.height);
|
|
253
|
-
}
|
|
254
|
-
clay.frontCtx.globalCompositeOperation = 'source-over';
|
|
255
|
-
clay.frontCtx.fillStyle = '#000';
|
|
256
|
-
while (i < frame.shapes.length && frame.shapes[i].kind === 'slice') {
|
|
257
|
-
const s = frame.shapes[i] as Extract<FrameShape, { kind: 'slice' }>;
|
|
258
|
-
const section = sections.get(s.path);
|
|
259
|
-
if (section) {
|
|
260
|
-
const m = matrices[i];
|
|
261
|
-
clay.frontCtx.setTransform(scale * m[0], scale * m[1], scale * m[2], scale * m[3], scale * m[4] - surface.left, scale * m[5] - surface.top);
|
|
262
|
-
clay.frontCtx.fill(section.path, section.rule);
|
|
263
|
-
}
|
|
264
|
-
i++;
|
|
265
|
-
}
|
|
266
|
-
clay.frontCtx.setTransform(1, 0, 0, 1, 0, 0);
|
|
267
|
-
clay.frontCtx.globalCompositeOperation = 'source-in';
|
|
268
|
-
clay.frontCtx.drawImage(clay.body, 0, 0);
|
|
269
|
-
clay.frontCtx.globalCompositeOperation = 'source-over';
|
|
270
|
-
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
271
|
-
ctx.drawImage(clay.front, 0, 0);
|
|
272
|
-
continue;
|
|
273
|
-
}
|
|
274
|
-
const section = sections.get(shape.path);
|
|
275
|
-
if (section) {
|
|
276
|
-
const m = matrices[i];
|
|
277
|
-
ctx.setTransform(scale * m[0], scale * m[1], scale * m[2], scale * m[3], scale * m[4] - surface.left, scale * m[5] - surface.top);
|
|
278
|
-
ctx.fillStyle = frame.color;
|
|
279
|
-
ctx.fill(section.path, section.rule);
|
|
280
|
-
}
|
|
281
|
-
i++;
|
|
282
|
-
continue;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
const m = matrices[i];
|
|
286
|
-
ctx.setTransform(scale * m[0], scale * m[1], scale * m[2], scale * m[3], scale * m[4] - surface.left, scale * m[5] - surface.top);
|
|
287
|
-
if (shape.kind === 'eye') {
|
|
288
|
-
ctx.fillStyle = frame.ink;
|
|
289
|
-
ctx.strokeStyle = frame.ink;
|
|
290
|
-
paintEye(ctx, shape.mark);
|
|
291
|
-
} else if (shape.kind === 'ribbon') {
|
|
292
|
-
const g = shape.gradient;
|
|
293
|
-
const paint = ctx.createLinearGradient(g.x1, g.y1, g.x2, g.y2);
|
|
294
|
-
g.stops.forEach((c, k) => paint.addColorStop(k / Math.max(1, g.stops.length - 1), c));
|
|
295
|
-
ctx.fillStyle = paint;
|
|
296
|
-
ctx.fill(new Path2D(shape.d));
|
|
297
|
-
} else if (shape.kind === 'particle') {
|
|
298
|
-
let section = sections.get(shape.d);
|
|
299
|
-
if (!section) {
|
|
300
|
-
section = { rule: 'nonzero', path: new Path2D(shape.d) };
|
|
301
|
-
sections.set(shape.d, section);
|
|
302
|
-
}
|
|
303
|
-
ctx.fillStyle = shape.fill;
|
|
304
|
-
ctx.fill(section.path, section.rule);
|
|
305
|
-
} else {
|
|
306
|
-
const section = sections.get(shape.id);
|
|
307
|
-
if (section) {
|
|
308
|
-
ctx.fillStyle = frame.color;
|
|
309
|
-
ctx.fill(section.path, section.rule);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
i++;
|
|
313
|
-
}
|
|
314
|
-
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
function paintEye(ctx: CanvasRenderingContext2D, mark: Extract<FrameShape, { kind: 'eye' }>['mark']): void {
|
|
318
|
-
if (mark.shape === 'pill') {
|
|
319
|
-
const r = Math.min(mark.radius, mark.width / 2, mark.height / 2);
|
|
320
|
-
ctx.beginPath();
|
|
321
|
-
ctx.roundRect(mark.x, mark.y, mark.width, mark.height, r);
|
|
322
|
-
ctx.fill();
|
|
323
|
-
} else if (mark.shape === 'arc') {
|
|
324
|
-
ctx.lineWidth = mark.strokeWidth;
|
|
325
|
-
ctx.beginPath();
|
|
326
|
-
const path = new Path2D(mark.d);
|
|
327
|
-
ctx.stroke(path);
|
|
328
|
-
} else {
|
|
329
|
-
ctx.fill(new Path2D(mark.d));
|
|
330
|
-
}
|
|
331
|
-
}
|