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