@leafer-ui/draw 1.6.2 → 1.6.4

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/lib/draw.esm.js DELETED
@@ -1,2028 +0,0 @@
1
- import { defineKey, decorateLeafAttr, attr, Plugin, PathConvert, Debug, LeafData, canvasSizeAttrs, UICreator, dataProcessor, dataType, surfaceType, opacityType, visibleType, sortType, maskType, eraserType, positionType, boundsType, scaleType, rotationType, autoLayoutType, naturalBoundsType, pathInputType, pathType, hitType, strokeType, cursorType, rewrite, Leaf, useModule, rewriteAble, MathHelper, pen, PathCorner, PathDrawer, DataHelper, registerUI, Branch, LeafList, Resource, getBoundsData, Creator, CanvasManager, WaitHelper, LeaferEvent, Bounds, ResizeEvent, AutoBounds, Run, LayoutEvent, RenderEvent, WatchEvent, ImageManager, BoundsHelper, affectRenderBoundsType, PathCommandDataHelper, Platform, PointHelper, PathBounds, affectStrokeBoundsType, getPointData, ImageEvent, LeaferImage, Matrix, PathCreator } from '@leafer/core';
2
- export * from '@leafer/core';
3
-
4
- /******************************************************************************
5
- Copyright (c) Microsoft Corporation.
6
-
7
- Permission to use, copy, modify, and/or distribute this software for any
8
- purpose with or without fee is hereby granted.
9
-
10
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
11
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
12
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
13
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
14
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
15
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16
- PERFORMANCE OF THIS SOFTWARE.
17
- ***************************************************************************** */
18
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
19
-
20
-
21
- function __decorate(decorators, target, key, desc) {
22
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
23
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
24
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
25
- return c > 3 && r && Object.defineProperty(target, key, r), r;
26
- }
27
-
28
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
29
- var e = new Error(message);
30
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
31
- };
32
-
33
- function effectType(defaultValue) {
34
- return decorateLeafAttr(defaultValue, (key) => attr({
35
- set(value) {
36
- this.__setAttr(key, value);
37
- if (value)
38
- this.__.__useEffect = true;
39
- this.__layout.renderChanged || this.__layout.renderChange();
40
- }
41
- }));
42
- }
43
- function resizeType(defaultValue) {
44
- return decorateLeafAttr(defaultValue, (key) => attr({
45
- set(value) {
46
- this.__setAttr(key, value);
47
- this.__layout.boxChanged || this.__layout.boxChange();
48
- this.__updateSize();
49
- }
50
- }));
51
- }
52
- function zoomLayerType() {
53
- return (target, key) => {
54
- const privateKey = '_' + key;
55
- defineKey(target, key, {
56
- set(value) { if (this.isLeafer)
57
- this[privateKey] = value; },
58
- get() {
59
- return this.isApp
60
- ? this.tree.zoomLayer
61
- : (this.isLeafer ? (this[privateKey] || this) : this.leafer && this.leafer.zoomLayer);
62
- }
63
- });
64
- };
65
- }
66
-
67
- const TextConvert = {};
68
- const ColorConvert = {};
69
- const UnitConvert = {
70
- number(value, percentRefer) {
71
- return typeof value === 'object' ? (value.type === 'percent' ? value.value * percentRefer : value.value) : value;
72
- }
73
- };
74
- const PathArrow = {};
75
- const Paint = {};
76
- const PaintImage = {};
77
- const PaintGradient = {};
78
- const Effect = {};
79
- const Filter = {
80
- apply() { Plugin.need('filter'); }
81
- };
82
- const Export = {};
83
- const State = {
84
- setStyleName() { return Plugin.need('state'); },
85
- set() { return Plugin.need('state'); }
86
- };
87
- const Transition = {
88
- list: {},
89
- register(attrName, fn) { Transition.list[attrName] = fn; },
90
- get(attrName) { return Transition.list[attrName]; }
91
- };
92
-
93
- const { parse, objectToCanvasData } = PathConvert;
94
- const emptyPaint = {};
95
- const debug$1 = Debug.get('UIData');
96
- class UIData extends LeafData {
97
- get scale() { const { scaleX, scaleY } = this; return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX; }
98
- get __strokeWidth() {
99
- const { strokeWidth, strokeWidthFixed } = this;
100
- if (strokeWidthFixed) {
101
- const ui = this.__leaf;
102
- let { scaleX } = ui.__nowWorld || ui.__world;
103
- if (scaleX < 0)
104
- scaleX = -scaleX;
105
- return scaleX > 1 ? strokeWidth / scaleX : strokeWidth;
106
- }
107
- else
108
- return strokeWidth;
109
- }
110
- get __hasStroke() { return this.stroke && this.strokeWidth; }
111
- get __hasHalf() { const t = this; return (t.stroke && t.strokeAlign === 'center' && t.strokeWidth % 2) || undefined; }
112
- get __hasMultiPaint() {
113
- const t = this;
114
- if ((t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect)
115
- return true;
116
- return t.fill && this.__hasStroke;
117
- }
118
- get __clipAfterFill() { const t = this; return (t.cornerRadius || t.innerShadow || t.__pathInputed); }
119
- get __hasSurface() { const t = this; return (t.fill || t.stroke); }
120
- get __autoWidth() { return !this._width; }
121
- get __autoHeight() { return !this._height; }
122
- get __autoSide() { return !this._width || !this._height; }
123
- get __autoSize() { return !this._width && !this._height; }
124
- setVisible(value) {
125
- this._visible = value;
126
- const { leafer } = this.__leaf;
127
- if (leafer)
128
- leafer.watcher.hasVisible = true;
129
- }
130
- setWidth(value) {
131
- if (value < 0) {
132
- this._width = -value;
133
- this.__leaf.scaleX *= -1;
134
- debug$1.warn('width < 0, instead -scaleX ', this);
135
- }
136
- else
137
- this._width = value;
138
- }
139
- setHeight(value) {
140
- if (value < 0) {
141
- this._height = -value;
142
- this.__leaf.scaleY *= -1;
143
- debug$1.warn('height < 0, instead -scaleY', this);
144
- }
145
- else
146
- this._height = value;
147
- }
148
- setFill(value) {
149
- if (this.__naturalWidth)
150
- this.__removeNaturalSize();
151
- if (typeof value === 'string' || !value) {
152
- if (this.__isFills) {
153
- this.__removeInput('fill');
154
- PaintImage.recycleImage('fill', this);
155
- this.__isFills = false;
156
- this.__pixelFill && (this.__pixelFill = false);
157
- }
158
- this._fill = value;
159
- }
160
- else if (typeof value === 'object') {
161
- this.__setInput('fill', value);
162
- const layout = this.__leaf.__layout;
163
- layout.boxChanged || layout.boxChange();
164
- this.__isFills = true;
165
- this._fill || (this._fill = emptyPaint);
166
- }
167
- }
168
- setStroke(value) {
169
- if (typeof value === 'string' || !value) {
170
- if (this.__isStrokes) {
171
- this.__removeInput('stroke');
172
- PaintImage.recycleImage('stroke', this);
173
- this.__isStrokes = false;
174
- this.__pixelStroke && (this.__pixelStroke = false);
175
- }
176
- this._stroke = value;
177
- }
178
- else if (typeof value === 'object') {
179
- this.__setInput('stroke', value);
180
- const layout = this.__leaf.__layout;
181
- layout.boxChanged || layout.boxChange();
182
- this.__isStrokes = true;
183
- this._stroke || (this._stroke = emptyPaint);
184
- }
185
- }
186
- setPath(value) {
187
- const isString = typeof value === 'string';
188
- if (isString || (value && typeof value[0] === 'object')) {
189
- this.__setInput('path', value);
190
- this._path = isString ? parse(value) : objectToCanvasData(value);
191
- }
192
- else {
193
- if (this.__input)
194
- this.__removeInput('path');
195
- this._path = value;
196
- }
197
- }
198
- setShadow(value) {
199
- setArray(this, 'shadow', value);
200
- }
201
- setInnerShadow(value) {
202
- setArray(this, 'innerShadow', value);
203
- }
204
- setFilter(value) {
205
- setArray(this, 'filter', value);
206
- }
207
- __computePaint() {
208
- const { fill, stroke } = this.__input;
209
- if (fill)
210
- Paint.compute('fill', this.__leaf);
211
- if (stroke)
212
- Paint.compute('stroke', this.__leaf);
213
- this.__needComputePaint = false;
214
- }
215
- }
216
- function setArray(data, key, value) {
217
- data.__setInput(key, value);
218
- if (value instanceof Array) {
219
- if (value.some((item) => item.visible === false))
220
- value = value.filter((item) => item.visible !== false);
221
- value.length || (value = null);
222
- }
223
- else
224
- value = value && value.visible !== false ? [value] : null;
225
- data['_' + key] = value;
226
- }
227
-
228
- class GroupData extends UIData {
229
- }
230
-
231
- class BoxData extends GroupData {
232
- get __boxStroke() { return !this.__pathInputed; }
233
- get __drawAfterFill() { const t = this; return (t.overflow === 'hide' && (t.__clipAfterFill || t.innerShadow) && t.__leaf.children.length); }
234
- get __clipAfterFill() { return this.__leaf.isOverflow || super.__clipAfterFill; }
235
- }
236
-
237
- class LeaferData extends GroupData {
238
- __getInputData(names, options) {
239
- const data = super.__getInputData(names, options);
240
- canvasSizeAttrs.forEach(key => delete data[key]);
241
- return data;
242
- }
243
- }
244
-
245
- class FrameData extends BoxData {
246
- }
247
-
248
- class LineData extends UIData {
249
- }
250
-
251
- class RectData extends UIData {
252
- get __boxStroke() { return !this.__pathInputed; }
253
- }
254
-
255
- class EllipseData extends UIData {
256
- get __boxStroke() { return !this.__pathInputed; }
257
- }
258
-
259
- class PolygonData extends UIData {
260
- }
261
-
262
- class StarData extends UIData {
263
- }
264
-
265
- class PathData extends UIData {
266
- get __pathInputed() { return 2; }
267
- }
268
-
269
- class PenData extends GroupData {
270
- }
271
-
272
- const fontWeightMap = {
273
- 'thin': 100,
274
- 'extra-light': 200,
275
- 'light': 300,
276
- 'normal': 400,
277
- 'medium': 500,
278
- 'semi-bold': 600,
279
- 'bold': 700,
280
- 'extra-bold': 800,
281
- 'black': 900
282
- };
283
- class TextData extends UIData {
284
- get __useNaturalRatio() { return false; }
285
- setFontWeight(value) {
286
- if (typeof value === 'string') {
287
- this.__setInput('fontWeight', value);
288
- value = fontWeightMap[value] || 400;
289
- }
290
- else if (this.__input)
291
- this.__removeInput('fontWeight');
292
- this._fontWeight = value;
293
- }
294
- setBoxStyle(value) {
295
- let t = this.__leaf, box = t.__box;
296
- if (value) {
297
- const { boxStyle } = this;
298
- if (box)
299
- for (let key in boxStyle)
300
- box[key] = undefined;
301
- else
302
- box = t.__box = UICreator.get('Rect', 0);
303
- const layout = t.__layout, boxLayout = box.__layout;
304
- if (!boxStyle)
305
- box.parent = t, box.__world = t.__world, boxLayout.boxBounds = layout.boxBounds;
306
- box.set(value);
307
- if (boxLayout.strokeChanged)
308
- layout.strokeChange();
309
- if (boxLayout.renderChanged)
310
- layout.renderChange();
311
- box.__updateChange();
312
- }
313
- else if (box) {
314
- t.__box = box.parent = null;
315
- box.destroy();
316
- }
317
- this._boxStyle = value;
318
- }
319
- }
320
-
321
- class ImageData extends RectData {
322
- setUrl(value) {
323
- this.__setImageFill(value);
324
- this._url = value;
325
- }
326
- __setImageFill(value) {
327
- if (this.__leaf.image)
328
- this.__leaf.image = null;
329
- this.fill = value ? { type: 'image', mode: 'stretch', url: value } : undefined;
330
- }
331
- __getData() {
332
- const data = super.__getData();
333
- delete data.fill;
334
- return data;
335
- }
336
- __getInputData(names, options) {
337
- const data = super.__getInputData(names, options);
338
- delete data.fill;
339
- return data;
340
- }
341
- }
342
-
343
- class CanvasData extends RectData {
344
- get __isCanvas() { return true; }
345
- get __drawAfterFill() { return true; }
346
- __getInputData(names, options) {
347
- const data = super.__getInputData(names, options);
348
- data.url = this.__leaf.canvas.toDataURL('image/png');
349
- return data;
350
- }
351
- }
352
-
353
- const UIBounds = {
354
- __updateStrokeSpread() {
355
- let width = 0, boxWidth = 0;
356
- const data = this.__, { strokeAlign, strokeWidth } = data, box = this.__box;
357
- if ((data.stroke || data.hitStroke === 'all') && strokeWidth && strokeAlign !== 'inside') {
358
- boxWidth = width = strokeAlign === 'center' ? strokeWidth / 2 : strokeWidth;
359
- if (!data.__boxStroke) {
360
- const miterLimitAddWidth = data.__isLinePath ? 0 : 10 * width;
361
- const storkeCapAddWidth = data.strokeCap === 'none' ? 0 : strokeWidth;
362
- width += Math.max(miterLimitAddWidth, storkeCapAddWidth);
363
- }
364
- }
365
- if (data.__useArrow)
366
- width += strokeWidth * 5;
367
- if (box) {
368
- width = Math.max(box.__layout.strokeSpread = box.__updateStrokeSpread(), width);
369
- boxWidth = box.__layout.strokeBoxSpread;
370
- }
371
- this.__layout.strokeBoxSpread = boxWidth;
372
- return width;
373
- },
374
- __updateRenderSpread() {
375
- let width = 0;
376
- const { shadow, innerShadow, blur, backgroundBlur, filter } = this.__;
377
- if (shadow)
378
- shadow.forEach(item => width = Math.max(width, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread > 0 ? item.spread : 0) + item.blur * 1.5));
379
- if (blur)
380
- width = Math.max(width, blur);
381
- if (filter)
382
- width += Filter.getSpread(filter);
383
- let shapeWidth = width = Math.ceil(width);
384
- if (innerShadow)
385
- innerShadow.forEach(item => shapeWidth = Math.max(shapeWidth, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread < 0 ? -item.spread : 0) + item.blur * 1.5));
386
- if (backgroundBlur)
387
- shapeWidth = Math.max(shapeWidth, backgroundBlur);
388
- this.__layout.renderShapeSpread = shapeWidth;
389
- width += this.__layout.strokeSpread || 0;
390
- return this.__box ? Math.max(this.__box.__updateRenderSpread(), width) : width;
391
- }
392
- };
393
-
394
- const UIRender = {
395
- __updateChange() {
396
- const data = this.__, w = this.__world;
397
- if (data.__useEffect) {
398
- const { shadow, innerShadow, blur, backgroundBlur, filter } = this.__;
399
- data.__useEffect = !!(shadow || innerShadow || blur || backgroundBlur || filter);
400
- }
401
- const half = data.__hasHalf;
402
- w.half !== half && (w.half = half);
403
- data.__checkSingle();
404
- const complex = data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect;
405
- if (complex)
406
- data.__complex = true;
407
- else
408
- data.__complex && (data.__complex = false);
409
- },
410
- __drawFast(canvas, options) {
411
- drawFast(this, canvas, options);
412
- },
413
- __draw(canvas, options, originCanvas) {
414
- const data = this.__;
415
- if (data.__complex) {
416
- if (data.__needComputePaint)
417
- data.__computePaint();
418
- const { fill, stroke, __drawAfterFill } = data;
419
- this.__drawRenderPath(canvas);
420
- if (data.__useEffect) {
421
- const shape = Paint.shape(this, canvas, options);
422
- this.__nowWorld = this.__getNowWorld(options);
423
- const { shadow, innerShadow, filter } = data;
424
- if (shadow)
425
- Effect.shadow(this, canvas, shape);
426
- if (fill)
427
- data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
428
- if (__drawAfterFill)
429
- this.__drawAfterFill(canvas, options);
430
- if (innerShadow)
431
- Effect.innerShadow(this, canvas, shape);
432
- if (stroke)
433
- data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
434
- if (filter)
435
- Filter.apply(filter, this, this.__nowWorld, canvas, originCanvas, shape);
436
- if (shape.worldCanvas)
437
- shape.worldCanvas.recycle();
438
- shape.canvas.recycle();
439
- }
440
- else {
441
- if (fill)
442
- data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
443
- if (__drawAfterFill)
444
- this.__drawAfterFill(canvas, options);
445
- if (stroke)
446
- data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
447
- }
448
- }
449
- else {
450
- if (data.__pathInputed) {
451
- drawFast(this, canvas, options);
452
- }
453
- else {
454
- this.__drawFast(canvas, options);
455
- }
456
- }
457
- },
458
- __renderShape(canvas, options, ignoreFill, ignoreStroke) {
459
- if (this.__worldOpacity) {
460
- canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
461
- const { fill, stroke } = this.__;
462
- this.__drawRenderPath(canvas);
463
- if (fill && !ignoreFill)
464
- this.__.__pixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
465
- if (this.__.__isCanvas)
466
- this.__drawAfterFill(canvas, options);
467
- if (stroke && !ignoreStroke)
468
- this.__.__pixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
469
- }
470
- },
471
- __drawAfterFill(canvas, options) {
472
- if (this.__.__clipAfterFill) {
473
- canvas.save();
474
- this.windingRule ? canvas.clip(this.windingRule) : canvas.clip();
475
- this.__drawContent(canvas, options);
476
- canvas.restore();
477
- }
478
- else
479
- this.__drawContent(canvas, options);
480
- }
481
- };
482
- function drawFast(ui, canvas, options) {
483
- const { fill, stroke, __drawAfterFill } = ui.__;
484
- ui.__drawRenderPath(canvas);
485
- if (fill)
486
- Paint.fill(fill, ui, canvas);
487
- if (__drawAfterFill)
488
- ui.__drawAfterFill(canvas, options);
489
- if (stroke)
490
- Paint.stroke(stroke, ui, canvas);
491
- }
492
-
493
- const RectRender = {
494
- __drawFast(canvas, options) {
495
- let { x, y, width, height } = this.__layout.boxBounds;
496
- const { fill, stroke, __drawAfterFill } = this.__;
497
- if (fill) {
498
- canvas.fillStyle = fill;
499
- canvas.fillRect(x, y, width, height);
500
- }
501
- if (__drawAfterFill)
502
- this.__drawAfterFill(canvas, options);
503
- if (stroke) {
504
- const { strokeAlign, __strokeWidth } = this.__;
505
- if (!__strokeWidth)
506
- return;
507
- canvas.setStroke(stroke, __strokeWidth, this.__);
508
- const half = __strokeWidth / 2;
509
- switch (strokeAlign) {
510
- case 'center':
511
- canvas.strokeRect(0, 0, width, height);
512
- break;
513
- case 'inside':
514
- width -= __strokeWidth, height -= __strokeWidth;
515
- if (width < 0 || height < 0) {
516
- canvas.save();
517
- this.__clip(canvas, options);
518
- canvas.strokeRect(x + half, y + half, width, height);
519
- canvas.restore();
520
- }
521
- else
522
- canvas.strokeRect(x + half, y + half, width, height);
523
- break;
524
- case 'outside':
525
- canvas.strokeRect(x - half, y - half, width + __strokeWidth, height + __strokeWidth);
526
- break;
527
- }
528
- }
529
- }
530
- };
531
-
532
- var UI_1;
533
- let UI = UI_1 = class UI extends Leaf {
534
- get app() { return this.leafer && this.leafer.app; }
535
- get isFrame() { return false; }
536
- set scale(value) { MathHelper.assignScale(this, value); }
537
- get scale() { return this.__.scale; }
538
- get pen() {
539
- const { path } = this.__;
540
- pen.set(this.path = path || []);
541
- if (!path)
542
- this.__drawPathByBox(pen);
543
- return pen;
544
- }
545
- constructor(data) {
546
- super(data);
547
- }
548
- reset(_data) { }
549
- set(data, transition) {
550
- if (data) {
551
- if (transition) {
552
- if (transition === 'temp') {
553
- this.lockNormalStyle = true;
554
- Object.assign(this, data);
555
- this.lockNormalStyle = false;
556
- }
557
- else
558
- this.animate(data, transition);
559
- }
560
- else
561
- Object.assign(this, data);
562
- }
563
- }
564
- get(name) {
565
- return typeof name === 'string' ? this.__.__getInput(name) : this.__.__getInputData(name);
566
- }
567
- createProxyData() { return undefined; }
568
- find(_condition, _options) { return Plugin.need('find'); }
569
- findTag(tag) { return this.find({ tag }); }
570
- findOne(_condition, _options) { return Plugin.need('find'); }
571
- findId(id) { return this.findOne({ id }); }
572
- getPath(curve, pathForRender) {
573
- this.__layout.update();
574
- let path = pathForRender ? this.__.__pathForRender : this.__.path;
575
- if (!path)
576
- pen.set(path = []), this.__drawPathByBox(pen);
577
- return curve ? PathConvert.toCanvasData(path, true) : path;
578
- }
579
- getPathString(curve, pathForRender, floatLength) {
580
- return PathConvert.stringify(this.getPath(curve, pathForRender), floatLength);
581
- }
582
- load() {
583
- this.__.__computePaint();
584
- }
585
- __onUpdateSize() {
586
- if (this.__.__input) {
587
- const data = this.__;
588
- (data.lazy && !this.__inLazyBounds && !Export.running) ? data.__needComputePaint = true : data.__computePaint();
589
- }
590
- }
591
- __updateRenderPath() {
592
- if (this.__.path) {
593
- const data = this.__;
594
- data.__pathForRender = data.cornerRadius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
595
- if (data.__useArrow)
596
- PathArrow.addArrows(this, !data.cornerRadius);
597
- }
598
- }
599
- __drawRenderPath(canvas) {
600
- canvas.beginPath();
601
- this.__drawPathByData(canvas, this.__.__pathForRender);
602
- }
603
- __drawPath(canvas) {
604
- canvas.beginPath();
605
- this.__drawPathByData(canvas, this.__.path);
606
- }
607
- __drawPathByData(drawer, data) {
608
- data ? PathDrawer.drawPathByData(drawer, data) : this.__drawPathByBox(drawer);
609
- }
610
- __drawPathByBox(drawer) {
611
- const { x, y, width, height } = this.__layout.boxBounds;
612
- if (this.__.cornerRadius) {
613
- const { cornerRadius } = this.__;
614
- drawer.roundRect(x, y, width, height, typeof cornerRadius === 'number' ? [cornerRadius] : cornerRadius);
615
- }
616
- else
617
- drawer.rect(x, y, width, height);
618
- }
619
- drawImagePlaceholder(canvas, _image) {
620
- Paint.fill(this.__.placeholderColor, this, canvas);
621
- }
622
- animate(_keyframe, _options, _type, _isTemp) {
623
- return Plugin.need('animate');
624
- }
625
- killAnimate(_type, _nextStyle) { }
626
- export(_filename, _options) {
627
- return Plugin.need('export');
628
- }
629
- syncExport(_filename, _options) {
630
- return Plugin.need('export');
631
- }
632
- clone(data) {
633
- const json = DataHelper.clone(this.toJSON());
634
- if (data)
635
- Object.assign(json, data);
636
- return UI_1.one(json);
637
- }
638
- static one(data, x, y, width, height) {
639
- return UICreator.get(data.tag || this.prototype.__tag, data, x, y, width, height);
640
- }
641
- static registerUI() {
642
- registerUI()(this);
643
- }
644
- static registerData(data) {
645
- dataProcessor(data)(this.prototype);
646
- }
647
- static setEditConfig(_config) { }
648
- static setEditOuter(_toolName) { }
649
- static setEditInner(_editorName) { }
650
- destroy() {
651
- this.fill = this.stroke = null;
652
- if (this.__animate)
653
- this.killAnimate();
654
- super.destroy();
655
- }
656
- };
657
- __decorate([
658
- dataProcessor(UIData)
659
- ], UI.prototype, "__", void 0);
660
- __decorate([
661
- zoomLayerType()
662
- ], UI.prototype, "zoomLayer", void 0);
663
- __decorate([
664
- dataType('')
665
- ], UI.prototype, "id", void 0);
666
- __decorate([
667
- dataType('')
668
- ], UI.prototype, "name", void 0);
669
- __decorate([
670
- dataType('')
671
- ], UI.prototype, "className", void 0);
672
- __decorate([
673
- surfaceType('pass-through')
674
- ], UI.prototype, "blendMode", void 0);
675
- __decorate([
676
- opacityType(1)
677
- ], UI.prototype, "opacity", void 0);
678
- __decorate([
679
- visibleType(true)
680
- ], UI.prototype, "visible", void 0);
681
- __decorate([
682
- surfaceType(false)
683
- ], UI.prototype, "locked", void 0);
684
- __decorate([
685
- surfaceType(false)
686
- ], UI.prototype, "dim", void 0);
687
- __decorate([
688
- surfaceType(false)
689
- ], UI.prototype, "dimskip", void 0);
690
- __decorate([
691
- sortType(0)
692
- ], UI.prototype, "zIndex", void 0);
693
- __decorate([
694
- maskType(false)
695
- ], UI.prototype, "mask", void 0);
696
- __decorate([
697
- eraserType(false)
698
- ], UI.prototype, "eraser", void 0);
699
- __decorate([
700
- positionType(0, true)
701
- ], UI.prototype, "x", void 0);
702
- __decorate([
703
- positionType(0, true)
704
- ], UI.prototype, "y", void 0);
705
- __decorate([
706
- boundsType(100, true)
707
- ], UI.prototype, "width", void 0);
708
- __decorate([
709
- boundsType(100, true)
710
- ], UI.prototype, "height", void 0);
711
- __decorate([
712
- scaleType(1, true)
713
- ], UI.prototype, "scaleX", void 0);
714
- __decorate([
715
- scaleType(1, true)
716
- ], UI.prototype, "scaleY", void 0);
717
- __decorate([
718
- rotationType(0, true)
719
- ], UI.prototype, "rotation", void 0);
720
- __decorate([
721
- rotationType(0, true)
722
- ], UI.prototype, "skewX", void 0);
723
- __decorate([
724
- rotationType(0, true)
725
- ], UI.prototype, "skewY", void 0);
726
- __decorate([
727
- positionType(0, true)
728
- ], UI.prototype, "offsetX", void 0);
729
- __decorate([
730
- positionType(0, true)
731
- ], UI.prototype, "offsetY", void 0);
732
- __decorate([
733
- positionType(0, true)
734
- ], UI.prototype, "scrollX", void 0);
735
- __decorate([
736
- positionType(0, true)
737
- ], UI.prototype, "scrollY", void 0);
738
- __decorate([
739
- autoLayoutType()
740
- ], UI.prototype, "origin", void 0);
741
- __decorate([
742
- autoLayoutType()
743
- ], UI.prototype, "around", void 0);
744
- __decorate([
745
- dataType(false)
746
- ], UI.prototype, "lazy", void 0);
747
- __decorate([
748
- naturalBoundsType(1)
749
- ], UI.prototype, "pixelRatio", void 0);
750
- __decorate([
751
- pathInputType()
752
- ], UI.prototype, "path", void 0);
753
- __decorate([
754
- pathType()
755
- ], UI.prototype, "windingRule", void 0);
756
- __decorate([
757
- pathType(true)
758
- ], UI.prototype, "closed", void 0);
759
- __decorate([
760
- boundsType(0)
761
- ], UI.prototype, "padding", void 0);
762
- __decorate([
763
- boundsType(false)
764
- ], UI.prototype, "lockRatio", void 0);
765
- __decorate([
766
- boundsType()
767
- ], UI.prototype, "widthRange", void 0);
768
- __decorate([
769
- boundsType()
770
- ], UI.prototype, "heightRange", void 0);
771
- __decorate([
772
- dataType(false)
773
- ], UI.prototype, "draggable", void 0);
774
- __decorate([
775
- dataType()
776
- ], UI.prototype, "dragBounds", void 0);
777
- __decorate([
778
- dataType(false)
779
- ], UI.prototype, "editable", void 0);
780
- __decorate([
781
- hitType(true)
782
- ], UI.prototype, "hittable", void 0);
783
- __decorate([
784
- hitType('path')
785
- ], UI.prototype, "hitFill", void 0);
786
- __decorate([
787
- strokeType('path')
788
- ], UI.prototype, "hitStroke", void 0);
789
- __decorate([
790
- hitType(false)
791
- ], UI.prototype, "hitBox", void 0);
792
- __decorate([
793
- hitType(true)
794
- ], UI.prototype, "hitChildren", void 0);
795
- __decorate([
796
- hitType(true)
797
- ], UI.prototype, "hitSelf", void 0);
798
- __decorate([
799
- hitType()
800
- ], UI.prototype, "hitRadius", void 0);
801
- __decorate([
802
- cursorType('')
803
- ], UI.prototype, "cursor", void 0);
804
- __decorate([
805
- surfaceType()
806
- ], UI.prototype, "fill", void 0);
807
- __decorate([
808
- strokeType()
809
- ], UI.prototype, "stroke", void 0);
810
- __decorate([
811
- strokeType('inside')
812
- ], UI.prototype, "strokeAlign", void 0);
813
- __decorate([
814
- strokeType(1)
815
- ], UI.prototype, "strokeWidth", void 0);
816
- __decorate([
817
- strokeType(false)
818
- ], UI.prototype, "strokeWidthFixed", void 0);
819
- __decorate([
820
- strokeType('none')
821
- ], UI.prototype, "strokeCap", void 0);
822
- __decorate([
823
- strokeType('miter')
824
- ], UI.prototype, "strokeJoin", void 0);
825
- __decorate([
826
- strokeType()
827
- ], UI.prototype, "dashPattern", void 0);
828
- __decorate([
829
- strokeType(0)
830
- ], UI.prototype, "dashOffset", void 0);
831
- __decorate([
832
- strokeType(10)
833
- ], UI.prototype, "miterLimit", void 0);
834
- __decorate([
835
- pathType(0)
836
- ], UI.prototype, "cornerRadius", void 0);
837
- __decorate([
838
- pathType()
839
- ], UI.prototype, "cornerSmoothing", void 0);
840
- __decorate([
841
- effectType()
842
- ], UI.prototype, "shadow", void 0);
843
- __decorate([
844
- effectType()
845
- ], UI.prototype, "innerShadow", void 0);
846
- __decorate([
847
- effectType()
848
- ], UI.prototype, "blur", void 0);
849
- __decorate([
850
- effectType()
851
- ], UI.prototype, "backgroundBlur", void 0);
852
- __decorate([
853
- effectType()
854
- ], UI.prototype, "grayscale", void 0);
855
- __decorate([
856
- effectType()
857
- ], UI.prototype, "filter", void 0);
858
- __decorate([
859
- surfaceType()
860
- ], UI.prototype, "placeholderColor", void 0);
861
- __decorate([
862
- dataType({})
863
- ], UI.prototype, "data", void 0);
864
- __decorate([
865
- rewrite(Leaf.prototype.reset)
866
- ], UI.prototype, "reset", null);
867
- UI = UI_1 = __decorate([
868
- useModule(UIBounds),
869
- useModule(UIRender),
870
- rewriteAble()
871
- ], UI);
872
-
873
- let Group = class Group extends UI {
874
- get __tag() { return 'Group'; }
875
- get isBranch() { return true; }
876
- constructor(data) {
877
- super(data);
878
- }
879
- reset(data) {
880
- this.__setBranch();
881
- super.reset(data);
882
- }
883
- __setBranch() {
884
- if (!this.children)
885
- this.children = [];
886
- }
887
- set(data, transition) {
888
- if (data) {
889
- if (data.children) {
890
- const { children } = data;
891
- delete data.children;
892
- this.children ? this.clear() : this.__setBranch();
893
- super.set(data, transition);
894
- children.forEach(child => this.add(child));
895
- data.children = children;
896
- }
897
- else
898
- super.set(data, transition);
899
- }
900
- }
901
- toJSON(options) {
902
- const data = super.toJSON(options);
903
- data.children = this.children.map(child => child.toJSON(options));
904
- return data;
905
- }
906
- pick(_hitPoint, _options) { return undefined; }
907
- addAt(child, index) {
908
- this.add(child, index);
909
- }
910
- addAfter(child, after) {
911
- this.add(child, this.children.indexOf(after) + 1);
912
- }
913
- addBefore(child, before) {
914
- this.add(child, this.children.indexOf(before));
915
- }
916
- add(_child, _index) { }
917
- addMany(..._children) { }
918
- remove(_child, _destroy) { }
919
- removeAll(_destroy) { }
920
- clear() { }
921
- };
922
- __decorate([
923
- dataProcessor(GroupData)
924
- ], Group.prototype, "__", void 0);
925
- __decorate([
926
- boundsType(0)
927
- ], Group.prototype, "width", void 0);
928
- __decorate([
929
- boundsType(0)
930
- ], Group.prototype, "height", void 0);
931
- Group = __decorate([
932
- useModule(Branch),
933
- registerUI()
934
- ], Group);
935
-
936
- var Leafer_1;
937
- const debug = Debug.get('Leafer');
938
- let Leafer = Leafer_1 = class Leafer extends Group {
939
- get __tag() { return 'Leafer'; }
940
- get isApp() { return false; }
941
- get app() { return this.parent || this; }
942
- get isLeafer() { return true; }
943
- get imageReady() { return this.viewReady && Resource.isComplete; }
944
- get layoutLocked() { return !this.layouter.running; }
945
- get FPS() { return this.renderer ? this.renderer.FPS : 60; }
946
- get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
947
- get clientBounds() { return (this.canvas && this.canvas.getClientBounds(true)) || getBoundsData(); }
948
- constructor(userConfig, data) {
949
- super(data);
950
- this.config = {
951
- start: true,
952
- hittable: true,
953
- smooth: true,
954
- lazySpeard: 100,
955
- };
956
- this.leafs = 0;
957
- this.__eventIds = [];
958
- this.__controllers = [];
959
- this.__readyWait = [];
960
- this.__viewReadyWait = [];
961
- this.__viewCompletedWait = [];
962
- this.__nextRenderWait = [];
963
- this.userConfig = userConfig;
964
- if (userConfig && (userConfig.view || userConfig.width))
965
- this.init(userConfig);
966
- Leafer_1.list.add(this);
967
- }
968
- init(userConfig, parentApp) {
969
- if (this.canvas)
970
- return;
971
- let start;
972
- const { config } = this;
973
- this.__setLeafer(this);
974
- if (parentApp) {
975
- this.parentApp = parentApp;
976
- this.__bindApp(parentApp);
977
- start = parentApp.running;
978
- }
979
- if (userConfig) {
980
- this.parent = parentApp;
981
- this.initType(userConfig.type);
982
- this.parent = undefined;
983
- DataHelper.assign(config, userConfig);
984
- }
985
- const canvas = this.canvas = Creator.canvas(config);
986
- this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
987
- if (this.isApp)
988
- this.__setApp();
989
- this.__checkAutoLayout(config, parentApp);
990
- this.view = canvas.view;
991
- if (!parentApp) {
992
- this.selector = Creator.selector(this);
993
- this.interaction = Creator.interaction(this, canvas, this.selector, config);
994
- if (this.interaction) {
995
- this.__controllers.unshift(this.interaction);
996
- this.hitCanvasManager = Creator.hitCanvasManager();
997
- }
998
- this.canvasManager = new CanvasManager();
999
- start = config.start;
1000
- }
1001
- this.hittable = config.hittable;
1002
- this.fill = config.fill;
1003
- this.canvasManager.add(canvas);
1004
- this.__listenEvents();
1005
- if (start)
1006
- this.__startTimer = setTimeout(this.start.bind(this));
1007
- WaitHelper.run(this.__initWait);
1008
- this.onInit();
1009
- }
1010
- onInit() { }
1011
- initType(_type) { }
1012
- set(data, transition) {
1013
- this.waitInit(() => { super.set(data, transition); });
1014
- }
1015
- start() {
1016
- clearTimeout(this.__startTimer);
1017
- if (!this.running && this.canvas) {
1018
- this.running = true;
1019
- this.ready ? this.emitLeafer(LeaferEvent.RESTART) : this.emitLeafer(LeaferEvent.START);
1020
- this.__controllers.forEach(item => item.start());
1021
- if (!this.isApp)
1022
- this.renderer.render();
1023
- }
1024
- }
1025
- stop() {
1026
- clearTimeout(this.__startTimer);
1027
- if (this.running && this.canvas) {
1028
- this.__controllers.forEach(item => item.stop());
1029
- this.running = false;
1030
- this.emitLeafer(LeaferEvent.STOP);
1031
- }
1032
- }
1033
- unlockLayout() {
1034
- this.layouter.start();
1035
- this.updateLayout();
1036
- }
1037
- lockLayout() {
1038
- this.updateLayout();
1039
- this.layouter.stop();
1040
- }
1041
- resize(size) {
1042
- const data = DataHelper.copyAttrs({}, size, canvasSizeAttrs);
1043
- Object.keys(data).forEach(key => this[key] = data[key]);
1044
- }
1045
- forceRender(bounds, sync) {
1046
- const { renderer } = this;
1047
- if (renderer) {
1048
- renderer.addBlock(bounds ? new Bounds(bounds) : this.canvas.bounds);
1049
- if (this.viewReady)
1050
- sync ? renderer.render() : renderer.update();
1051
- }
1052
- }
1053
- requestRender(change = false) {
1054
- if (this.renderer)
1055
- this.renderer.update(change);
1056
- }
1057
- updateCursor(cursor) {
1058
- const i = this.interaction;
1059
- if (i)
1060
- cursor ? i.setCursor(cursor) : i.updateCursor();
1061
- }
1062
- updateLazyBounds() {
1063
- this.lazyBounds = this.canvas.bounds.clone().spread(this.config.lazySpeard);
1064
- }
1065
- __doResize(size) {
1066
- const { canvas } = this;
1067
- if (!canvas || canvas.isSameSize(size))
1068
- return;
1069
- const old = DataHelper.copyAttrs({}, this.canvas, canvasSizeAttrs);
1070
- canvas.resize(size);
1071
- this.updateLazyBounds();
1072
- this.__onResize(new ResizeEvent(size, old));
1073
- }
1074
- __onResize(event) {
1075
- this.emitEvent(event);
1076
- DataHelper.copyAttrs(this.__, event, canvasSizeAttrs);
1077
- setTimeout(() => { if (this.canvasManager)
1078
- this.canvasManager.clearRecycled(); }, 0);
1079
- }
1080
- __setApp() { }
1081
- __bindApp(app) {
1082
- this.selector = app.selector;
1083
- this.interaction = app.interaction;
1084
- this.canvasManager = app.canvasManager;
1085
- this.hitCanvasManager = app.hitCanvasManager;
1086
- }
1087
- __setLeafer(leafer) {
1088
- this.leafer = leafer;
1089
- this.__level = 1;
1090
- }
1091
- __checkAutoLayout(config, parentApp) {
1092
- if (!parentApp) {
1093
- if (!config.width || !config.height)
1094
- this.autoLayout = new AutoBounds(config);
1095
- this.canvas.startAutoLayout(this.autoLayout, this.__onResize.bind(this));
1096
- }
1097
- }
1098
- __setAttr(attrName, newValue) {
1099
- if (this.canvas) {
1100
- if (canvasSizeAttrs.includes(attrName)) {
1101
- this.__changeCanvasSize(attrName, newValue);
1102
- }
1103
- else if (attrName === 'fill') {
1104
- this.__changeFill(newValue);
1105
- }
1106
- else if (attrName === 'hittable') {
1107
- if (!this.parent)
1108
- this.canvas.hittable = newValue;
1109
- }
1110
- else if (attrName === 'zIndex') {
1111
- this.canvas.zIndex = newValue;
1112
- setTimeout(() => this.parent && this.parent.__updateSortChildren());
1113
- }
1114
- }
1115
- return super.__setAttr(attrName, newValue);
1116
- }
1117
- __getAttr(attrName) {
1118
- if (this.canvas && canvasSizeAttrs.includes(attrName))
1119
- return this.canvas[attrName];
1120
- return super.__getAttr(attrName);
1121
- }
1122
- __changeCanvasSize(attrName, newValue) {
1123
- const data = DataHelper.copyAttrs({}, this.canvas, canvasSizeAttrs);
1124
- data[attrName] = this.config[attrName] = newValue;
1125
- if (newValue)
1126
- this.canvas.stopAutoLayout();
1127
- this.__doResize(data);
1128
- }
1129
- __changeFill(newValue) {
1130
- this.config.fill = newValue;
1131
- if (this.canvas.allowBackgroundColor)
1132
- this.canvas.backgroundColor = newValue;
1133
- else
1134
- this.forceRender();
1135
- }
1136
- __onCreated() {
1137
- this.created = true;
1138
- }
1139
- __onReady() {
1140
- this.ready = true;
1141
- this.emitLeafer(LeaferEvent.BEFORE_READY);
1142
- this.emitLeafer(LeaferEvent.READY);
1143
- this.emitLeafer(LeaferEvent.AFTER_READY);
1144
- WaitHelper.run(this.__readyWait);
1145
- }
1146
- __onViewReady() {
1147
- if (this.viewReady)
1148
- return;
1149
- this.viewReady = true;
1150
- this.emitLeafer(LeaferEvent.VIEW_READY);
1151
- WaitHelper.run(this.__viewReadyWait);
1152
- }
1153
- __onLayoutEnd() {
1154
- const { grow, width: fixedWidth, height: fixedHeight } = this.config;
1155
- if (grow) {
1156
- let { width, height, pixelRatio } = this;
1157
- const bounds = grow === 'box' ? this.worldBoxBounds : this.__world;
1158
- if (!fixedWidth)
1159
- width = Math.max(1, bounds.x + bounds.width);
1160
- if (!fixedHeight)
1161
- height = Math.max(1, bounds.y + bounds.height);
1162
- this.__doResize({ width, height, pixelRatio });
1163
- }
1164
- if (!this.ready)
1165
- this.__onReady();
1166
- }
1167
- __onNextRender() {
1168
- if (this.viewReady) {
1169
- WaitHelper.run(this.__nextRenderWait);
1170
- const { imageReady } = this;
1171
- if (imageReady && !this.viewCompleted)
1172
- this.__checkViewCompleted();
1173
- if (!imageReady) {
1174
- this.viewCompleted = false;
1175
- this.requestRender();
1176
- }
1177
- }
1178
- else
1179
- this.requestRender();
1180
- }
1181
- __checkViewCompleted(emit = true) {
1182
- this.nextRender(() => {
1183
- if (this.imageReady) {
1184
- if (emit)
1185
- this.emitLeafer(LeaferEvent.VIEW_COMPLETED);
1186
- WaitHelper.run(this.__viewCompletedWait);
1187
- this.viewCompleted = true;
1188
- }
1189
- });
1190
- }
1191
- __onWatchData() {
1192
- if (this.watcher.childrenChanged && this.interaction) {
1193
- this.nextRender(() => this.interaction.updateCursor());
1194
- }
1195
- }
1196
- waitInit(item, bind) {
1197
- if (bind)
1198
- item = item.bind(bind);
1199
- if (!this.__initWait)
1200
- this.__initWait = [];
1201
- this.canvas ? item() : this.__initWait.push(item);
1202
- }
1203
- waitReady(item, bind) {
1204
- if (bind)
1205
- item = item.bind(bind);
1206
- this.ready ? item() : this.__readyWait.push(item);
1207
- }
1208
- waitViewReady(item, bind) {
1209
- if (bind)
1210
- item = item.bind(bind);
1211
- this.viewReady ? item() : this.__viewReadyWait.push(item);
1212
- }
1213
- waitViewCompleted(item, bind) {
1214
- if (bind)
1215
- item = item.bind(bind);
1216
- this.__viewCompletedWait.push(item);
1217
- if (this.viewCompleted)
1218
- this.__checkViewCompleted(false);
1219
- else if (!this.running)
1220
- this.start();
1221
- }
1222
- nextRender(item, bind, off) {
1223
- if (bind)
1224
- item = item.bind(bind);
1225
- const list = this.__nextRenderWait;
1226
- if (off) {
1227
- for (let i = 0; i < list.length; i++) {
1228
- if (list[i] === item) {
1229
- list.splice(i, 1);
1230
- break;
1231
- }
1232
- }
1233
- }
1234
- else
1235
- list.push(item);
1236
- this.requestRender();
1237
- }
1238
- zoom(_zoomType, _padding, _fixedScale, _transition) {
1239
- return Plugin.need('view');
1240
- }
1241
- getValidMove(moveX, moveY) { return { x: moveX, y: moveY }; }
1242
- getValidScale(changeScale) { return changeScale; }
1243
- getWorldPointByClient(clientPoint, updateClient) {
1244
- return this.interaction && this.interaction.getLocal(clientPoint, updateClient);
1245
- }
1246
- getPagePointByClient(clientPoint, updateClient) {
1247
- return this.getPagePoint(this.getWorldPointByClient(clientPoint, updateClient));
1248
- }
1249
- getClientPointByWorld(worldPoint) {
1250
- const { x, y } = this.clientBounds;
1251
- return { x: x + worldPoint.x, y: y + worldPoint.y };
1252
- }
1253
- updateClientBounds() {
1254
- this.canvas && this.canvas.updateClientBounds();
1255
- }
1256
- receiveEvent(_event) { }
1257
- emitLeafer(type) {
1258
- this.emitEvent(new LeaferEvent(type, this));
1259
- }
1260
- __listenEvents() {
1261
- const runId = Run.start('FirstCreate ' + this.innerName);
1262
- this.once(LeaferEvent.START, () => Run.end(runId));
1263
- this.once(LayoutEvent.START, () => this.updateLazyBounds());
1264
- this.once(RenderEvent.START, () => this.__onCreated());
1265
- this.once(RenderEvent.END, () => this.__onViewReady());
1266
- this.__eventIds.push(this.on_(WatchEvent.DATA, this.__onWatchData, this), this.on_(LayoutEvent.END, this.__onLayoutEnd, this), this.on_(RenderEvent.NEXT, this.__onNextRender, this));
1267
- }
1268
- __removeListenEvents() {
1269
- this.off_(this.__eventIds);
1270
- this.__eventIds.length = 0;
1271
- }
1272
- destroy(sync) {
1273
- const doDestory = () => {
1274
- if (!this.destroyed) {
1275
- Leafer_1.list.remove(this);
1276
- try {
1277
- this.stop();
1278
- this.emitEvent(new LeaferEvent(LeaferEvent.END, this));
1279
- this.__removeListenEvents();
1280
- this.__controllers.forEach(item => !(this.parent && item === this.interaction) && item.destroy());
1281
- this.__controllers.length = 0;
1282
- if (!this.parent) {
1283
- if (this.selector)
1284
- this.selector.destroy();
1285
- if (this.hitCanvasManager)
1286
- this.hitCanvasManager.destroy();
1287
- this.canvasManager.destroy();
1288
- }
1289
- this.canvas.destroy();
1290
- this.config.view = this.view = this.parentApp = null;
1291
- if (this.userConfig)
1292
- this.userConfig.view = null;
1293
- super.destroy();
1294
- setTimeout(() => { ImageManager.clearRecycled(); }, 100);
1295
- }
1296
- catch (e) {
1297
- debug.error(e);
1298
- }
1299
- }
1300
- };
1301
- sync ? doDestory() : setTimeout(doDestory);
1302
- }
1303
- };
1304
- Leafer.list = new LeafList();
1305
- __decorate([
1306
- dataProcessor(LeaferData)
1307
- ], Leafer.prototype, "__", void 0);
1308
- __decorate([
1309
- boundsType()
1310
- ], Leafer.prototype, "pixelRatio", void 0);
1311
- Leafer = Leafer_1 = __decorate([
1312
- registerUI()
1313
- ], Leafer);
1314
-
1315
- let Rect = class Rect extends UI {
1316
- get __tag() { return 'Rect'; }
1317
- constructor(data) {
1318
- super(data);
1319
- }
1320
- };
1321
- __decorate([
1322
- dataProcessor(RectData)
1323
- ], Rect.prototype, "__", void 0);
1324
- Rect = __decorate([
1325
- useModule(RectRender),
1326
- rewriteAble(),
1327
- registerUI()
1328
- ], Rect);
1329
-
1330
- const { copy, add, includes: includes$1 } = BoundsHelper;
1331
- const rect = Rect.prototype, group = Group.prototype;
1332
- const childrenRenderBounds = {};
1333
- let Box = class Box extends Group {
1334
- get __tag() { return 'Box'; }
1335
- get isBranchLeaf() { return true; }
1336
- constructor(data) {
1337
- super(data);
1338
- this.__layout.renderChanged || this.__layout.renderChange();
1339
- }
1340
- __updateStrokeSpread() { return 0; }
1341
- __updateRectRenderSpread() { return 0; }
1342
- __updateRenderSpread() { return this.__updateRectRenderSpread() || -1; }
1343
- __updateRectBoxBounds() { }
1344
- __updateBoxBounds(_secondLayout) {
1345
- const data = this.__;
1346
- if (this.children.length && !this.pathInputed) {
1347
- if (data.__autoSide) {
1348
- if (data.__hasSurface)
1349
- this.__extraUpdate();
1350
- super.__updateBoxBounds();
1351
- const { boxBounds } = this.__layout;
1352
- if (!data.__autoSize) {
1353
- if (data.__autoWidth) {
1354
- boxBounds.width += boxBounds.x, boxBounds.x = 0;
1355
- boxBounds.height = data.height, boxBounds.y = 0;
1356
- }
1357
- else {
1358
- boxBounds.height += boxBounds.y, boxBounds.y = 0;
1359
- boxBounds.width = data.width, boxBounds.x = 0;
1360
- }
1361
- }
1362
- this.__updateNaturalSize();
1363
- }
1364
- else
1365
- this.__updateRectBoxBounds();
1366
- }
1367
- else
1368
- this.__updateRectBoxBounds();
1369
- }
1370
- __updateStrokeBounds() { }
1371
- __updateRenderBounds() {
1372
- let isOverflow;
1373
- const { renderBounds } = this.__layout;
1374
- if (this.children.length) {
1375
- super.__updateRenderBounds();
1376
- copy(childrenRenderBounds, renderBounds);
1377
- this.__updateRectRenderBounds();
1378
- isOverflow = !includes$1(renderBounds, childrenRenderBounds) || undefined;
1379
- if (isOverflow && this.__.overflow !== 'hide')
1380
- add(renderBounds, childrenRenderBounds);
1381
- }
1382
- else
1383
- this.__updateRectRenderBounds();
1384
- this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
1385
- }
1386
- __updateRectRenderBounds() { }
1387
- __updateRectChange() { }
1388
- __updateChange() {
1389
- super.__updateChange();
1390
- this.__updateRectChange();
1391
- }
1392
- __renderRect(_canvas, _options) { }
1393
- __renderGroup(_canvas, _options) { }
1394
- __render(canvas, options) {
1395
- if (this.__.__drawAfterFill) {
1396
- this.__renderRect(canvas, options);
1397
- }
1398
- else {
1399
- this.__renderRect(canvas, options);
1400
- if (this.children.length)
1401
- this.__renderGroup(canvas, options);
1402
- }
1403
- }
1404
- __drawContent(canvas, options) {
1405
- this.__renderGroup(canvas, options);
1406
- if (this.__.__hasStroke) {
1407
- canvas.setWorld(this.__nowWorld);
1408
- this.__drawRenderPath(canvas);
1409
- }
1410
- }
1411
- };
1412
- __decorate([
1413
- dataProcessor(BoxData)
1414
- ], Box.prototype, "__", void 0);
1415
- __decorate([
1416
- boundsType(100)
1417
- ], Box.prototype, "width", void 0);
1418
- __decorate([
1419
- boundsType(100)
1420
- ], Box.prototype, "height", void 0);
1421
- __decorate([
1422
- dataType(false)
1423
- ], Box.prototype, "resizeChildren", void 0);
1424
- __decorate([
1425
- affectRenderBoundsType('show')
1426
- ], Box.prototype, "overflow", void 0);
1427
- __decorate([
1428
- rewrite(rect.__updateStrokeSpread)
1429
- ], Box.prototype, "__updateStrokeSpread", null);
1430
- __decorate([
1431
- rewrite(rect.__updateRenderSpread)
1432
- ], Box.prototype, "__updateRectRenderSpread", null);
1433
- __decorate([
1434
- rewrite(rect.__updateBoxBounds)
1435
- ], Box.prototype, "__updateRectBoxBounds", null);
1436
- __decorate([
1437
- rewrite(rect.__updateStrokeBounds)
1438
- ], Box.prototype, "__updateStrokeBounds", null);
1439
- __decorate([
1440
- rewrite(rect.__updateRenderBounds)
1441
- ], Box.prototype, "__updateRectRenderBounds", null);
1442
- __decorate([
1443
- rewrite(rect.__updateChange)
1444
- ], Box.prototype, "__updateRectChange", null);
1445
- __decorate([
1446
- rewrite(rect.__render)
1447
- ], Box.prototype, "__renderRect", null);
1448
- __decorate([
1449
- rewrite(group.__render)
1450
- ], Box.prototype, "__renderGroup", null);
1451
- Box = __decorate([
1452
- rewriteAble(),
1453
- registerUI()
1454
- ], Box);
1455
-
1456
- let Frame = class Frame extends Box {
1457
- get __tag() { return 'Frame'; }
1458
- get isFrame() { return true; }
1459
- constructor(data) {
1460
- super(data);
1461
- }
1462
- };
1463
- __decorate([
1464
- dataProcessor(FrameData)
1465
- ], Frame.prototype, "__", void 0);
1466
- __decorate([
1467
- surfaceType('#FFFFFF')
1468
- ], Frame.prototype, "fill", void 0);
1469
- __decorate([
1470
- affectRenderBoundsType('hide')
1471
- ], Frame.prototype, "overflow", void 0);
1472
- Frame = __decorate([
1473
- registerUI()
1474
- ], Frame);
1475
-
1476
- const { moveTo: moveTo$3, closePath: closePath$2, ellipse } = PathCommandDataHelper;
1477
- let Ellipse = class Ellipse extends UI {
1478
- get __tag() { return 'Ellipse'; }
1479
- constructor(data) {
1480
- super(data);
1481
- }
1482
- __updatePath() {
1483
- const { width, height, innerRadius, startAngle, endAngle } = this.__;
1484
- const rx = width / 2, ry = height / 2;
1485
- const path = this.__.path = [];
1486
- if (innerRadius) {
1487
- if (startAngle || endAngle) {
1488
- if (innerRadius < 1)
1489
- ellipse(path, rx, ry, rx * innerRadius, ry * innerRadius, 0, startAngle, endAngle, false);
1490
- ellipse(path, rx, ry, rx, ry, 0, endAngle, startAngle, true);
1491
- if (innerRadius < 1)
1492
- closePath$2(path);
1493
- }
1494
- else {
1495
- if (innerRadius < 1) {
1496
- ellipse(path, rx, ry, rx * innerRadius, ry * innerRadius);
1497
- moveTo$3(path, width, ry);
1498
- }
1499
- ellipse(path, rx, ry, rx, ry, 0, 360, 0, true);
1500
- }
1501
- if (Platform.ellipseToCurve)
1502
- this.__.path = this.getPath(true);
1503
- }
1504
- else {
1505
- if (startAngle || endAngle) {
1506
- moveTo$3(path, rx, ry);
1507
- ellipse(path, rx, ry, rx, ry, 0, startAngle, endAngle, false);
1508
- closePath$2(path);
1509
- }
1510
- else {
1511
- ellipse(path, rx, ry, rx, ry);
1512
- }
1513
- }
1514
- }
1515
- };
1516
- __decorate([
1517
- dataProcessor(EllipseData)
1518
- ], Ellipse.prototype, "__", void 0);
1519
- __decorate([
1520
- pathType(0)
1521
- ], Ellipse.prototype, "innerRadius", void 0);
1522
- __decorate([
1523
- pathType(0)
1524
- ], Ellipse.prototype, "startAngle", void 0);
1525
- __decorate([
1526
- pathType(0)
1527
- ], Ellipse.prototype, "endAngle", void 0);
1528
- Ellipse = __decorate([
1529
- registerUI()
1530
- ], Ellipse);
1531
-
1532
- const { moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1 } = PathCommandDataHelper;
1533
- const { rotate, getAngle, getDistance, defaultPoint } = PointHelper;
1534
- const { toBounds } = PathBounds;
1535
- let Line = class Line extends UI {
1536
- get __tag() { return 'Line'; }
1537
- get toPoint() {
1538
- const { width, rotation } = this.__;
1539
- const to = getPointData();
1540
- if (width)
1541
- to.x = width;
1542
- if (rotation)
1543
- rotate(to, rotation);
1544
- return to;
1545
- }
1546
- set toPoint(value) {
1547
- this.width = getDistance(defaultPoint, value);
1548
- this.rotation = getAngle(defaultPoint, value);
1549
- if (this.height)
1550
- this.height = 0;
1551
- }
1552
- constructor(data) {
1553
- super(data);
1554
- }
1555
- __updatePath() {
1556
- const data = this.__;
1557
- const path = data.path = [];
1558
- if (data.points) {
1559
- drawPoints$1(path, data.points, false, data.closed);
1560
- }
1561
- else {
1562
- moveTo$2(path, 0, 0);
1563
- lineTo$2(path, this.width, 0);
1564
- }
1565
- }
1566
- __updateRenderPath() {
1567
- const data = this.__;
1568
- if (!this.pathInputed && data.points && data.curve) {
1569
- drawPoints$1(data.__pathForRender = [], data.points, data.curve, data.closed);
1570
- if (data.__useArrow)
1571
- PathArrow.addArrows(this, false);
1572
- }
1573
- else
1574
- super.__updateRenderPath();
1575
- }
1576
- __updateBoxBounds() {
1577
- if (this.points) {
1578
- toBounds(this.__.__pathForRender, this.__layout.boxBounds);
1579
- }
1580
- else
1581
- super.__updateBoxBounds();
1582
- }
1583
- };
1584
- __decorate([
1585
- dataProcessor(LineData)
1586
- ], Line.prototype, "__", void 0);
1587
- __decorate([
1588
- affectStrokeBoundsType('center')
1589
- ], Line.prototype, "strokeAlign", void 0);
1590
- __decorate([
1591
- boundsType(0)
1592
- ], Line.prototype, "height", void 0);
1593
- __decorate([
1594
- pathType()
1595
- ], Line.prototype, "points", void 0);
1596
- __decorate([
1597
- pathType(0)
1598
- ], Line.prototype, "curve", void 0);
1599
- __decorate([
1600
- pathType(false)
1601
- ], Line.prototype, "closed", void 0);
1602
- Line = __decorate([
1603
- registerUI()
1604
- ], Line);
1605
-
1606
- const { sin: sin$1, cos: cos$1, PI: PI$1 } = Math;
1607
- const { moveTo: moveTo$1, lineTo: lineTo$1, closePath: closePath$1, drawPoints } = PathCommandDataHelper;
1608
- const line = Line.prototype;
1609
- let Polygon = class Polygon extends UI {
1610
- get __tag() { return 'Polygon'; }
1611
- constructor(data) {
1612
- super(data);
1613
- }
1614
- __updatePath() {
1615
- const path = this.__.path = [];
1616
- if (this.__.points) {
1617
- drawPoints(path, this.__.points, false, true);
1618
- }
1619
- else {
1620
- const { width, height, sides } = this.__;
1621
- const rx = width / 2, ry = height / 2;
1622
- moveTo$1(path, rx, 0);
1623
- for (let i = 1; i < sides; i++) {
1624
- lineTo$1(path, rx + rx * sin$1((i * 2 * PI$1) / sides), ry - ry * cos$1((i * 2 * PI$1) / sides));
1625
- }
1626
- }
1627
- closePath$1(path);
1628
- }
1629
- __updateRenderPath() { }
1630
- __updateBoxBounds() { }
1631
- };
1632
- __decorate([
1633
- dataProcessor(PolygonData)
1634
- ], Polygon.prototype, "__", void 0);
1635
- __decorate([
1636
- pathType(3)
1637
- ], Polygon.prototype, "sides", void 0);
1638
- __decorate([
1639
- pathType()
1640
- ], Polygon.prototype, "points", void 0);
1641
- __decorate([
1642
- pathType(0)
1643
- ], Polygon.prototype, "curve", void 0);
1644
- __decorate([
1645
- rewrite(line.__updateRenderPath)
1646
- ], Polygon.prototype, "__updateRenderPath", null);
1647
- __decorate([
1648
- rewrite(line.__updateBoxBounds)
1649
- ], Polygon.prototype, "__updateBoxBounds", null);
1650
- Polygon = __decorate([
1651
- rewriteAble(),
1652
- registerUI()
1653
- ], Polygon);
1654
-
1655
- const { sin, cos, PI } = Math;
1656
- const { moveTo, lineTo, closePath } = PathCommandDataHelper;
1657
- let Star = class Star extends UI {
1658
- get __tag() { return 'Star'; }
1659
- constructor(data) {
1660
- super(data);
1661
- }
1662
- __updatePath() {
1663
- const { width, height, corners, innerRadius } = this.__;
1664
- const rx = width / 2, ry = height / 2;
1665
- const path = this.__.path = [];
1666
- moveTo(path, rx, 0);
1667
- for (let i = 1; i < corners * 2; i++) {
1668
- lineTo(path, rx + (i % 2 === 0 ? rx : rx * innerRadius) * sin((i * PI) / corners), ry - (i % 2 === 0 ? ry : ry * innerRadius) * cos((i * PI) / corners));
1669
- }
1670
- closePath(path);
1671
- }
1672
- };
1673
- __decorate([
1674
- dataProcessor(StarData)
1675
- ], Star.prototype, "__", void 0);
1676
- __decorate([
1677
- pathType(5)
1678
- ], Star.prototype, "corners", void 0);
1679
- __decorate([
1680
- pathType(0.382)
1681
- ], Star.prototype, "innerRadius", void 0);
1682
- Star = __decorate([
1683
- registerUI()
1684
- ], Star);
1685
-
1686
- let Image = class Image extends Rect {
1687
- get __tag() { return 'Image'; }
1688
- get ready() { return this.image ? this.image.ready : false; }
1689
- constructor(data) {
1690
- super(data);
1691
- this.on_(ImageEvent.LOADED, this.__onLoaded, this);
1692
- }
1693
- __onLoaded(e) {
1694
- if (e.attrName === 'fill' && e.attrValue.url === this.url)
1695
- this.image = e.image;
1696
- }
1697
- destroy() {
1698
- this.image = null;
1699
- super.destroy();
1700
- }
1701
- };
1702
- __decorate([
1703
- dataProcessor(ImageData)
1704
- ], Image.prototype, "__", void 0);
1705
- __decorate([
1706
- boundsType('')
1707
- ], Image.prototype, "url", void 0);
1708
- Image = __decorate([
1709
- registerUI()
1710
- ], Image);
1711
- const MyImage = Image;
1712
-
1713
- let Canvas = class Canvas extends Rect {
1714
- get __tag() { return 'Canvas'; }
1715
- get ready() { return !this.url; }
1716
- constructor(data) {
1717
- super(data);
1718
- this.canvas = Creator.canvas(this.__);
1719
- this.context = this.canvas.context;
1720
- if (data && data.url)
1721
- this.drawImage(data.url);
1722
- }
1723
- drawImage(url) {
1724
- new LeaferImage({ url }).load((image) => {
1725
- this.context.drawImage(image.view, 0, 0);
1726
- this.url = undefined;
1727
- this.paint();
1728
- this.emitEvent(new ImageEvent(ImageEvent.LOADED, { image }));
1729
- });
1730
- }
1731
- draw(ui, offset, scale, rotation) {
1732
- const matrix = new Matrix(ui.worldTransform).invert();
1733
- const m = new Matrix();
1734
- if (offset)
1735
- m.translate(offset.x, offset.y);
1736
- if (scale)
1737
- typeof scale === 'number' ? m.scale(scale) : m.scale(scale.x, scale.y);
1738
- if (rotation)
1739
- m.rotate(rotation);
1740
- matrix.multiplyParent(m);
1741
- ui.__render(this.canvas, { matrix: matrix.withScale() });
1742
- this.paint();
1743
- }
1744
- paint() {
1745
- this.forceRender();
1746
- }
1747
- __drawContent(canvas, _options) {
1748
- const { width, height } = this.__, { view } = this.canvas;
1749
- canvas.drawImage(view, 0, 0, view.width, view.height, 0, 0, width, height);
1750
- }
1751
- __updateSize() {
1752
- const { canvas } = this;
1753
- if (canvas) {
1754
- const { smooth, safeResize } = this.__;
1755
- canvas.resize(this.__, safeResize);
1756
- if (canvas.smooth !== smooth)
1757
- canvas.smooth = smooth;
1758
- }
1759
- }
1760
- destroy() {
1761
- if (this.canvas) {
1762
- this.canvas.destroy();
1763
- this.canvas = this.context = null;
1764
- }
1765
- super.destroy();
1766
- }
1767
- };
1768
- __decorate([
1769
- dataProcessor(CanvasData)
1770
- ], Canvas.prototype, "__", void 0);
1771
- __decorate([
1772
- resizeType(100)
1773
- ], Canvas.prototype, "width", void 0);
1774
- __decorate([
1775
- resizeType(100)
1776
- ], Canvas.prototype, "height", void 0);
1777
- __decorate([
1778
- resizeType(1)
1779
- ], Canvas.prototype, "pixelRatio", void 0);
1780
- __decorate([
1781
- resizeType(true)
1782
- ], Canvas.prototype, "smooth", void 0);
1783
- __decorate([
1784
- dataType(false)
1785
- ], Canvas.prototype, "safeResize", void 0);
1786
- __decorate([
1787
- resizeType()
1788
- ], Canvas.prototype, "contextSettings", void 0);
1789
- Canvas = __decorate([
1790
- registerUI()
1791
- ], Canvas);
1792
-
1793
- const { copyAndSpread, includes, spread, setList } = BoundsHelper;
1794
- let Text = class Text extends UI {
1795
- get __tag() { return 'Text'; }
1796
- get textDrawData() { this.updateLayout(); return this.__.__textDrawData; }
1797
- constructor(data) {
1798
- super(data);
1799
- }
1800
- __updateTextDrawData() {
1801
- const data = this.__;
1802
- const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase, textOverflow, padding } = data;
1803
- data.__lineHeight = UnitConvert.number(lineHeight, fontSize);
1804
- data.__letterSpacing = UnitConvert.number(letterSpacing, fontSize);
1805
- data.__padding = padding ? MathHelper.fourNumber(padding) : undefined;
1806
- data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * 0.7) / 2;
1807
- data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize}px ${fontFamily}`;
1808
- data.__clipText = textOverflow !== 'show' && !data.__autoSize;
1809
- data.__textDrawData = TextConvert.getDrawData((data.__isPlacehold = data.placeholder && data.text === '') ? data.placeholder : data.text, this.__);
1810
- }
1811
- __updateBoxBounds() {
1812
- const data = this.__;
1813
- const layout = this.__layout;
1814
- const { fontSize, italic, padding, __autoWidth: autoWidth, __autoHeight: autoHeight } = data;
1815
- this.__updateTextDrawData();
1816
- const { bounds: contentBounds } = data.__textDrawData;
1817
- const b = layout.boxBounds;
1818
- layout.contentBounds = contentBounds;
1819
- if (data.__lineHeight < fontSize)
1820
- spread(contentBounds, fontSize / 2);
1821
- if (autoWidth || autoHeight) {
1822
- b.x = autoWidth ? contentBounds.x : 0;
1823
- b.y = autoHeight ? contentBounds.y : 0;
1824
- b.width = autoWidth ? contentBounds.width : data.width;
1825
- b.height = autoHeight ? contentBounds.height : data.height;
1826
- if (padding) {
1827
- const [top, right, bottom, left] = data.__padding;
1828
- if (autoWidth)
1829
- b.x -= left, b.width += (right + left);
1830
- if (autoHeight)
1831
- b.y -= top, b.height += (bottom + top);
1832
- }
1833
- this.__updateNaturalSize();
1834
- }
1835
- else
1836
- super.__updateBoxBounds();
1837
- if (italic)
1838
- b.width += fontSize * 0.16;
1839
- const isOverflow = !includes(b, contentBounds) || undefined;
1840
- if (isOverflow)
1841
- setList(data.__textBoxBounds = {}, [b, contentBounds]), layout.renderChanged = true;
1842
- else
1843
- data.__textBoxBounds = b;
1844
- this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
1845
- }
1846
- __onUpdateSize() {
1847
- if (this.__box)
1848
- this.__box.__onUpdateSize();
1849
- super.__onUpdateSize();
1850
- }
1851
- __updateRenderSpread() {
1852
- let width = super.__updateRenderSpread();
1853
- if (!width)
1854
- width = this.isOverflow ? 1 : 0;
1855
- return width;
1856
- }
1857
- __updateRenderBounds() {
1858
- const { renderBounds, renderSpread } = this.__layout;
1859
- copyAndSpread(renderBounds, this.__.__textBoxBounds, renderSpread);
1860
- if (this.__box)
1861
- this.__box.__layout.renderBounds = renderBounds;
1862
- }
1863
- __drawRenderPath(canvas) {
1864
- canvas.font = this.__.__font;
1865
- }
1866
- __draw(canvas, options, originCanvas) {
1867
- const box = this.__box;
1868
- if (box)
1869
- box.__nowWorld = this.__nowWorld, box.__draw(canvas, options, originCanvas);
1870
- if (this.textEditing && !Export.running)
1871
- return;
1872
- super.__draw(canvas, options, originCanvas);
1873
- }
1874
- destroy() {
1875
- if (this.boxStyle)
1876
- this.boxStyle = null;
1877
- super.destroy();
1878
- }
1879
- };
1880
- __decorate([
1881
- dataProcessor(TextData)
1882
- ], Text.prototype, "__", void 0);
1883
- __decorate([
1884
- boundsType(0)
1885
- ], Text.prototype, "width", void 0);
1886
- __decorate([
1887
- boundsType(0)
1888
- ], Text.prototype, "height", void 0);
1889
- __decorate([
1890
- surfaceType()
1891
- ], Text.prototype, "boxStyle", void 0);
1892
- __decorate([
1893
- dataType(false)
1894
- ], Text.prototype, "resizeFontSize", void 0);
1895
- __decorate([
1896
- surfaceType('#000000')
1897
- ], Text.prototype, "fill", void 0);
1898
- __decorate([
1899
- affectStrokeBoundsType('outside')
1900
- ], Text.prototype, "strokeAlign", void 0);
1901
- __decorate([
1902
- hitType('all')
1903
- ], Text.prototype, "hitFill", void 0);
1904
- __decorate([
1905
- boundsType('')
1906
- ], Text.prototype, "text", void 0);
1907
- __decorate([
1908
- boundsType('')
1909
- ], Text.prototype, "placeholder", void 0);
1910
- __decorate([
1911
- boundsType('caption')
1912
- ], Text.prototype, "fontFamily", void 0);
1913
- __decorate([
1914
- boundsType(12)
1915
- ], Text.prototype, "fontSize", void 0);
1916
- __decorate([
1917
- boundsType('normal')
1918
- ], Text.prototype, "fontWeight", void 0);
1919
- __decorate([
1920
- boundsType(false)
1921
- ], Text.prototype, "italic", void 0);
1922
- __decorate([
1923
- boundsType('none')
1924
- ], Text.prototype, "textCase", void 0);
1925
- __decorate([
1926
- boundsType('none')
1927
- ], Text.prototype, "textDecoration", void 0);
1928
- __decorate([
1929
- boundsType(0)
1930
- ], Text.prototype, "letterSpacing", void 0);
1931
- __decorate([
1932
- boundsType({ type: 'percent', value: 1.5 })
1933
- ], Text.prototype, "lineHeight", void 0);
1934
- __decorate([
1935
- boundsType(0)
1936
- ], Text.prototype, "paraIndent", void 0);
1937
- __decorate([
1938
- boundsType(0)
1939
- ], Text.prototype, "paraSpacing", void 0);
1940
- __decorate([
1941
- boundsType('x')
1942
- ], Text.prototype, "writingMode", void 0);
1943
- __decorate([
1944
- boundsType('left')
1945
- ], Text.prototype, "textAlign", void 0);
1946
- __decorate([
1947
- boundsType('top')
1948
- ], Text.prototype, "verticalAlign", void 0);
1949
- __decorate([
1950
- boundsType(true)
1951
- ], Text.prototype, "autoSizeAlign", void 0);
1952
- __decorate([
1953
- boundsType('normal')
1954
- ], Text.prototype, "textWrap", void 0);
1955
- __decorate([
1956
- boundsType('show')
1957
- ], Text.prototype, "textOverflow", void 0);
1958
- Text = __decorate([
1959
- registerUI()
1960
- ], Text);
1961
-
1962
- let Path = class Path extends UI {
1963
- get __tag() { return 'Path'; }
1964
- constructor(data) {
1965
- super(data);
1966
- }
1967
- };
1968
- __decorate([
1969
- dataProcessor(PathData)
1970
- ], Path.prototype, "__", void 0);
1971
- __decorate([
1972
- affectStrokeBoundsType('center')
1973
- ], Path.prototype, "strokeAlign", void 0);
1974
- Path = __decorate([
1975
- registerUI()
1976
- ], Path);
1977
-
1978
- let Pen = class Pen extends Group {
1979
- get __tag() { return 'Pen'; }
1980
- constructor(data) {
1981
- super(data);
1982
- }
1983
- setStyle(data) {
1984
- const path = this.pathElement = new Path(data);
1985
- this.pathStyle = data;
1986
- this.__path = path.path || (path.path = []);
1987
- this.add(path);
1988
- return this;
1989
- }
1990
- beginPath() { return this; }
1991
- moveTo(_x, _y) { return this; }
1992
- lineTo(_x, _y) { return this; }
1993
- bezierCurveTo(_x1, _y1, _x2, _y2, _x, _y) { return this; }
1994
- quadraticCurveTo(_x1, _y1, _x, _y) { return this; }
1995
- closePath() { return this; }
1996
- rect(_x, _y, _width, _height) { return this; }
1997
- roundRect(_x, _y, _width, _height, _cornerRadius) { return this; }
1998
- ellipse(_x, _y, _radiusX, _radiusY, _rotation, _startAngle, _endAngle, _anticlockwise) { return this; }
1999
- arc(_x, _y, _radius, _startAngle, _endAngle, _anticlockwise) { return this; }
2000
- arcTo(_x1, _y1, _x2, _y2, _radius) { return this; }
2001
- drawEllipse(_x, _y, _radiusX, _radiusY, _rotation, _startAngle, _endAngle, _anticlockwise) { return this; }
2002
- drawArc(_x, _y, _radius, _startAngle, _endAngle, _anticlockwise) { return this; }
2003
- drawPoints(_points, _curve, _close) { return this; }
2004
- clearPath() { return this; }
2005
- paint() {
2006
- if (!this.pathElement.__layout.boxChanged)
2007
- this.pathElement.forceUpdate('path');
2008
- }
2009
- };
2010
- __decorate([
2011
- dataProcessor(PenData)
2012
- ], Pen.prototype, "__", void 0);
2013
- __decorate([
2014
- penPathType()
2015
- ], Pen.prototype, "path", void 0);
2016
- Pen = __decorate([
2017
- useModule(PathCreator, ['set', 'path', 'paint']),
2018
- registerUI()
2019
- ], Pen);
2020
- function penPathType() {
2021
- return (target, key) => {
2022
- defineKey(target, key, {
2023
- get() { return this.__path; }
2024
- });
2025
- };
2026
- }
2027
-
2028
- export { Box, BoxData, Canvas, CanvasData, ColorConvert, Effect, Ellipse, EllipseData, Export, Filter, Frame, FrameData, Group, GroupData, Image, ImageData, Leafer, LeaferData, Line, LineData, MyImage, Paint, PaintGradient, PaintImage, Path, PathArrow, PathData, Pen, PenData, Polygon, PolygonData, Rect, RectData, RectRender, Star, StarData, State, Text, TextConvert, TextData, Transition, UI, UIBounds, UIData, UIRender, UnitConvert, effectType, resizeType, zoomLayerType };