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