@meta2d/core 1.0.55 → 1.0.57
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/index.d.ts +9 -9
- package/index.js +9 -9
- package/package.json +38 -39
- package/src/canvas/canvas.d.ts +456 -456
- package/src/canvas/canvas.js +7583 -8186
- package/src/canvas/canvas.js.map +1 -1
- package/src/canvas/canvasImage.d.ts +27 -28
- package/src/canvas/canvasImage.js +440 -502
- package/src/canvas/canvasImage.js.map +1 -1
- package/src/canvas/canvasTemplate.d.ts +18 -19
- package/src/canvas/canvasTemplate.js +208 -228
- package/src/canvas/canvasTemplate.js.map +1 -1
- package/src/canvas/index.d.ts +2 -2
- package/src/canvas/index.js +2 -2
- package/src/canvas/magnifierCanvas.d.ts +19 -20
- package/src/canvas/magnifierCanvas.js +101 -100
- package/src/canvas/magnifierCanvas.js.map +1 -1
- package/src/canvas/offscreen.d.ts +1 -2
- package/src/canvas/offscreen.js +13 -13
- package/src/canvas/offscreen.js.map +1 -1
- package/src/core.d.ts +479 -479
- package/src/core.js +4589 -5198
- package/src/core.js.map +1 -1
- package/src/data.d.ts +34 -34
- package/src/data.js +84 -84
- package/src/data.js.map +1 -1
- package/src/diagrams/arrow.d.ts +4 -4
- package/src/diagrams/arrow.js +46 -46
- package/src/diagrams/arrow.js.map +1 -1
- package/src/diagrams/circle.d.ts +2 -2
- package/src/diagrams/circle.js +8 -8
- package/src/diagrams/circle.js.map +1 -1
- package/src/diagrams/cloud.d.ts +2 -2
- package/src/diagrams/cloud.js +11 -11
- package/src/diagrams/cloud.js.map +1 -1
- package/src/diagrams/cube.d.ts +2 -2
- package/src/diagrams/cube.js +67 -69
- package/src/diagrams/cube.js.map +1 -1
- package/src/diagrams/diamond.d.ts +2 -2
- package/src/diagrams/diamond.js +12 -12
- package/src/diagrams/diamond.js.map +1 -1
- package/src/diagrams/file.d.ts +2 -2
- package/src/diagrams/file.js +17 -17
- package/src/diagrams/file.js.map +1 -1
- package/src/diagrams/gif.d.ts +5 -5
- package/src/diagrams/gif.js +88 -89
- package/src/diagrams/gif.js.map +1 -1
- package/src/diagrams/hexagon.d.ts +2 -2
- package/src/diagrams/hexagon.js +54 -54
- package/src/diagrams/hexagon.js.map +1 -1
- package/src/diagrams/iframe.d.ts +2 -2
- package/src/diagrams/iframe.js +337 -355
- package/src/diagrams/iframe.js.map +1 -1
- package/src/diagrams/index.d.ts +71 -71
- package/src/diagrams/index.js +76 -76
- package/src/diagrams/index.js.map +1 -1
- package/src/diagrams/line/arrow.d.ts +2 -2
- package/src/diagrams/line/arrow.js +127 -127
- package/src/diagrams/line/arrow.js.map +1 -1
- package/src/diagrams/line/curve.d.ts +16 -16
- package/src/diagrams/line/curve.js +226 -235
- package/src/diagrams/line/curve.js.map +1 -1
- package/src/diagrams/line/index.d.ts +5 -5
- package/src/diagrams/line/index.js +5 -5
- package/src/diagrams/line/line.d.ts +42 -42
- package/src/diagrams/line/line.js +369 -430
- package/src/diagrams/line/line.js.map +1 -1
- package/src/diagrams/line/polyline.d.ts +10 -10
- package/src/diagrams/line/polyline.js +626 -656
- package/src/diagrams/line/polyline.js.map +1 -1
- package/src/diagrams/line/smooth.d.ts +3 -3
- package/src/diagrams/line/smooth.js +135 -173
- package/src/diagrams/line/smooth.js.map +1 -1
- package/src/diagrams/message.d.ts +2 -2
- package/src/diagrams/message.js +14 -14
- package/src/diagrams/message.js.map +1 -1
- package/src/diagrams/mindLine.d.ts +3 -3
- package/src/diagrams/mindLine.js +29 -30
- package/src/diagrams/mindLine.js.map +1 -1
- package/src/diagrams/mindNode.d.ts +3 -3
- package/src/diagrams/mindNode.js +160 -188
- package/src/diagrams/mindNode.js.map +1 -1
- package/src/diagrams/panel.d.ts +2 -2
- package/src/diagrams/panel.js +130 -130
- package/src/diagrams/panel.js.map +1 -1
- package/src/diagrams/pentagon.d.ts +3 -3
- package/src/diagrams/pentagon.js +44 -45
- package/src/diagrams/pentagon.js.map +1 -1
- package/src/diagrams/pentagram.d.ts +3 -3
- package/src/diagrams/pentagram.js +50 -76
- package/src/diagrams/pentagram.js.map +1 -1
- package/src/diagrams/people.d.ts +2 -2
- package/src/diagrams/people.js +18 -18
- package/src/diagrams/people.js.map +1 -1
- package/src/diagrams/rectangle.d.ts +3 -3
- package/src/diagrams/rectangle.js +25 -25
- package/src/diagrams/rectangle.js.map +1 -1
- package/src/diagrams/svg/parse.d.ts +15 -15
- package/src/diagrams/svg/parse.js +278 -325
- package/src/diagrams/svg/parse.js.map +1 -1
- package/src/diagrams/svgPath.d.ts +2 -2
- package/src/diagrams/svgPath.js +28 -29
- package/src/diagrams/svgPath.js.map +1 -1
- package/src/diagrams/triangle.d.ts +3 -3
- package/src/diagrams/triangle.js +39 -40
- package/src/diagrams/triangle.js.map +1 -1
- package/src/diagrams/video.d.ts +5 -5
- package/src/diagrams/video.js +183 -184
- package/src/diagrams/video.js.map +1 -1
- package/src/dialog/dialog.d.ts +21 -21
- package/src/dialog/dialog.js +156 -97
- package/src/dialog/dialog.js.map +1 -1
- package/src/dialog/index.d.ts +1 -1
- package/src/dialog/index.js +1 -1
- package/src/event/event.d.ts +102 -102
- package/src/event/event.js +21 -21
- package/src/event/index.d.ts +1 -1
- package/src/event/index.js +1 -1
- package/src/map/index.d.ts +1 -1
- package/src/map/index.js +1 -1
- package/src/map/map.d.ts +21 -21
- package/src/map/map.js +211 -209
- package/src/map/map.js.map +1 -1
- package/src/options.d.ts +130 -130
- package/src/options.js +79 -79
- package/src/options.js.map +1 -1
- package/src/pen/arrow.d.ts +4 -4
- package/src/pen/arrow.js +187 -187
- package/src/pen/arrow.js.map +1 -1
- package/src/pen/index.d.ts +6 -6
- package/src/pen/index.js +6 -6
- package/src/pen/math.d.ts +28 -28
- package/src/pen/math.js +212 -303
- package/src/pen/math.js.map +1 -1
- package/src/pen/model.d.ts +514 -514
- package/src/pen/model.js +209 -209
- package/src/pen/model.js.map +1 -1
- package/src/pen/plugin.d.ts +5 -5
- package/src/pen/plugin.js +57 -87
- package/src/pen/plugin.js.map +1 -1
- package/src/pen/render.d.ts +146 -147
- package/src/pen/render.js +3233 -3235
- package/src/pen/render.js.map +1 -1
- package/src/pen/text.d.ts +8 -8
- package/src/pen/text.js +315 -374
- package/src/pen/text.js.map +1 -1
- package/src/pen/utils.d.ts +2 -2
- package/src/pen/utils.js +18 -40
- package/src/pen/utils.js.map +1 -1
- package/src/point/index.d.ts +1 -1
- package/src/point/index.js +1 -1
- package/src/point/point.d.ts +65 -65
- package/src/point/point.js +177 -178
- package/src/point/point.js.map +1 -1
- package/src/rect/index.d.ts +1 -1
- package/src/rect/index.js +1 -1
- package/src/rect/rect.d.ts +52 -52
- package/src/rect/rect.js +426 -485
- package/src/rect/rect.js.map +1 -1
- package/src/rect/triangle.d.ts +2 -2
- package/src/rect/triangle.js +9 -9
- package/src/rect/triangle.js.map +1 -1
- package/src/scroll/index.d.ts +1 -1
- package/src/scroll/index.js +1 -1
- package/src/scroll/scroll.d.ts +35 -35
- package/src/scroll/scroll.js +233 -220
- package/src/scroll/scroll.js.map +1 -1
- package/src/store/global.d.ts +25 -25
- package/src/store/global.js +17 -17
- package/src/store/global.js.map +1 -1
- package/src/store/index.d.ts +2 -2
- package/src/store/index.js +2 -2
- package/src/store/store.d.ts +228 -228
- package/src/store/store.js +86 -120
- package/src/store/store.js.map +1 -1
- package/src/theme.d.ts +13 -13
- package/src/theme.js +22 -22
- package/src/theme.js.map +1 -1
- package/src/title/index.d.ts +1 -1
- package/src/title/index.js +1 -1
- package/src/title/title.d.ts +30 -30
- package/src/title/title.js +98 -98
- package/src/title/title.js.map +1 -1
- package/src/tooltip/index.d.ts +1 -1
- package/src/tooltip/index.js +1 -1
- package/src/tooltip/tooltip.d.ts +40 -40
- package/src/tooltip/tooltip.js +171 -166
- package/src/tooltip/tooltip.js.map +1 -1
- package/src/utils/clone.d.ts +8 -8
- package/src/utils/clone.js +83 -87
- package/src/utils/clone.js.map +1 -1
- package/src/utils/color.d.ts +3 -3
- package/src/utils/color.js +109 -125
- package/src/utils/color.js.map +1 -1
- package/src/utils/error.d.ts +2 -2
- package/src/utils/error.js +5 -5
- package/src/utils/error.js.map +1 -1
- package/src/utils/file.d.ts +3 -3
- package/src/utils/file.js +39 -91
- package/src/utils/file.js.map +1 -1
- package/src/utils/index.d.ts +9 -8
- package/src/utils/index.js +9 -8
- package/src/utils/index.js.map +1 -1
- package/src/utils/math.d.ts +18 -18
- package/src/utils/math.js +113 -151
- package/src/utils/math.js.map +1 -1
- package/src/utils/object.d.ts +2 -2
- package/src/utils/object.js +20 -20
- package/src/utils/object.js.map +1 -1
- package/src/utils/padding.d.ts +7 -7
- package/src/utils/padding.js +46 -46
- package/src/utils/padding.js.map +1 -1
- package/src/utils/time.d.ts +1 -1
- package/src/utils/time.js +16 -16
- package/src/utils/time.js.map +1 -1
- package/src/utils/url.d.ts +4 -4
- package/src/utils/url.js +26 -26
- package/src/utils/url.js.map +1 -1
- package/src/utils/uuid.d.ts +4 -4
- package/src/utils/uuid.js +12 -12
- package/src/utils/browser.d.ts +0 -1
- package/src/utils/browser.js +0 -4
- package/src/utils/browser.js.map +0 -1
|
@@ -1,503 +1,441 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
this.
|
|
27
|
-
this.
|
|
28
|
-
this.
|
|
29
|
-
this.
|
|
30
|
-
this.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
this.canvas.style.
|
|
34
|
-
this.canvas.style.
|
|
35
|
-
this.
|
|
36
|
-
this.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
this.
|
|
40
|
-
this.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
this.
|
|
44
|
-
this.
|
|
45
|
-
this.
|
|
46
|
-
this.
|
|
47
|
-
this.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
this.
|
|
51
|
-
this.
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
.
|
|
68
|
-
|
|
69
|
-
this.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
.
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
pen.calculative.
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
//
|
|
164
|
-
//
|
|
165
|
-
//
|
|
166
|
-
//
|
|
167
|
-
//
|
|
168
|
-
//
|
|
169
|
-
//
|
|
170
|
-
//
|
|
171
|
-
//
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
//
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
ctx.
|
|
216
|
-
ctx.
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
ctx.
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
ctx.
|
|
432
|
-
ctx.
|
|
433
|
-
ctx.
|
|
434
|
-
ctx.
|
|
435
|
-
ctx.
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
// horizontal rule
|
|
442
|
-
ctx.beginPath();
|
|
443
|
-
ctx.lineWidth = h / 2;
|
|
444
|
-
ctx.lineDashOffset = -x % span;
|
|
445
|
-
ctx.setLineDash([1, span - 1]);
|
|
446
|
-
ctx.moveTo(0, b_y);
|
|
447
|
-
ctx.lineTo(width, b_y);
|
|
448
|
-
ctx.stroke();
|
|
449
|
-
// vertical rule
|
|
450
|
-
ctx.beginPath();
|
|
451
|
-
ctx.lineDashOffset = -y % span;
|
|
452
|
-
ctx.moveTo(b_y, 0);
|
|
453
|
-
ctx.lineTo(b_y, height);
|
|
454
|
-
ctx.stroke();
|
|
455
|
-
// the big rule
|
|
456
|
-
ctx.strokeStyle = finalRuleColor;
|
|
457
|
-
ctx.beginPath();
|
|
458
|
-
ctx.lineWidth = h;
|
|
459
|
-
ctx.lineDashOffset = -x % (span * 10);
|
|
460
|
-
ctx.setLineDash([1, span * 10 - 1]);
|
|
461
|
-
ctx.moveTo(0, h / 2);
|
|
462
|
-
ctx.lineTo(width, h / 2);
|
|
463
|
-
ctx.stroke();
|
|
464
|
-
ctx.beginPath();
|
|
465
|
-
ctx.lineDashOffset = -y % (span * 10);
|
|
466
|
-
ctx.moveTo(h / 2, 0);
|
|
467
|
-
ctx.lineTo(h / 2, height);
|
|
468
|
-
ctx.stroke();
|
|
469
|
-
ctx.beginPath();
|
|
470
|
-
ctx.fillStyle = ((_f = options.ruleOptions) === null || _f === void 0 ? void 0 : _f.textColor) || ctx.strokeStyle;
|
|
471
|
-
var text = 0 - Math.floor(x / span / 10) * 100;
|
|
472
|
-
var textTop = ((_g = options.ruleOptions) === null || _g === void 0 ? void 0 : _g.textTop) || 16;
|
|
473
|
-
var textLeft = ((_h = options.ruleOptions) === null || _h === void 0 ? void 0 : _h.textLeft) || 4;
|
|
474
|
-
if (x < 0) {
|
|
475
|
-
text -= 100;
|
|
476
|
-
}
|
|
477
|
-
for (var i = x % (span * 10); i < width; i += 10 * span, text += 100) {
|
|
478
|
-
if (span < 3 && text % 500) {
|
|
479
|
-
continue;
|
|
480
|
-
}
|
|
481
|
-
ctx.fillText(text.toString(), i + textLeft, textTop);
|
|
482
|
-
}
|
|
483
|
-
text = 0 - Math.floor(y / span / 10) * 100;
|
|
484
|
-
if (y < 0) {
|
|
485
|
-
text -= 100;
|
|
486
|
-
}
|
|
487
|
-
for (var i = y % (span * 10); i < height; i += 10 * span, text += 100) {
|
|
488
|
-
if (span < 3 && text % 500) {
|
|
489
|
-
continue;
|
|
490
|
-
}
|
|
491
|
-
ctx.save();
|
|
492
|
-
ctx.beginPath();
|
|
493
|
-
ctx.translate(textTop, i - textLeft);
|
|
494
|
-
ctx.rotate((270 * Math.PI) / 180);
|
|
495
|
-
ctx.fillText(text.toString(), 0, 0);
|
|
496
|
-
ctx.restore();
|
|
497
|
-
}
|
|
498
|
-
ctx.restore();
|
|
499
|
-
};
|
|
500
|
-
return CanvasImage;
|
|
501
|
-
}());
|
|
502
|
-
export { CanvasImage };
|
|
1
|
+
import { ctxFlip, ctxRotate, drawImage, setGlobalAlpha, getParent, CanvasLayer, } from '../pen';
|
|
2
|
+
import { rgba } from '../utils';
|
|
3
|
+
import { createOffscreen } from './offscreen';
|
|
4
|
+
export class CanvasImage {
|
|
5
|
+
parentElement;
|
|
6
|
+
store;
|
|
7
|
+
isBottom;
|
|
8
|
+
canvas = document.createElement('canvas');
|
|
9
|
+
/**
|
|
10
|
+
* 非图片的绘制
|
|
11
|
+
* isBottom true 指背景颜色,背景网格
|
|
12
|
+
* isBottom false 指 标尺
|
|
13
|
+
*/
|
|
14
|
+
otherOffsreen = createOffscreen(); // 非图片的
|
|
15
|
+
offscreen = createOffscreen();
|
|
16
|
+
animateOffsScreen = createOffscreen();
|
|
17
|
+
fitOffscreen = createOffscreen();
|
|
18
|
+
fitFlag = false; //开启自定义填充
|
|
19
|
+
currentFit;
|
|
20
|
+
activeFit;
|
|
21
|
+
constructor(parentElement, store, isBottom) {
|
|
22
|
+
this.parentElement = parentElement;
|
|
23
|
+
this.store = store;
|
|
24
|
+
this.isBottom = isBottom;
|
|
25
|
+
parentElement.appendChild(this.canvas);
|
|
26
|
+
this.canvas.style.backgroundRepeat = 'no-repeat';
|
|
27
|
+
this.canvas.style.backgroundSize = '100% 100%';
|
|
28
|
+
this.canvas.style.position = 'absolute';
|
|
29
|
+
this.canvas.style.top = '0';
|
|
30
|
+
this.canvas.style.left = '0';
|
|
31
|
+
}
|
|
32
|
+
resize(w, h) {
|
|
33
|
+
this.canvas.style.width = w + 'px';
|
|
34
|
+
this.canvas.style.height = h + 'px';
|
|
35
|
+
w = (w * this.store.dpiRatio) | 0;
|
|
36
|
+
h = (h * this.store.dpiRatio) | 0;
|
|
37
|
+
this.canvas.width = w;
|
|
38
|
+
this.canvas.height = h;
|
|
39
|
+
this.otherOffsreen.width = w;
|
|
40
|
+
this.otherOffsreen.height = h;
|
|
41
|
+
this.offscreen.width = w;
|
|
42
|
+
this.offscreen.height = h;
|
|
43
|
+
this.animateOffsScreen.width = w;
|
|
44
|
+
this.animateOffsScreen.height = h;
|
|
45
|
+
this.fitOffscreen.width = w;
|
|
46
|
+
this.fitOffscreen.height = h;
|
|
47
|
+
this.otherOffsreen
|
|
48
|
+
.getContext('2d')
|
|
49
|
+
.scale(this.store.dpiRatio, this.store.dpiRatio);
|
|
50
|
+
this.otherOffsreen.getContext('2d').textBaseline = 'middle';
|
|
51
|
+
this.offscreen
|
|
52
|
+
.getContext('2d')
|
|
53
|
+
.scale(this.store.dpiRatio, this.store.dpiRatio);
|
|
54
|
+
this.offscreen.getContext('2d').textBaseline = 'middle';
|
|
55
|
+
this.animateOffsScreen
|
|
56
|
+
.getContext('2d')
|
|
57
|
+
.scale(this.store.dpiRatio, this.store.dpiRatio);
|
|
58
|
+
this.animateOffsScreen.getContext('2d').textBaseline = 'middle';
|
|
59
|
+
this.fitOffscreen
|
|
60
|
+
.getContext('2d')
|
|
61
|
+
.scale(this.store.dpiRatio, this.store.dpiRatio);
|
|
62
|
+
this.fitOffscreen.getContext('2d').textBaseline = 'middle';
|
|
63
|
+
this.init();
|
|
64
|
+
}
|
|
65
|
+
init() {
|
|
66
|
+
this.offscreen
|
|
67
|
+
.getContext('2d')
|
|
68
|
+
.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
69
|
+
this.animateOffsScreen
|
|
70
|
+
.getContext('2d')
|
|
71
|
+
.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
72
|
+
this.fitOffscreen
|
|
73
|
+
.getContext('2d')
|
|
74
|
+
.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
75
|
+
for (const pen of this.store.data.pens) {
|
|
76
|
+
if (this.hasImage(pen)) {
|
|
77
|
+
// 只影响本层的
|
|
78
|
+
pen.calculative.imageDrawed = false;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (this.isBottom) {
|
|
82
|
+
this.store.patchFlagsBackground = true;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
this.store.patchFlagsTop = true;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
clear() {
|
|
89
|
+
this.otherOffsreen
|
|
90
|
+
.getContext('2d')
|
|
91
|
+
.clearRect(0, 0, this.otherOffsreen.width, this.otherOffsreen.height);
|
|
92
|
+
this.offscreen
|
|
93
|
+
.getContext('2d')
|
|
94
|
+
.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
95
|
+
this.animateOffsScreen
|
|
96
|
+
.getContext('2d')
|
|
97
|
+
.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
98
|
+
this.fitOffscreen
|
|
99
|
+
.getContext('2d')
|
|
100
|
+
.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
101
|
+
this.canvas
|
|
102
|
+
.getContext('2d')
|
|
103
|
+
.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
104
|
+
}
|
|
105
|
+
hasImage(pen) {
|
|
106
|
+
pen.calculative.hasImage =
|
|
107
|
+
pen.calculative &&
|
|
108
|
+
pen.calculative.inView &&
|
|
109
|
+
// !pen.isBottom == !this.isBottom && // undefined == false 结果 false
|
|
110
|
+
((this.isBottom && pen.canvasLayer === CanvasLayer.CanvasImageBottom) ||
|
|
111
|
+
(!this.isBottom && pen.canvasLayer === CanvasLayer.CanvasImage)) &&
|
|
112
|
+
pen.image &&
|
|
113
|
+
pen.calculative.img &&
|
|
114
|
+
pen.name !== 'gif';
|
|
115
|
+
return pen.calculative.hasImage;
|
|
116
|
+
}
|
|
117
|
+
render() {
|
|
118
|
+
let patchFlags = false;
|
|
119
|
+
let patchFlagsAnimate = false;
|
|
120
|
+
for (const pen of this.store.data.pens) {
|
|
121
|
+
if (this.hasImage(pen)) {
|
|
122
|
+
if (this.store.animates.has(pen)) {
|
|
123
|
+
patchFlagsAnimate = true;
|
|
124
|
+
}
|
|
125
|
+
else if (!pen.calculative.imageDrawed) {
|
|
126
|
+
patchFlags = true;
|
|
127
|
+
}
|
|
128
|
+
if (pen.parentId && this.store.animates.has(getParent(pen, true))) {
|
|
129
|
+
patchFlagsAnimate = true;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const patchFlagsBackground = this.store.patchFlagsBackground;
|
|
134
|
+
// if (patchFlagsBackground && this.isBottom) {
|
|
135
|
+
// const ctx = this.otherOffsreen.getContext('2d');
|
|
136
|
+
// ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
137
|
+
// const width = this.store.data.width || this.store.options.width;
|
|
138
|
+
// const height = this.store.data.height || this.store.options.height;
|
|
139
|
+
// const x = this.store.data.x || this.store.options.x;
|
|
140
|
+
// const y = this.store.data.y || this.store.options.y;
|
|
141
|
+
// if (width && height && this.store.bkImg) {
|
|
142
|
+
// ctx.save();
|
|
143
|
+
// ctx.drawImage(
|
|
144
|
+
// this.store.bkImg,
|
|
145
|
+
// this.store.data.origin.x + x,
|
|
146
|
+
// this.store.data.origin.y + y,
|
|
147
|
+
// width * this.store.data.scale,
|
|
148
|
+
// height * this.store.data.scale
|
|
149
|
+
// );
|
|
150
|
+
// ctx.restore();
|
|
151
|
+
// }
|
|
152
|
+
// const background =
|
|
153
|
+
// this.store.data.background ||
|
|
154
|
+
// (this.store.bkImg ? undefined : this.store.options.background);
|
|
155
|
+
// if (background) {
|
|
156
|
+
// ctx.save();
|
|
157
|
+
// ctx.fillStyle = background;
|
|
158
|
+
// if (width && height) {
|
|
159
|
+
// ctx.fillRect(
|
|
160
|
+
// this.store.data.origin.x + x,
|
|
161
|
+
// this.store.data.origin.y + y,
|
|
162
|
+
// width * this.store.data.scale,
|
|
163
|
+
// height * this.store.data.scale
|
|
164
|
+
// );
|
|
165
|
+
// } else {
|
|
166
|
+
// ctx.fillRect(0, 0, this.canvas.width, this.canvas.height);
|
|
167
|
+
// }
|
|
168
|
+
// ctx.restore();
|
|
169
|
+
// }
|
|
170
|
+
// this.renderGrid(ctx);
|
|
171
|
+
// }
|
|
172
|
+
const patchFlagsTop = this.store.patchFlagsTop;
|
|
173
|
+
if (patchFlagsTop && !this.isBottom) {
|
|
174
|
+
const ctx = this.otherOffsreen.getContext('2d');
|
|
175
|
+
ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
176
|
+
this.renderRule(ctx);
|
|
177
|
+
}
|
|
178
|
+
// 从有图片画布层切换到无图片画布
|
|
179
|
+
const patchFlagsLast = this.store.patchFlagsLast;
|
|
180
|
+
if (patchFlagsLast) {
|
|
181
|
+
const ctx = this.offscreen.getContext('2d');
|
|
182
|
+
ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
183
|
+
}
|
|
184
|
+
if (patchFlags) {
|
|
185
|
+
const ctx = this.offscreen.getContext('2d');
|
|
186
|
+
ctx.save();
|
|
187
|
+
ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
188
|
+
ctx.translate(this.store.data.x, this.store.data.y);
|
|
189
|
+
for (const pen of this.store.data.pens) {
|
|
190
|
+
//pen.calculative.imageDrawed 只用于判断是否需要重绘整块画布,不用于判断改图片节点是否绘制过
|
|
191
|
+
if (!pen.calculative.hasImage ||
|
|
192
|
+
this.store.animates.has(pen) ||
|
|
193
|
+
this.store.animates.has(getParent(pen, true))) {
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
// if (pen.template) {
|
|
197
|
+
if (pen.canvasLayer === CanvasLayer.CanvasTemplate) {
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
pen.calculative.imageDrawed = true;
|
|
201
|
+
ctx.save();
|
|
202
|
+
ctxFlip(ctx, pen);
|
|
203
|
+
if (pen.calculative.rotate) {
|
|
204
|
+
ctxRotate(ctx, pen);
|
|
205
|
+
}
|
|
206
|
+
setGlobalAlpha(ctx, pen);
|
|
207
|
+
drawImage(ctx, pen);
|
|
208
|
+
ctx.restore();
|
|
209
|
+
}
|
|
210
|
+
ctx.restore();
|
|
211
|
+
}
|
|
212
|
+
if (patchFlagsAnimate) {
|
|
213
|
+
const ctx = this.animateOffsScreen.getContext('2d');
|
|
214
|
+
ctx.save();
|
|
215
|
+
ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
216
|
+
ctx.translate(this.store.data.x, this.store.data.y);
|
|
217
|
+
for (const pen of this.store.animates) {
|
|
218
|
+
if (!pen.calculative.hasImage) {
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
// if (pen.template) {
|
|
222
|
+
if (pen.canvasLayer === CanvasLayer.CanvasTemplate) {
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
pen.calculative.imageDrawed = true;
|
|
226
|
+
ctx.save();
|
|
227
|
+
ctxFlip(ctx, pen);
|
|
228
|
+
if (pen.calculative.rotate) {
|
|
229
|
+
ctxRotate(ctx, pen);
|
|
230
|
+
}
|
|
231
|
+
setGlobalAlpha(ctx, pen);
|
|
232
|
+
drawImage(ctx, pen);
|
|
233
|
+
ctx.restore();
|
|
234
|
+
}
|
|
235
|
+
//图片组合节点 动画
|
|
236
|
+
for (const pen of this.store.data.pens) {
|
|
237
|
+
if (!pen.calculative.hasImage || !pen.parentId) {
|
|
238
|
+
continue;
|
|
239
|
+
}
|
|
240
|
+
// if (pen.template) {
|
|
241
|
+
if (pen.canvasLayer === CanvasLayer.CanvasTemplate) {
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
if (this.store.animates.has(getParent(pen, true))) {
|
|
245
|
+
pen.calculative.imageDrawed = true;
|
|
246
|
+
ctx.save();
|
|
247
|
+
ctxFlip(ctx, pen);
|
|
248
|
+
if (pen.calculative.rotate) {
|
|
249
|
+
ctxRotate(ctx, pen);
|
|
250
|
+
}
|
|
251
|
+
setGlobalAlpha(ctx, pen);
|
|
252
|
+
drawImage(ctx, pen);
|
|
253
|
+
ctx.restore();
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
ctx.restore();
|
|
257
|
+
}
|
|
258
|
+
if (!this.isBottom && !this.store.data.locked && this.fitFlag) {
|
|
259
|
+
const width = (this.store.data.width || this.store.options.width) *
|
|
260
|
+
this.store.data.scale;
|
|
261
|
+
const height = (this.store.data.height || this.store.options.height) *
|
|
262
|
+
this.store.data.scale;
|
|
263
|
+
const x = this.store.data.origin.x + this.store.data.x ||
|
|
264
|
+
this.store.options.x ||
|
|
265
|
+
0;
|
|
266
|
+
const y = this.store.data.origin.y + this.store.data.y ||
|
|
267
|
+
this.store.options.y ||
|
|
268
|
+
0;
|
|
269
|
+
const ctx = this.fitOffscreen.getContext('2d');
|
|
270
|
+
ctx.save();
|
|
271
|
+
ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
272
|
+
ctx.fillStyle = '#ffffff66';
|
|
273
|
+
ctx.strokeStyle = this.store.options.activeColor;
|
|
274
|
+
this.store.data.fits?.forEach((item, index) => {
|
|
275
|
+
ctx.fillRect(x + width * item.x, y + height * item.y, width * item.width, height * item.height);
|
|
276
|
+
if (item.active) {
|
|
277
|
+
ctx.strokeRect(x + width * item.x, y + height * item.y, width * item.width, height * item.height);
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
ctx.restore();
|
|
281
|
+
}
|
|
282
|
+
if (patchFlags ||
|
|
283
|
+
patchFlagsAnimate ||
|
|
284
|
+
(patchFlagsBackground && this.isBottom) ||
|
|
285
|
+
// this.isBottom ||
|
|
286
|
+
(patchFlagsTop && !this.isBottom)) {
|
|
287
|
+
const ctxCanvas = this.canvas.getContext('2d');
|
|
288
|
+
ctxCanvas.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
289
|
+
if (this.isBottom) {
|
|
290
|
+
// ctxCanvas.drawImage(
|
|
291
|
+
// this.otherOffsreen,
|
|
292
|
+
// 0,
|
|
293
|
+
// 0,
|
|
294
|
+
// this.canvas.width,
|
|
295
|
+
// this.canvas.height
|
|
296
|
+
// );
|
|
297
|
+
this.store.patchFlagsBackground = false;
|
|
298
|
+
}
|
|
299
|
+
ctxCanvas.drawImage(this.offscreen, 0, 0, this.canvas.width, this.canvas.height);
|
|
300
|
+
ctxCanvas.drawImage(this.animateOffsScreen, 0, 0, this.canvas.width, this.canvas.height);
|
|
301
|
+
if (!this.isBottom) {
|
|
302
|
+
ctxCanvas.drawImage(this.otherOffsreen, 0, 0, this.canvas.width, this.canvas.height);
|
|
303
|
+
this.store.patchFlagsTop = false;
|
|
304
|
+
if (!this.store.data.locked && this.fitFlag) {
|
|
305
|
+
ctxCanvas.drawImage(this.fitOffscreen, 0, 0, this.canvas.width, this.canvas.height);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
// renderGrid(
|
|
311
|
+
// ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D
|
|
312
|
+
// ) {
|
|
313
|
+
// const { data, options } = this.store;
|
|
314
|
+
// const { grid, gridRotate, gridColor, gridSize, scale } = data;
|
|
315
|
+
// if (!(grid ?? options.grid)) {
|
|
316
|
+
// // grid false 时不绘制, undefined 时看 options.grid
|
|
317
|
+
// return;
|
|
318
|
+
// }
|
|
319
|
+
// ctx.save();
|
|
320
|
+
// const { width, height } = this.canvas;
|
|
321
|
+
// if (gridRotate) {
|
|
322
|
+
// ctx.translate(width / 2, height / 2);
|
|
323
|
+
// ctx.rotate((gridRotate * Math.PI) / 180);
|
|
324
|
+
// ctx.translate(-width / 2, -height / 2);
|
|
325
|
+
// }
|
|
326
|
+
// ctx.lineWidth = 1;
|
|
327
|
+
// ctx.strokeStyle = gridColor || options.gridColor;
|
|
328
|
+
// ctx.beginPath();
|
|
329
|
+
// const size = (gridSize || options.gridSize) * scale;
|
|
330
|
+
// const longSide = Math.max(width, height);
|
|
331
|
+
// const count = Math.ceil(longSide / size);
|
|
332
|
+
// for (let i = -size * count; i < longSide * 2; i += size) {
|
|
333
|
+
// ctx.moveTo(i, -longSide);
|
|
334
|
+
// ctx.lineTo(i, longSide * 2);
|
|
335
|
+
// }
|
|
336
|
+
// for (let i = -size * count; i < longSide * 2; i += size) {
|
|
337
|
+
// ctx.moveTo(-longSide, i);
|
|
338
|
+
// ctx.lineTo(longSide * 2, i);
|
|
339
|
+
// }
|
|
340
|
+
// ctx.stroke();
|
|
341
|
+
// ctx.restore();
|
|
342
|
+
// }
|
|
343
|
+
renderRule(ctx) {
|
|
344
|
+
const { data, options } = this.store;
|
|
345
|
+
const { rule, ruleColor, scale, origin } = data;
|
|
346
|
+
if (!(rule ?? options.rule)) {
|
|
347
|
+
// rule false 时不绘制, undefined 时看 options.rule
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
const span = scale * 10;
|
|
351
|
+
ctx.save();
|
|
352
|
+
const finalRuleColor = ruleColor || options.ruleColor;
|
|
353
|
+
ctx.strokeStyle = rgba(finalRuleColor, 0.7);
|
|
354
|
+
const x = origin.x + data.x;
|
|
355
|
+
const y = origin.y + data.y;
|
|
356
|
+
const { width, height } = this.canvas;
|
|
357
|
+
let h = options.ruleOptions?.height || 20;
|
|
358
|
+
if (options.ruleOptions?.background) {
|
|
359
|
+
//背景颜色
|
|
360
|
+
ctx.beginPath();
|
|
361
|
+
ctx.fillStyle = options.ruleOptions?.background;
|
|
362
|
+
ctx.rect(0, 0, width, h);
|
|
363
|
+
ctx.fill();
|
|
364
|
+
ctx.rect(0, 0, h, height);
|
|
365
|
+
ctx.fill();
|
|
366
|
+
}
|
|
367
|
+
if (options.ruleOptions?.underline) {
|
|
368
|
+
ctx.beginPath();
|
|
369
|
+
ctx.fillStyle = rgba(finalRuleColor, 0.7);
|
|
370
|
+
ctx.moveTo(0, h);
|
|
371
|
+
ctx.lineTo(width, h);
|
|
372
|
+
ctx.stroke();
|
|
373
|
+
ctx.moveTo(h, 0);
|
|
374
|
+
ctx.lineTo(h, height);
|
|
375
|
+
ctx.stroke();
|
|
376
|
+
}
|
|
377
|
+
let b_y = h / 4;
|
|
378
|
+
if (options.ruleOptions?.baseline === "bottom") {
|
|
379
|
+
b_y = h * 3 / 4;
|
|
380
|
+
}
|
|
381
|
+
// horizontal rule
|
|
382
|
+
ctx.beginPath();
|
|
383
|
+
ctx.lineWidth = h / 2;
|
|
384
|
+
ctx.lineDashOffset = -x % span;
|
|
385
|
+
ctx.setLineDash([1, span - 1]);
|
|
386
|
+
ctx.moveTo(0, b_y);
|
|
387
|
+
ctx.lineTo(width, b_y);
|
|
388
|
+
ctx.stroke();
|
|
389
|
+
// vertical rule
|
|
390
|
+
ctx.beginPath();
|
|
391
|
+
ctx.lineDashOffset = -y % span;
|
|
392
|
+
ctx.moveTo(b_y, 0);
|
|
393
|
+
ctx.lineTo(b_y, height);
|
|
394
|
+
ctx.stroke();
|
|
395
|
+
// the big rule
|
|
396
|
+
ctx.strokeStyle = finalRuleColor;
|
|
397
|
+
ctx.beginPath();
|
|
398
|
+
ctx.lineWidth = h;
|
|
399
|
+
ctx.lineDashOffset = -x % (span * 10);
|
|
400
|
+
ctx.setLineDash([1, span * 10 - 1]);
|
|
401
|
+
ctx.moveTo(0, h / 2);
|
|
402
|
+
ctx.lineTo(width, h / 2);
|
|
403
|
+
ctx.stroke();
|
|
404
|
+
ctx.beginPath();
|
|
405
|
+
ctx.lineDashOffset = -y % (span * 10);
|
|
406
|
+
ctx.moveTo(h / 2, 0);
|
|
407
|
+
ctx.lineTo(h / 2, height);
|
|
408
|
+
ctx.stroke();
|
|
409
|
+
ctx.beginPath();
|
|
410
|
+
ctx.fillStyle = options.ruleOptions?.textColor || ctx.strokeStyle;
|
|
411
|
+
let text = 0 - Math.floor(x / span / 10) * 100;
|
|
412
|
+
let textTop = options.ruleOptions?.textTop || 16;
|
|
413
|
+
let textLeft = options.ruleOptions?.textLeft || 4;
|
|
414
|
+
if (x < 0) {
|
|
415
|
+
text -= 100;
|
|
416
|
+
}
|
|
417
|
+
for (let i = x % (span * 10); i < width; i += 10 * span, text += 100) {
|
|
418
|
+
if (span < 3 && text % 500) {
|
|
419
|
+
continue;
|
|
420
|
+
}
|
|
421
|
+
ctx.fillText(text.toString(), i + textLeft, textTop);
|
|
422
|
+
}
|
|
423
|
+
text = 0 - Math.floor(y / span / 10) * 100;
|
|
424
|
+
if (y < 0) {
|
|
425
|
+
text -= 100;
|
|
426
|
+
}
|
|
427
|
+
for (let i = y % (span * 10); i < height; i += 10 * span, text += 100) {
|
|
428
|
+
if (span < 3 && text % 500) {
|
|
429
|
+
continue;
|
|
430
|
+
}
|
|
431
|
+
ctx.save();
|
|
432
|
+
ctx.beginPath();
|
|
433
|
+
ctx.translate(textTop, i - textLeft);
|
|
434
|
+
ctx.rotate((270 * Math.PI) / 180);
|
|
435
|
+
ctx.fillText(text.toString(), 0, 0);
|
|
436
|
+
ctx.restore();
|
|
437
|
+
}
|
|
438
|
+
ctx.restore();
|
|
439
|
+
}
|
|
440
|
+
}
|
|
503
441
|
//# sourceMappingURL=canvasImage.js.map
|