@x-cmd/draw 0.3.0 → 0.4.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 +79 -297
- package/dist/lib.d.ts +23 -3
- package/dist/lib.js +28 -4
- package/dist/node/cli.js +1 -1
- package/dist/render/anno.d.ts +50 -0
- package/dist/render/anno.js +589 -0
- package/dist/render/arch.d.ts +106 -0
- package/dist/render/arch.js +1011 -0
- package/dist/render/archmap.d.ts +90 -3
- package/dist/render/archmap.js +174 -102
- package/dist/render/area.js +9 -7
- package/dist/render/bar-grouped.js +3 -2
- package/dist/render/bar-stacked.js +3 -2
- package/dist/render/bar.js +3 -2
- package/dist/render/butterfly.d.ts +3 -0
- package/dist/render/butterfly.js +355 -0
- package/dist/render/calendar.d.ts +6 -0
- package/dist/render/calendar.js +448 -0
- package/dist/render/combo.js +3 -2
- package/dist/render/compass.d.ts +6 -0
- package/dist/render/compass.js +77 -0
- package/dist/render/dispatch.js +26 -1
- package/dist/render/echarts-ssr.d.ts +30 -0
- package/dist/render/echarts-ssr.js +337 -16
- package/dist/render/gantt.d.ts +11 -0
- package/dist/render/gantt.js +12 -19
- package/dist/render/gantt2.d.ts +24 -0
- package/dist/render/gantt2.js +198 -0
- package/dist/render/hbar.js +8 -4
- package/dist/render/icons.d.ts +3 -0
- package/dist/render/icons.js +78 -0
- package/dist/render/kinds.d.ts +11 -0
- package/dist/render/kinds.js +176 -0
- package/dist/render/ladder.d.ts +21 -0
- package/dist/render/ladder.js +230 -0
- package/dist/render/layout.d.ts +46 -0
- package/dist/render/layout.js +57 -0
- package/dist/render/line-multi.js +2 -2
- package/dist/render/line.js +2 -2
- package/dist/render/maps.d.ts +34 -0
- package/dist/render/maps.js +197 -2
- package/dist/render/mermaid.js +25 -6
- package/dist/render/mindmap.js +3 -2
- package/dist/render/orgicon.d.ts +12 -0
- package/dist/render/orgicon.js +31 -0
- package/dist/render/png.js +3 -1
- package/dist/render/quadrant.d.ts +6 -0
- package/dist/render/quadrant.js +201 -0
- package/dist/render/query.d.ts +2 -0
- package/dist/render/query.js +100 -1
- package/dist/render/route.d.ts +86 -0
- package/dist/render/route.js +1077 -0
- package/dist/render/scatter.js +73 -7
- package/dist/render/seq.d.ts +41 -0
- package/dist/render/seq.js +248 -0
- package/dist/render/svg.d.ts +16 -2
- package/dist/render/svg.js +85 -7
- package/dist/render/table.d.ts +30 -0
- package/dist/render/table.js +134 -0
- package/dist/render/tokei.d.ts +18 -0
- package/dist/render/tokei.js +230 -0
- package/dist/render/uc.d.ts +58 -0
- package/dist/render/uc.js +319 -0
- package/dist/render/units.d.ts +32 -0
- package/dist/render/units.js +84 -0
- package/dist/render/vendor/au.js +10 -0
- package/dist/render/vendor/br.js +10 -0
- package/dist/render/vendor/china.js +11 -0
- package/dist/render/vendor/de.js +10 -0
- package/dist/render/vendor/eu.js +10 -0
- package/dist/render/vendor/japan.js +10 -0
- package/dist/render/vendor/kr.js +10 -0
- package/dist/render/vendor/us-states.js +4 -6
- package/dist/render/vendor/world-geo.d.ts +22 -0
- package/dist/render/vendor/world-geo.js +9 -0
- package/dist/render/vendor/world.d.ts +13 -0
- package/dist/render/vendor/world.js +12 -0
- package/dist/specs/base.d.ts +5 -0
- package/dist/specs/base.js +14 -1
- package/dist/specs/butterfly.d.ts +46 -0
- package/dist/specs/butterfly.js +241 -0
- package/dist/specs/calendar.d.ts +90 -0
- package/dist/specs/calendar.js +296 -0
- package/dist/specs/compass.d.ts +27 -0
- package/dist/specs/compass.js +111 -0
- package/dist/specs/index.d.ts +5 -0
- package/dist/specs/index.js +5 -0
- package/dist/specs/ladder.d.ts +43 -0
- package/dist/specs/ladder.js +261 -0
- package/dist/specs/quadrant.d.ts +41 -0
- package/dist/specs/quadrant.js +200 -0
- package/dist/specs/scatter.d.ts +14 -8
- package/dist/specs/scatter.js +54 -5
- package/dist/specs/table.d.ts +24 -0
- package/dist/specs/table.js +154 -0
- package/dist/store.d.ts +1 -1
- package/dist/store.js +1 -1
- package/dist/styles/butterfly.d.ts +2 -0
- package/dist/styles/butterfly.js +74 -0
- package/dist/styles/calendar.d.ts +2 -0
- package/dist/styles/calendar.js +51 -0
- package/dist/styles/compass.d.ts +2 -0
- package/dist/styles/compass.js +19 -0
- package/dist/styles/index.js +13 -0
- package/dist/styles/ladder.d.ts +3 -0
- package/dist/styles/ladder.js +66 -0
- package/dist/styles/quadrant.d.ts +2 -0
- package/dist/styles/quadrant.js +19 -0
- package/dist/styles/table.d.ts +2 -0
- package/dist/styles/table.js +12 -0
- package/dist/styles/types.d.ts +1 -0
- package/dist/styles/types.js +1 -0
- package/dist/types/dagre.d.ts +39 -0
- package/dist/types/dagre.js +3 -0
- package/package.json +17 -1
|
@@ -0,0 +1,589 @@
|
|
|
1
|
+
// 图上的标注层:在图上圈一个椭圆、写一句话、标一块区域、写一条评论。
|
|
2
|
+
//
|
|
3
|
+
// 用途:AI(或人)拿到一张图,想在上面指出点东西 —— 「那次抖动是发布引起的」。
|
|
4
|
+
// 于是 URL 后面可以再挂几个参数(都能写多次):
|
|
5
|
+
//
|
|
6
|
+
// &_oval=70,25,12,8 圈一个椭圆(中心 70,25;半径 12,8)
|
|
7
|
+
// &_oval=70,25,12,8,#22d3ee 同上,换个颜色
|
|
8
|
+
// &_text=70,12;发布抖动 写一句话
|
|
9
|
+
// &_text=70,12,#22d3ee;发布抖动
|
|
10
|
+
// &_text=70,12,40,30;发布抖动 两个节点:指示点(70,12)+ 文字的位置(40,30)
|
|
11
|
+
// ⇒ 中间拉一条引线,指示点也能单独挪
|
|
12
|
+
// &_hl=20,30,40,25 高亮一块区域(左上角 x,y;宽 w;高 h)
|
|
13
|
+
// &_hl=20,30,40,25,#fbbf24 同上,换个颜色
|
|
14
|
+
// &_note=62,44;这个尖峰是发布引起的 一条评论(从 62,44 拉一条线过去)
|
|
15
|
+
// &_note=62,44,#60a5fa;… 同上,换个颜色
|
|
16
|
+
// &_arrow=20,60,60,20 一支箭头(起点 20,60;终点 60,20)
|
|
17
|
+
// &_arrow=20,60,60,20,#60a5fa 同上,换个颜色
|
|
18
|
+
// &_path=12,30,20,25,31,28,… 手绘的一笔(折线,坐标连着写)
|
|
19
|
+
// &_path=12,30,20,25,#F87171 同上,换个颜色
|
|
20
|
+
//
|
|
21
|
+
// 坐标是**百分比**(0-100),相对整张画布 —— 换尺寸、换图种,标注都还在原来的地方。
|
|
22
|
+
// 颜色只收 6 位 hex(# 要 URL 编码成 %23)。
|
|
23
|
+
//
|
|
24
|
+
// 通用扩展一律用 `_` 开头:这样不会跟各图种自己的参数(smiles= d= theme= …)打架
|
|
25
|
+
// —— 见 x-cmd/draw#33。
|
|
26
|
+
//
|
|
27
|
+
// 老名字(`oval=` / `text=`,没有下划线)**继续能用**(兼容旧链接 ✓),但正式名是
|
|
28
|
+
// `_oval=` / `_text=` ✓;用了老名字会在日志里留一句(便于以后统计、什么时候下掉)✓。
|
|
29
|
+
//
|
|
30
|
+
// 这层是画在图**上面**的一层(g.anno),不改动图本身 —— 图还是那张图,只是上面多了几笔。
|
|
31
|
+
// 只依赖 base.ts(不引整个 specs 桶)—— 站里的客户端要单独引这一块
|
|
32
|
+
// (`@x-cmd/draw/anno`),把渲染库整个打进浏览器包不合适 ✓。
|
|
33
|
+
import { ApiError } from '../specs/base.js';
|
|
34
|
+
const HEX_RE = /^#?[0-9a-fA-F]{6}$/;
|
|
35
|
+
const DEFAULT_COLOR = '#F87171';
|
|
36
|
+
/** 高亮默认取荧光黄的底色(像荧光笔) */
|
|
37
|
+
const HL_COLOR = '#FBBF24';
|
|
38
|
+
/** 评论默认取站上的强调色(蓝) */
|
|
39
|
+
const NOTE_COLOR = '#60A5FA';
|
|
40
|
+
/** 箭头也用强调色(蓝)—— 跟评论一族 */
|
|
41
|
+
const ARROW_COLOR = '#60A5FA';
|
|
42
|
+
const r2 = (v) => Math.round(v * 100) / 100;
|
|
43
|
+
function colorOf(raw, name) {
|
|
44
|
+
if (raw === undefined || raw === '')
|
|
45
|
+
return undefined;
|
|
46
|
+
if (!HEX_RE.test(raw)) {
|
|
47
|
+
throw new ApiError(400, `"${name}" color must be a 6-digit hex like %23F87171 — got ${JSON.stringify(raw)}`);
|
|
48
|
+
}
|
|
49
|
+
return '#' + raw.replace('#', '').toLowerCase();
|
|
50
|
+
}
|
|
51
|
+
/** 百分比坐标 → 画布坐标 */
|
|
52
|
+
function pct(v, name, raw) {
|
|
53
|
+
if (!Number.isFinite(v) || v < -50 || v > 150) {
|
|
54
|
+
throw new ApiError(400, `"${name}" coordinates are percent of the canvas (0-100), got ${JSON.stringify(raw)}`);
|
|
55
|
+
}
|
|
56
|
+
return v;
|
|
57
|
+
}
|
|
58
|
+
/** 头尾拆开:「;」之前是坐标,之后是文字 */
|
|
59
|
+
function head_of(raw) {
|
|
60
|
+
const i = raw.indexOf(';');
|
|
61
|
+
return i < 0 ? raw : raw.slice(0, i);
|
|
62
|
+
}
|
|
63
|
+
function splitHead(raw) {
|
|
64
|
+
const i = raw.indexOf(';');
|
|
65
|
+
return { head: i < 0 ? raw : raw.slice(0, i), body: i < 0 ? '' : raw.slice(i + 1) };
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* 「字」和「评」共用的头部解析。
|
|
69
|
+
*
|
|
70
|
+
* x,y = 指示点(指着哪儿 ✓)
|
|
71
|
+
* tx,ty = 文字的位置(**可省**;给了就是第二个自由度 —— 引线拉多远就是多远 ✓)
|
|
72
|
+
* #color = 颜色(可省)
|
|
73
|
+
*
|
|
74
|
+
* 给两个节点时,画出来是「指示点 + 引线 + 文字」;只给一个节点时,
|
|
75
|
+
* 文字就落在那个点上(老样子 ✓)。
|
|
76
|
+
*/
|
|
77
|
+
function parseHead(kind, raw, head) {
|
|
78
|
+
const nums = head.split(',').map((v) => v.trim());
|
|
79
|
+
if (nums.length < 2 || nums.slice(0, 2).some((n) => !Number.isFinite(Number(n)))) {
|
|
80
|
+
const extra = kind === '_note' ? 'a ,tx,ty and ,#color may follow' : 'a ,tx,ty and ,#color may follow';
|
|
81
|
+
throw new ApiError(400, `"${kind}" expects x,y in percent of the canvas (${extra}), then the text after ";", e.g. ${kind}=70,12;the spike — got ${JSON.stringify(raw)}`);
|
|
82
|
+
}
|
|
83
|
+
let tx;
|
|
84
|
+
let ty;
|
|
85
|
+
let colorRaw;
|
|
86
|
+
for (const f of nums.slice(2)) {
|
|
87
|
+
if (!f)
|
|
88
|
+
continue;
|
|
89
|
+
if (f.startsWith('#')) {
|
|
90
|
+
colorRaw = f;
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
if (tx === undefined)
|
|
94
|
+
tx = Number(f);
|
|
95
|
+
else if (ty === undefined)
|
|
96
|
+
ty = Number(f);
|
|
97
|
+
}
|
|
98
|
+
if ((tx === undefined) !== (ty === undefined)) {
|
|
99
|
+
throw new ApiError(400, `"${kind}" needs both tx and ty for the text position, e.g. ${kind}=70,12,40,30;the spike — got ${JSON.stringify(raw)}`);
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
x: pct(Number(nums[0]), kind, raw),
|
|
103
|
+
y: pct(Number(nums[1]), kind, raw),
|
|
104
|
+
tx: tx === undefined ? undefined : pct(tx, kind, raw),
|
|
105
|
+
ty: ty === undefined ? undefined : pct(ty, kind, raw),
|
|
106
|
+
colorRaw,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* 解析标注参数(都能写多次)。
|
|
111
|
+
* 约定:第一个字段是逗号分隔的数,后面用分号分隔别的字段。
|
|
112
|
+
*/
|
|
113
|
+
export function parseAnnos(params) {
|
|
114
|
+
// 标注层总开关(explore 页那个按钮):画布标注与数据点标注一起藏 ✓
|
|
115
|
+
if (params.get('markhide') === '1')
|
|
116
|
+
return undefined;
|
|
117
|
+
// 新名(_oval/_text)是正式名;老名(oval/text)继续收 —— 旧链接不能断 ✓
|
|
118
|
+
const legacyOvals = params.getAll('oval');
|
|
119
|
+
const legacyTexts = params.getAll('text');
|
|
120
|
+
if (legacyOvals.length || legacyTexts.length) {
|
|
121
|
+
console.warn('[draw] 标注层用了老名字(oval=/text=);正式名是 _oval=/_text= —— 见 x-cmd/draw#33');
|
|
122
|
+
}
|
|
123
|
+
const ovals = [...params.getAll('_oval'), ...legacyOvals];
|
|
124
|
+
const texts = [...params.getAll('_text'), ...legacyTexts];
|
|
125
|
+
const hls = params.getAll('_hl');
|
|
126
|
+
const notes = params.getAll('_note');
|
|
127
|
+
const arrows = params.getAll('_arrow');
|
|
128
|
+
const paths = params.getAll('_path');
|
|
129
|
+
if (!ovals.length && !texts.length && !hls.length && !notes.length && !arrows.length && !paths.length) {
|
|
130
|
+
return undefined;
|
|
131
|
+
}
|
|
132
|
+
// 藏起来的:`_hide=0,2`(序号 = 解析出来的顺序,跨种类;explore 页的标注面板写这个参数)
|
|
133
|
+
const hidden = new Set((params.get('_hide') ?? '').split(',').filter(Boolean).map((n) => Number(n)).filter((n) => Number.isFinite(n)));
|
|
134
|
+
// 类别(训练数据 ✓):`_cls=异常,趋势`(词表 ✓)+ `_c=0:异常,2:趋势`(第几条属于哪类 ✓)
|
|
135
|
+
// ⇒ 序号跟 `_hide=` 同一套 ✓(解析顺序 ✓)
|
|
136
|
+
const classes = new Map();
|
|
137
|
+
for (const pair of (params.get('_c') ?? '').split(',').filter(Boolean)) {
|
|
138
|
+
const i = pair.indexOf(':');
|
|
139
|
+
if (i < 0)
|
|
140
|
+
continue;
|
|
141
|
+
const n = Number(pair.slice(0, i));
|
|
142
|
+
const name = pair.slice(i + 1).trim();
|
|
143
|
+
if (Number.isFinite(n) && name)
|
|
144
|
+
classes.set(n, name);
|
|
145
|
+
}
|
|
146
|
+
const out = [];
|
|
147
|
+
// 序号按「本来会有几条」算(跳过的也算进去)—— 否则藏掉一条,后面的序号全错位
|
|
148
|
+
let seq = 0;
|
|
149
|
+
/** 这一条的序号(藏起来的也算进去 ✓ —— 跟 `_hide=` 同一套 ✓) */
|
|
150
|
+
const idx = () => seq;
|
|
151
|
+
const skip = () => hidden.has(seq++);
|
|
152
|
+
for (const raw of ovals) {
|
|
153
|
+
const parts = raw.split(';');
|
|
154
|
+
const nums = parts[0].split(',');
|
|
155
|
+
if (nums.length < 4 || nums.length > 5 || nums.slice(0, 4).some((n) => !Number.isFinite(Number(n)))) {
|
|
156
|
+
throw new ApiError(400, `"_oval" expects cx,cy,rx,ry in percent of the canvas (a ,#color may follow), e.g. _oval=70,25,12,8 — got ${JSON.stringify(raw)}`);
|
|
157
|
+
}
|
|
158
|
+
const ai = idx();
|
|
159
|
+
if (skip())
|
|
160
|
+
continue;
|
|
161
|
+
out.push({
|
|
162
|
+
kind: 'oval',
|
|
163
|
+
cls: classes.get(ai),
|
|
164
|
+
x: pct(Number(nums[0]), '_oval', raw),
|
|
165
|
+
y: pct(Number(nums[1]), '_oval', raw),
|
|
166
|
+
rx: Math.abs(Number(nums[2])),
|
|
167
|
+
ry: Math.abs(Number(nums[3])),
|
|
168
|
+
color: colorOf(nums[4] ?? parts[1], '_oval'),
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
// 「字」和「评」的头部一样:x,y 是指示点,tx,ty 是文字的位置(可省),
|
|
172
|
+
// 后面可以跟一个颜色。两节点那个形式是给「引线拉多远就是多远」用的。
|
|
173
|
+
for (const raw of texts) {
|
|
174
|
+
const { body } = splitHead(raw);
|
|
175
|
+
const h = parseHead('_text', raw, head_of(raw));
|
|
176
|
+
const text = body.slice(0, 80);
|
|
177
|
+
if (!text.trim()) {
|
|
178
|
+
throw new ApiError(400, `"_text" needs some text after ";", e.g. _text=70,12;the spike — got ${JSON.stringify(raw)}`);
|
|
179
|
+
}
|
|
180
|
+
const ai = idx();
|
|
181
|
+
if (skip())
|
|
182
|
+
continue;
|
|
183
|
+
out.push({
|
|
184
|
+
kind: 'text',
|
|
185
|
+
cls: classes.get(ai),
|
|
186
|
+
x: h.x,
|
|
187
|
+
y: h.y,
|
|
188
|
+
tx: h.tx,
|
|
189
|
+
ty: h.ty,
|
|
190
|
+
text,
|
|
191
|
+
color: colorOf(h.colorRaw, '_text'),
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
// 高亮一块区域:_hl=x,y,w,h(左上角 + 宽高,都是百分比)
|
|
195
|
+
for (const raw of hls) {
|
|
196
|
+
const parts = raw.split(';');
|
|
197
|
+
const nums = parts[0].split(',');
|
|
198
|
+
if (nums.length < 4 || nums.length > 5 || nums.slice(0, 4).some((n) => !Number.isFinite(Number(n)))) {
|
|
199
|
+
throw new ApiError(400, `"_hl" expects x,y,w,h in percent of the canvas (a ,#color may follow), e.g. _hl=20,30,40,25 — got ${JSON.stringify(raw)}`);
|
|
200
|
+
}
|
|
201
|
+
const w = Number(nums[2]);
|
|
202
|
+
const h = Number(nums[3]);
|
|
203
|
+
if (w <= 0 || h <= 0) {
|
|
204
|
+
throw new ApiError(400, `"_hl" width and height must be positive, e.g. _hl=20,30,40,25 — got ${JSON.stringify(raw)}`);
|
|
205
|
+
}
|
|
206
|
+
const ai = idx();
|
|
207
|
+
if (skip())
|
|
208
|
+
continue;
|
|
209
|
+
out.push({
|
|
210
|
+
kind: 'hl',
|
|
211
|
+
cls: classes.get(ai),
|
|
212
|
+
x: pct(Number(nums[0]), '_hl', raw),
|
|
213
|
+
y: pct(Number(nums[1]), '_hl', raw),
|
|
214
|
+
w,
|
|
215
|
+
h,
|
|
216
|
+
color: colorOf(nums[4] ?? parts[1], '_hl'),
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
// 一条评论:_note=x,y[,tx,ty][,#color];评论正文
|
|
220
|
+
// x,y = 指示点(指着哪儿 ✓)
|
|
221
|
+
// tx,ty = 文字框的**左上角**(可省 ⇒ 自己挑 ✓;给了 ⇒ 引线拉多远就是多远 ✓)
|
|
222
|
+
for (const raw of notes) {
|
|
223
|
+
const i = raw.indexOf(';');
|
|
224
|
+
const head = i < 0 ? raw : raw.slice(0, i);
|
|
225
|
+
const body = i < 0 ? '' : raw.slice(i + 1);
|
|
226
|
+
const h = parseHead('_note', raw, head);
|
|
227
|
+
const text = body.slice(0, 200);
|
|
228
|
+
if (!text.trim()) {
|
|
229
|
+
throw new ApiError(400, `"_note" needs some text after ";", e.g. _note=62,44;this spike came from the release — got ${JSON.stringify(raw)}`);
|
|
230
|
+
}
|
|
231
|
+
const ai = idx();
|
|
232
|
+
if (skip())
|
|
233
|
+
continue;
|
|
234
|
+
out.push({
|
|
235
|
+
kind: 'note',
|
|
236
|
+
cls: classes.get(ai),
|
|
237
|
+
x: h.x,
|
|
238
|
+
y: h.y,
|
|
239
|
+
tx: h.tx,
|
|
240
|
+
ty: h.ty,
|
|
241
|
+
text,
|
|
242
|
+
color: colorOf(h.colorRaw, '_note'),
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
// 一支箭头:_arrow=x1,y1,x2,y2(起点、终点;# 之后可带颜色)
|
|
246
|
+
for (const raw of arrows) {
|
|
247
|
+
const parts = raw.split(';');
|
|
248
|
+
const nums = parts[0].split(',');
|
|
249
|
+
if (nums.length < 4 || nums.length > 5 || nums.slice(0, 4).some((n) => !Number.isFinite(Number(n)))) {
|
|
250
|
+
throw new ApiError(400, `"_arrow" expects x1,y1,x2,y2 in percent of the canvas (a ,#color may follow), e.g. _arrow=20,60,60,20 — got ${JSON.stringify(raw)}`);
|
|
251
|
+
}
|
|
252
|
+
const ai = idx();
|
|
253
|
+
if (skip())
|
|
254
|
+
continue;
|
|
255
|
+
out.push({
|
|
256
|
+
kind: 'arrow',
|
|
257
|
+
cls: classes.get(ai),
|
|
258
|
+
x: pct(Number(nums[0]), '_arrow', raw),
|
|
259
|
+
y: pct(Number(nums[1]), '_arrow', raw),
|
|
260
|
+
x2: pct(Number(nums[2]), '_arrow', raw),
|
|
261
|
+
y2: pct(Number(nums[3]), '_arrow', raw),
|
|
262
|
+
color: colorOf(nums[4] ?? parts[1], '_arrow'),
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
// 手绘的一笔:_path=x1,y1,x2,y2,…(折线;末尾若带 # 就是颜色)
|
|
266
|
+
for (const raw of paths) {
|
|
267
|
+
const parts = raw.split(';');
|
|
268
|
+
const nums = parts[0].split(',');
|
|
269
|
+
// 末尾那一段若带 # ⇒ 是颜色,摘出来
|
|
270
|
+
let colorRaw;
|
|
271
|
+
if (nums.length > 3 && nums[nums.length - 1].trim().startsWith('#')) {
|
|
272
|
+
colorRaw = nums.pop();
|
|
273
|
+
}
|
|
274
|
+
if (nums.length < 4 || nums.length % 2 !== 0 || nums.some((n) => !Number.isFinite(Number(n)))) {
|
|
275
|
+
throw new ApiError(400, `"_path" expects a polyline x1,y1,x2,y2,… in percent of the canvas (a ,#color may follow), e.g. _path=12,30,20,25,31,28 — got ${JSON.stringify(raw)}`);
|
|
276
|
+
}
|
|
277
|
+
const pts = [];
|
|
278
|
+
for (let i = 0; i + 1 < nums.length; i += 2) {
|
|
279
|
+
pts.push([pct(Number(nums[i]), '_path', raw), pct(Number(nums[i + 1]), '_path', raw)]);
|
|
280
|
+
}
|
|
281
|
+
const ai = idx();
|
|
282
|
+
if (skip())
|
|
283
|
+
continue;
|
|
284
|
+
out.push({
|
|
285
|
+
kind: 'path',
|
|
286
|
+
cls: classes.get(ai),
|
|
287
|
+
x: pts[0][0],
|
|
288
|
+
y: pts[0][1],
|
|
289
|
+
pts,
|
|
290
|
+
color: colorOf(colorRaw ?? parts[1], '_path'),
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
return out;
|
|
294
|
+
}
|
|
295
|
+
/** 一个字符占几个字宽(CJK 一个字宽,拉丁半个左右) */
|
|
296
|
+
function charUnits(ch) {
|
|
297
|
+
const c = ch.codePointAt(0) ?? 0;
|
|
298
|
+
const wide = c >= 0x1100 && (c <= 0x115f || (c >= 0x2e80 && c <= 0xa4cf && c !== 0x303f)
|
|
299
|
+
|| (c >= 0xac00 && c <= 0xd7a3) || (c >= 0xf900 && c <= 0xfaff)
|
|
300
|
+
|| (c >= 0xfe30 && c <= 0xfe6f) || (c >= 0xff00 && c <= 0xff60));
|
|
301
|
+
return wide ? 1 : 0.55;
|
|
302
|
+
}
|
|
303
|
+
/** 一段文字占几个字宽 */
|
|
304
|
+
function unitsOf(text) {
|
|
305
|
+
let w = 0;
|
|
306
|
+
for (const ch of text)
|
|
307
|
+
w += charUnits(ch);
|
|
308
|
+
return w;
|
|
309
|
+
}
|
|
310
|
+
/** 文本宽度估算(CJK 一个字宽,拉丁半个左右) */
|
|
311
|
+
function textWidth(text, fontSize) {
|
|
312
|
+
return unitsOf(text) * fontSize;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* 折行:中文随处断,西文按空格断(找不到空格就硬断)。
|
|
316
|
+
* maxEm 是「多少字宽」一行 —— 不是多少个字符。
|
|
317
|
+
*/
|
|
318
|
+
function wrapText(text, maxEm) {
|
|
319
|
+
const lines = [];
|
|
320
|
+
// 显式换行先切开,每段各自折行
|
|
321
|
+
for (const para of text.replace(/\r/g, '').split('\n')) {
|
|
322
|
+
let rest = para;
|
|
323
|
+
while (rest.length) {
|
|
324
|
+
if (unitsOf(rest) <= maxEm) {
|
|
325
|
+
lines.push(rest);
|
|
326
|
+
break;
|
|
327
|
+
}
|
|
328
|
+
// 断点:宽度之内最后一个空格
|
|
329
|
+
let cut = -1;
|
|
330
|
+
let w = 0;
|
|
331
|
+
for (let i = 0; i < rest.length; i++) {
|
|
332
|
+
w += charUnits(rest[i]);
|
|
333
|
+
if (w > maxEm)
|
|
334
|
+
break;
|
|
335
|
+
if (rest[i] === ' ')
|
|
336
|
+
cut = i;
|
|
337
|
+
}
|
|
338
|
+
if (cut > 0) {
|
|
339
|
+
lines.push(rest.slice(0, cut).trimEnd());
|
|
340
|
+
rest = rest.slice(cut + 1).trimStart();
|
|
341
|
+
continue;
|
|
342
|
+
}
|
|
343
|
+
// 没有空格:按宽度硬断
|
|
344
|
+
let i = 0;
|
|
345
|
+
w = 0;
|
|
346
|
+
while (i < rest.length && w + charUnits(rest[i]) <= maxEm) {
|
|
347
|
+
w += charUnits(rest[i]);
|
|
348
|
+
i++;
|
|
349
|
+
}
|
|
350
|
+
if (i === 0)
|
|
351
|
+
i = 1;
|
|
352
|
+
lines.push(rest.slice(0, i));
|
|
353
|
+
rest = rest.slice(i);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
return lines.filter((l) => l.length);
|
|
357
|
+
}
|
|
358
|
+
const esc = (s) => s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
359
|
+
/**
|
|
360
|
+
* 引线 + 指示点 —— 「字」和「评」共用这一份实现。
|
|
361
|
+
*
|
|
362
|
+
* 两个节点:指示点(ax,ay)与文字框(x,y,w,h)。引线连到框上离落点最近的那一点,
|
|
363
|
+
* 落点上点一个小圆点 —— 那是「指着哪儿」的记号。
|
|
364
|
+
*/
|
|
365
|
+
function leaderAndDot(ax, ay, x, y, w, h, color, k, dataI = -1) {
|
|
366
|
+
const px = Math.min(Math.max(ax, x), x + w);
|
|
367
|
+
const py = Math.min(Math.max(ay, y), y + h);
|
|
368
|
+
const tag = dataI >= 0 ? ` data-i="${dataI}"` : '';
|
|
369
|
+
return [
|
|
370
|
+
`<line${tag} x1="${r2(ax)}" y1="${r2(ay)}" x2="${r2(px)}" y2="${r2(py)}" stroke="${color}" stroke-width="${r2(1.4 * k)}" stroke-opacity="0.85"/>`,
|
|
371
|
+
`<circle${tag} cx="${r2(ax)}" cy="${r2(ay)}" r="${r2(3.2 * k)}" fill="${color}"/>`,
|
|
372
|
+
];
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* 类别牌(训练数据 ✓):一小块深色牌,写着这一条属于哪一类 ✓。
|
|
376
|
+
* 锚点给的是牌的**左下角**(牌画在它上面 ✓)—— 不压着标注本身 ✓。
|
|
377
|
+
*/
|
|
378
|
+
function clsTag(text, x, y, color, k, dataI = -1) {
|
|
379
|
+
const fs = 10 * k;
|
|
380
|
+
const padX = 5 * k;
|
|
381
|
+
const padY = 3 * k;
|
|
382
|
+
const bw = textWidth(text, fs) + padX * 2;
|
|
383
|
+
const bh = fs + padY * 2;
|
|
384
|
+
const by = y - bh;
|
|
385
|
+
const tag = dataI >= 0 ? ` data-i="${dataI}"` : '';
|
|
386
|
+
return `<rect${tag} x="${r2(x)}" y="${r2(by)}" width="${r2(bw)}" height="${r2(bh)}" rx="${r2(bh / 2)}" fill="#0b0c0f" fill-opacity="0.86" stroke="${color}" stroke-opacity="0.6" stroke-width="${r2(k)}"/>`
|
|
387
|
+
+ `<text${tag} x="${r2(x + bw / 2)}" y="${r2(by + bh / 2 + fs * 0.35)}" text-anchor="middle" font-size="${r2(fs)}" fill="${color}">${esc(text)}</text>`;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* 标注层 → SVG(画在画布坐标上)。
|
|
391
|
+
* frame 是画布在 viewBox 里的位置与大小(标注的百分比按它换算)。
|
|
392
|
+
*
|
|
393
|
+
* 画的时候按kind分批:高亮(区域)在最底下,圈、笔、箭头居中,文字与评论(带引线)最上。
|
|
394
|
+
*
|
|
395
|
+
* k 是「一个用户单位 = 多少像素」的倒数 —— 画布的 viewBox 跟它的像素尺寸
|
|
396
|
+
* 不一定一样(化学结构那张:viewBox 只有 119 个单位,画布 560 像素),
|
|
397
|
+
* 不按它折算,标注会跟着图一起被放大四倍(字变得比分子还大)。
|
|
398
|
+
*/
|
|
399
|
+
export function annoLayer(annos, frame, k = 1) {
|
|
400
|
+
if (!annos.length)
|
|
401
|
+
return '';
|
|
402
|
+
const parts = [];
|
|
403
|
+
// of():连**序号**一起给 ✓ —— 画出来的每一笔都带 data-i ✓
|
|
404
|
+
// (客户端靠它知道「点中的是第几条」✓ —— 悬停、拖动、双击编辑都靠它 ✓)
|
|
405
|
+
const of = (kind) => annos.map((a, i) => ({ a, i })).filter((x) => x.a.kind === kind);
|
|
406
|
+
// 一、高亮:一块区域(荧光笔那一笔)
|
|
407
|
+
for (const { a, i } of of('hl')) {
|
|
408
|
+
const color = a.color ?? HL_COLOR;
|
|
409
|
+
const x = frame.x + (a.x / 100) * frame.w;
|
|
410
|
+
const y = frame.y + (a.y / 100) * frame.h;
|
|
411
|
+
const w = ((a.w ?? 0) / 100) * frame.w;
|
|
412
|
+
const h = ((a.h ?? 0) / 100) * frame.h;
|
|
413
|
+
parts.push(`<rect data-i="${i}" x="${r2(x)}" y="${r2(y)}" width="${r2(w)}" height="${r2(h)}" rx="${r2(10 * k)}" fill="${color}" fill-opacity="0.13" stroke="${color}" stroke-opacity="0.85" stroke-width="${r2(1.5 * k)}"/>`);
|
|
414
|
+
if (a.cls)
|
|
415
|
+
parts.push(clsTag(a.cls, x, y - 4 * k, color, k, i));
|
|
416
|
+
}
|
|
417
|
+
// 二、圈一个点
|
|
418
|
+
for (const { a, i } of of('oval')) {
|
|
419
|
+
const color = a.color ?? DEFAULT_COLOR;
|
|
420
|
+
const cx = frame.x + (a.x / 100) * frame.w;
|
|
421
|
+
const cy = frame.y + (a.y / 100) * frame.h;
|
|
422
|
+
const rx = ((a.rx ?? 0) / 100) * frame.w;
|
|
423
|
+
const ry = ((a.ry ?? 0) / 100) * frame.h;
|
|
424
|
+
parts.push(`<ellipse data-i="${i}" cx="${r2(cx)}" cy="${r2(cy)}" rx="${r2(rx)}" ry="${r2(ry)}" fill="${color}" fill-opacity="0.08" stroke="${color}" stroke-width="${r2(2.5 * k)}" stroke-opacity="0.95"/>`);
|
|
425
|
+
if (a.cls)
|
|
426
|
+
parts.push(clsTag(a.cls, cx - rx, cy - ry - 4 * k, color, k, i));
|
|
427
|
+
}
|
|
428
|
+
// 三、手绘的一笔:_path= 折线(笔触)
|
|
429
|
+
for (const { a, i } of of('path')) {
|
|
430
|
+
const color = a.color ?? DEFAULT_COLOR;
|
|
431
|
+
const pts = a.pts ?? [];
|
|
432
|
+
if (pts.length < 2)
|
|
433
|
+
continue;
|
|
434
|
+
const d = pts
|
|
435
|
+
.map(([px, py], i) => `${i ? 'L' : 'M'}${r2(frame.x + (px / 100) * frame.w)},${r2(frame.y + (py / 100) * frame.h)}`)
|
|
436
|
+
.join(' ');
|
|
437
|
+
parts.push(`<path data-i="${i}" d="${d}" fill="none" stroke="${color}" stroke-width="${r2(2.2 * k)}" stroke-opacity="0.95" stroke-linecap="round" stroke-linejoin="round"/>`);
|
|
438
|
+
if (a.cls) {
|
|
439
|
+
const fx = frame.x + (pts[0][0] / 100) * frame.w;
|
|
440
|
+
const fy = frame.y + (pts[0][1] / 100) * frame.h;
|
|
441
|
+
parts.push(clsTag(a.cls, fx + 4 * k, fy - 4 * k, color, k, i));
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
// 四、一支箭头:_arrow= 起点、终点(末端一个箭头)
|
|
445
|
+
for (const { a, i } of of('arrow')) {
|
|
446
|
+
const color = a.color ?? ARROW_COLOR;
|
|
447
|
+
const x1 = frame.x + (a.x / 100) * frame.w;
|
|
448
|
+
const y1 = frame.y + (a.y / 100) * frame.h;
|
|
449
|
+
const x2 = frame.x + ((a.x2 ?? a.x) / 100) * frame.w;
|
|
450
|
+
const y2 = frame.y + ((a.y2 ?? a.y) / 100) * frame.h;
|
|
451
|
+
const dx = x2 - x1;
|
|
452
|
+
const dy = y2 - y1;
|
|
453
|
+
const len = Math.hypot(dx, dy);
|
|
454
|
+
if (len < 1e-6) {
|
|
455
|
+
parts.push(`<circle cx="${r2(x2)}" cy="${r2(y2)}" r="${r2(3 * k)}" fill="${color}"/>`);
|
|
456
|
+
continue;
|
|
457
|
+
}
|
|
458
|
+
const ux = dx / len;
|
|
459
|
+
const uy = dy / len;
|
|
460
|
+
const head = Math.min(12 * k, len * 0.7); // 箭头别比线还长
|
|
461
|
+
const bx = x2 - ux * head;
|
|
462
|
+
const by = y2 - uy * head;
|
|
463
|
+
const half = head * 0.42; // 张开的角度
|
|
464
|
+
parts.push(`<line data-i="${i}" x1="${r2(x1)}" y1="${r2(y1)}" x2="${r2(x2)}" y2="${r2(y2)}" stroke="${color}" stroke-width="${r2(2 * k)}" stroke-opacity="0.95" stroke-linecap="round"/>`, `<path data-i="${i}" d="M${r2(x2)},${r2(y2)}L${r2(bx - uy * half)},${r2(by + ux * half)}L${r2(bx + uy * half)},${r2(by - ux * half)}" fill="none" stroke="${color}" stroke-width="${r2(2 * k)}" stroke-opacity="0.95" stroke-linecap="round" stroke-linejoin="round"/>`);
|
|
465
|
+
if (a.cls)
|
|
466
|
+
parts.push(clsTag(a.cls, x1, y1 - 4 * k, color, k, i));
|
|
467
|
+
}
|
|
468
|
+
// 五、一句话:一颗胶囊(底下垫一块半透明的底,压在什么颜色上都读得出)
|
|
469
|
+
//
|
|
470
|
+
// 给了 tx,ty 就是**两个节点**:指示点(a.x,a.y)+ 文字的位置(a.tx,a.ty),
|
|
471
|
+
// 中间拉一条引线 —— 引线拉多远就是多远,指示点也能单独挪。
|
|
472
|
+
// 没给就还是老样子:胶囊落在给定的点上(老链接继续能用 ✓)。
|
|
473
|
+
for (const { a, i } of of('text')) {
|
|
474
|
+
const color = a.color ?? DEFAULT_COLOR;
|
|
475
|
+
const fs = 13 * k;
|
|
476
|
+
const text = a.text ?? '';
|
|
477
|
+
const tw = textWidth(text, fs);
|
|
478
|
+
const padX = 8 * k;
|
|
479
|
+
const padY = 5 * k;
|
|
480
|
+
const bw = tw + padX * 2;
|
|
481
|
+
const bh = fs + padY * 2;
|
|
482
|
+
const ax = frame.x + (a.x / 100) * frame.w;
|
|
483
|
+
const ay = frame.y + (a.y / 100) * frame.h;
|
|
484
|
+
const two = a.tx !== undefined && a.ty !== undefined;
|
|
485
|
+
// 文字的位置:两个节点时是左上角给定的,一个节点时是胶囊中心落在给定点上
|
|
486
|
+
const x = two ? frame.x + (a.tx / 100) * frame.w : ax - bw / 2;
|
|
487
|
+
const y = two ? frame.y + (a.ty / 100) * frame.h : ay - bh / 2;
|
|
488
|
+
parts.push(`<rect data-i="${i}" x="${r2(x)}" y="${r2(y)}" width="${r2(bw)}" height="${r2(bh)}" rx="${r2(bh / 2)}" fill="${color}" fill-opacity="0.16" stroke="${color}" stroke-opacity="0.5" stroke-width="${r2(k)}"/>`);
|
|
489
|
+
parts.push(`<text data-i="${i}" x="${r2(x + bw / 2)}" y="${r2(y + bh / 2 + fs * 0.35)}" text-anchor="middle" font-size="${r2(fs)}" font-weight="500" fill="${color}">${esc(text)}</text>`);
|
|
490
|
+
if (two) {
|
|
491
|
+
// 引线 + 指示点(跟「评」共用这一份实现 ✓)
|
|
492
|
+
parts.push(...leaderAndDot(ax, ay, x, y, bw, bh, color, k, i));
|
|
493
|
+
}
|
|
494
|
+
if (a.cls)
|
|
495
|
+
parts.push(clsTag(a.cls, x, y - 4 * k, color, k, i));
|
|
496
|
+
}
|
|
497
|
+
// 六、一条评论:一条引线 + 一个多行的框(框自己挑位置:右边放不下就放左边)
|
|
498
|
+
for (const { a, i } of of('note')) {
|
|
499
|
+
const color = a.color ?? NOTE_COLOR;
|
|
500
|
+
const fs = 13 * k;
|
|
501
|
+
const text = a.text ?? '';
|
|
502
|
+
const lines = wrapText(text, 20).slice(0, 4);
|
|
503
|
+
if (!lines.length)
|
|
504
|
+
continue;
|
|
505
|
+
const lh = fs * 1.35;
|
|
506
|
+
const padX = 10 * k;
|
|
507
|
+
const padY = 8 * k;
|
|
508
|
+
const bw = Math.max(...lines.map((l) => unitsOf(l) * fs)) + padX * 2;
|
|
509
|
+
const bh = lines.length * lh + padY * 2;
|
|
510
|
+
const ax = frame.x + (a.x / 100) * frame.w;
|
|
511
|
+
const ay = frame.y + (a.y / 100) * frame.h;
|
|
512
|
+
const gap = 16 * k;
|
|
513
|
+
let bx;
|
|
514
|
+
let by;
|
|
515
|
+
if (a.tx !== undefined && a.ty !== undefined) {
|
|
516
|
+
// 文字框的**左上角**是给定的 ⇒ 引线拉多远就是多远 ✓
|
|
517
|
+
bx = frame.x + (a.tx / 100) * frame.w;
|
|
518
|
+
by = frame.y + (a.ty / 100) * frame.h;
|
|
519
|
+
}
|
|
520
|
+
else {
|
|
521
|
+
// 缺省:框放在引线的哪一侧 —— 先试右边,再试左边;上面放不下就放下面
|
|
522
|
+
bx = ax + gap;
|
|
523
|
+
if (bx + bw > frame.x + frame.w)
|
|
524
|
+
bx = ax - gap - bw;
|
|
525
|
+
by = ay - gap - bh;
|
|
526
|
+
if (by < frame.y)
|
|
527
|
+
by = ay + gap;
|
|
528
|
+
}
|
|
529
|
+
// 夹回画布(太小放不下时宁可压边,也不能跑出去)
|
|
530
|
+
bx = Math.min(Math.max(bx, frame.x), Math.max(frame.x, frame.x + frame.w - bw));
|
|
531
|
+
by = Math.min(Math.max(by, frame.y), Math.max(frame.y, frame.y + frame.h - bh));
|
|
532
|
+
parts.push(
|
|
533
|
+
// 引线 + 指示点(跟「字」共用这一份实现 ✓)
|
|
534
|
+
...leaderAndDot(ax, ay, bx, by, bw, bh, color, k, i),
|
|
535
|
+
// 垫色:底下垫一块近黑的底 —— 压在什么颜色的图上都读得出(亮底上是深色小牌,暗底上融进背景)
|
|
536
|
+
`<rect data-i="${i}" x="${r2(bx)}" y="${r2(by)}" width="${r2(bw)}" height="${r2(bh)}" rx="${r2(10 * k)}" fill="#0b0c0f" fill-opacity="0.86" stroke="${color}" stroke-opacity="0.6" stroke-width="${r2(k)}"/>`);
|
|
537
|
+
lines.forEach((l, ln) => {
|
|
538
|
+
parts.push(`<text data-i="${i}" x="${r2(bx + padX)}" y="${r2(by + padY + lh * ln + fs * 0.82)}" font-size="${r2(fs)}" fill="${color}">${esc(l)}</text>`);
|
|
539
|
+
});
|
|
540
|
+
if (a.cls)
|
|
541
|
+
parts.push(clsTag(a.cls, bx, by - 4 * k, color, k, i));
|
|
542
|
+
}
|
|
543
|
+
return `<g class="anno" data-anno="1">${parts.join('')}</g>`;
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* 把标注层塞进一张已经画好的 SVG(盖在最后面 = 最上面)。
|
|
547
|
+
* 坐标按 viewBox 换算 —— 画布尺寸变了,百分比的位置不变。
|
|
548
|
+
*/
|
|
549
|
+
export function injectAnnos(svg, annos) {
|
|
550
|
+
if (!annos?.length)
|
|
551
|
+
return svg;
|
|
552
|
+
if (svg.includes('data-anno="1"'))
|
|
553
|
+
return svg; // 已经注过(别叠两层)
|
|
554
|
+
const tag = /<svg\b[^>]*>/.exec(svg);
|
|
555
|
+
if (!tag)
|
|
556
|
+
return svg;
|
|
557
|
+
const attrs = tag[0];
|
|
558
|
+
const vb = /viewBox="([^"]+)"/.exec(attrs);
|
|
559
|
+
let x0 = 0;
|
|
560
|
+
let y0 = 0;
|
|
561
|
+
let vw = 0;
|
|
562
|
+
let vh = 0;
|
|
563
|
+
if (vb) {
|
|
564
|
+
const n = vb[1].split(/[\s,]+/).map(Number);
|
|
565
|
+
if (n.length === 4 && n.every((v) => Number.isFinite(v))) {
|
|
566
|
+
[x0, y0, vw, vh] = n;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
if (!vw || !vh) {
|
|
570
|
+
const w = /width="([\d.]+)"/.exec(attrs);
|
|
571
|
+
const h = /height="([\d.]+)"/.exec(attrs);
|
|
572
|
+
vw = w ? Number(w[1]) : 0;
|
|
573
|
+
vh = h ? Number(h[1]) : 0;
|
|
574
|
+
}
|
|
575
|
+
if (!vw || !vh)
|
|
576
|
+
return svg;
|
|
577
|
+
// 画布的像素尺寸跟 viewBox 不一定一样(化学结构那张:viewBox 119 个单位、
|
|
578
|
+
// 画布 560 像素 —— 图被放大了四倍多)。标注的字号、线宽得按同一个比例折算,
|
|
579
|
+
// 否则标注会跟着图一起被放大(字比分子还大)。
|
|
580
|
+
const px = /width="([\d.]+)"/.exec(attrs);
|
|
581
|
+
const scale = px && vw > 0 ? Number(px[1]) / vw : 1;
|
|
582
|
+
const k = scale > 0 ? 1 / scale : 1;
|
|
583
|
+
// 百分比按 viewBox 换算(viewBox 原点不一定在 0,0)
|
|
584
|
+
const layer = annoLayer(annos, { x: x0, y: y0, w: vw, h: vh }, k);
|
|
585
|
+
const at = svg.lastIndexOf('</svg>');
|
|
586
|
+
if (at < 0)
|
|
587
|
+
return svg;
|
|
588
|
+
return svg.slice(0, at) + layer + svg.slice(at);
|
|
589
|
+
}
|