@leafer-ui/core 1.0.0-rc.8 → 1.0.0

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