leafer-ui 1.0.9 → 1.1.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/README.md +54 -38
- package/dist/web.cjs +25 -13
- package/dist/web.esm.js +25 -13
- package/dist/web.esm.min.js +1 -1
- package/dist/web.js +114 -86
- package/dist/web.min.cjs +1 -1
- package/dist/web.min.js +1 -1
- package/dist/web.module.js +114 -86
- package/dist/web.module.min.js +1 -1
- package/package.json +11 -11
package/dist/web.module.js
CHANGED
|
@@ -108,7 +108,7 @@ const MathHelper = {
|
|
|
108
108
|
return rotation - oldRotation;
|
|
109
109
|
},
|
|
110
110
|
float(num, maxLength) {
|
|
111
|
-
const a = maxLength ? pow$1(10, maxLength) : 1000000000000;
|
|
111
|
+
const a = maxLength !== undefined ? pow$1(10, maxLength) : 1000000000000;
|
|
112
112
|
num = round(num * a) / a;
|
|
113
113
|
return num === -0 ? 0 : num;
|
|
114
114
|
},
|
|
@@ -1411,14 +1411,13 @@ const UICreator = {
|
|
|
1411
1411
|
list: {},
|
|
1412
1412
|
register(UI) {
|
|
1413
1413
|
const { __tag: tag } = UI.prototype;
|
|
1414
|
-
if (list$2[tag])
|
|
1414
|
+
if (list$2[tag])
|
|
1415
1415
|
debug$f.repeat(tag);
|
|
1416
|
-
|
|
1417
|
-
else {
|
|
1418
|
-
list$2[tag] = UI;
|
|
1419
|
-
}
|
|
1416
|
+
list$2[tag] = UI;
|
|
1420
1417
|
},
|
|
1421
1418
|
get(tag, data, x, y, width, height) {
|
|
1419
|
+
if (!list$2[tag])
|
|
1420
|
+
debug$f.error('not register ' + tag);
|
|
1422
1421
|
const ui = new list$2[tag](data);
|
|
1423
1422
|
if (x !== undefined) {
|
|
1424
1423
|
ui.x = x;
|
|
@@ -1442,7 +1441,7 @@ const EventCreator = {
|
|
|
1442
1441
|
Object.keys(Event).forEach(key => {
|
|
1443
1442
|
name = Event[key];
|
|
1444
1443
|
if (typeof name === 'string')
|
|
1445
|
-
nameList[name]
|
|
1444
|
+
nameList[name] && debug$e.repeat(name), nameList[name] = Event;
|
|
1446
1445
|
});
|
|
1447
1446
|
},
|
|
1448
1447
|
changeName(oldName, newName) {
|
|
@@ -1644,7 +1643,7 @@ class LeafData {
|
|
|
1644
1643
|
const t = this;
|
|
1645
1644
|
if (t.blendMode === 'pass-through') {
|
|
1646
1645
|
const leaf = this.__leaf;
|
|
1647
|
-
if ((t.opacity < 1 && leaf.isBranch) || leaf.__hasEraser || t.eraser) {
|
|
1646
|
+
if ((t.opacity < 1 && (leaf.isBranch || t.__hasMultiPaint)) || leaf.__hasEraser || t.eraser) {
|
|
1648
1647
|
t.__single = true;
|
|
1649
1648
|
}
|
|
1650
1649
|
else if (t.__single) {
|
|
@@ -2042,8 +2041,9 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2042
2041
|
takeCanvas = this.getSameCanvas();
|
|
2043
2042
|
takeCanvas.copyWorld(this);
|
|
2044
2043
|
}
|
|
2045
|
-
|
|
2046
|
-
|
|
2044
|
+
const s = this.size;
|
|
2045
|
+
DataHelper.copyAttrs(s, size, canvasSizeAttrs);
|
|
2046
|
+
canvasSizeAttrs.forEach(key => s[key] || (s[key] = 1));
|
|
2047
2047
|
this.bounds = new Bounds(0, 0, this.width, this.height);
|
|
2048
2048
|
if (this.context && !this.unreal) {
|
|
2049
2049
|
this.updateViewSize();
|
|
@@ -2157,6 +2157,17 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2157
2157
|
if (!onlyResetTransform)
|
|
2158
2158
|
this.useWorldTransform();
|
|
2159
2159
|
}
|
|
2160
|
+
useGrayscaleAlpha(bounds) {
|
|
2161
|
+
this.setTempBounds(bounds, true, true);
|
|
2162
|
+
let alpha, pixel;
|
|
2163
|
+
const { context } = this, imageData = context.getImageData(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height), { data } = imageData;
|
|
2164
|
+
for (let i = 0, len = data.length; i < len; i += 4) {
|
|
2165
|
+
pixel = data[i] * 0.299 + data[i + 1] * 0.587 + data[i + 2] * 0.114;
|
|
2166
|
+
if (alpha = data[i + 3])
|
|
2167
|
+
data[i + 3] = alpha === 255 ? pixel : alpha * (pixel / 255);
|
|
2168
|
+
}
|
|
2169
|
+
context.putImageData(imageData, tempBounds$1.x, tempBounds$1.y);
|
|
2170
|
+
}
|
|
2160
2171
|
useMask(maskCanvas, fromBounds, toBounds) {
|
|
2161
2172
|
this.copyWorld(maskCanvas, fromBounds, toBounds, 'destination-in');
|
|
2162
2173
|
}
|
|
@@ -2167,7 +2178,7 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2167
2178
|
if (blendMode)
|
|
2168
2179
|
this.blendMode = blendMode;
|
|
2169
2180
|
this.fillStyle = color;
|
|
2170
|
-
|
|
2181
|
+
this.setTempBounds(bounds);
|
|
2171
2182
|
this.fillRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
|
|
2172
2183
|
if (blendMode)
|
|
2173
2184
|
this.blendMode = 'source-over';
|
|
@@ -2176,22 +2187,18 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2176
2187
|
if (blendMode)
|
|
2177
2188
|
this.blendMode = blendMode;
|
|
2178
2189
|
this.strokeStyle = color;
|
|
2179
|
-
|
|
2190
|
+
this.setTempBounds(bounds);
|
|
2180
2191
|
this.strokeRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
|
|
2181
2192
|
if (blendMode)
|
|
2182
2193
|
this.blendMode = 'source-over';
|
|
2183
2194
|
}
|
|
2184
2195
|
clearWorld(bounds, ceilPixel) {
|
|
2185
|
-
|
|
2186
|
-
if (ceilPixel)
|
|
2187
|
-
tempBounds$1.ceil();
|
|
2196
|
+
this.setTempBounds(bounds, ceilPixel);
|
|
2188
2197
|
this.clearRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
|
|
2189
2198
|
}
|
|
2190
2199
|
clipWorld(bounds, ceilPixel) {
|
|
2191
2200
|
this.beginPath();
|
|
2192
|
-
|
|
2193
|
-
if (ceilPixel)
|
|
2194
|
-
tempBounds$1.ceil();
|
|
2201
|
+
this.setTempBounds(bounds, ceilPixel);
|
|
2195
2202
|
this.rect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
|
|
2196
2203
|
this.clip();
|
|
2197
2204
|
}
|
|
@@ -2199,6 +2206,14 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2199
2206
|
const { pixelRatio } = this;
|
|
2200
2207
|
this.clearRect(0, 0, this.width * pixelRatio + 2, this.height * pixelRatio + 2);
|
|
2201
2208
|
}
|
|
2209
|
+
setTempBounds(bounds, ceil, intersect) {
|
|
2210
|
+
tempBounds$1.set(bounds);
|
|
2211
|
+
if (intersect)
|
|
2212
|
+
tempBounds$1.intersect(this.bounds);
|
|
2213
|
+
tempBounds$1.scale(this.pixelRatio);
|
|
2214
|
+
if (ceil)
|
|
2215
|
+
tempBounds$1.ceil();
|
|
2216
|
+
}
|
|
2202
2217
|
isSameSize(size) {
|
|
2203
2218
|
return this.width === size.width && this.height === size.height && this.pixelRatio === size.pixelRatio;
|
|
2204
2219
|
}
|
|
@@ -4150,20 +4165,17 @@ const LeafHelper = {
|
|
|
4150
4165
|
}
|
|
4151
4166
|
return true;
|
|
4152
4167
|
},
|
|
4153
|
-
moveWorld(t, x, y = 0, isInnerPoint) {
|
|
4168
|
+
moveWorld(t, x, y = 0, isInnerPoint, transition) {
|
|
4154
4169
|
const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
|
|
4155
4170
|
isInnerPoint ? toOuterPoint$1(t.localTransform, local, local, true) : (t.parent && toInnerPoint$1(t.parent.worldTransform, local, local, true));
|
|
4156
|
-
L.moveLocal(t, local.x, local.y);
|
|
4171
|
+
L.moveLocal(t, local.x, local.y, transition);
|
|
4157
4172
|
},
|
|
4158
|
-
moveLocal(t, x, y = 0) {
|
|
4159
|
-
if (typeof x === 'object')
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
t.x += x;
|
|
4165
|
-
t.y += y;
|
|
4166
|
-
}
|
|
4173
|
+
moveLocal(t, x, y = 0, transition) {
|
|
4174
|
+
if (typeof x === 'object')
|
|
4175
|
+
y = x.y, x = x.x;
|
|
4176
|
+
x += t.x;
|
|
4177
|
+
y += t.y;
|
|
4178
|
+
transition ? t.animate({ x, y }, transition) : (t.x = x, t.y = y);
|
|
4167
4179
|
},
|
|
4168
4180
|
zoomOfWorld(t, origin, scaleX, scaleY, resize) {
|
|
4169
4181
|
L.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize);
|
|
@@ -5212,13 +5224,14 @@ const BranchRender = {
|
|
|
5212
5224
|
this.__.__checkSingle();
|
|
5213
5225
|
},
|
|
5214
5226
|
__render(canvas, options) {
|
|
5227
|
+
this.__nowWorld = this.__getNowWorld(options);
|
|
5215
5228
|
if (this.__worldOpacity) {
|
|
5216
5229
|
if (this.__.__single) {
|
|
5217
5230
|
if (this.__.eraser === 'path')
|
|
5218
5231
|
return this.__renderEraser(canvas, options);
|
|
5219
5232
|
const tempCanvas = canvas.getSameCanvas(false, true);
|
|
5220
5233
|
this.__renderBranch(tempCanvas, options);
|
|
5221
|
-
const nowWorld = this.
|
|
5234
|
+
const nowWorld = this.__nowWorld;
|
|
5222
5235
|
canvas.opacity = this.__.opacity;
|
|
5223
5236
|
canvas.copyWorldByReset(tempCanvas, nowWorld, nowWorld, this.__.__blendMode, true);
|
|
5224
5237
|
tempCanvas.recycle(nowWorld);
|
|
@@ -5542,11 +5555,11 @@ let Leaf = class Leaf {
|
|
|
5542
5555
|
transform(matrix, resize) {
|
|
5543
5556
|
transform(this, matrix, resize);
|
|
5544
5557
|
}
|
|
5545
|
-
move(x, y) {
|
|
5546
|
-
moveLocal(this, x, y);
|
|
5558
|
+
move(x, y, transition) {
|
|
5559
|
+
moveLocal(this, x, y, transition);
|
|
5547
5560
|
}
|
|
5548
|
-
moveInner(x, y) {
|
|
5549
|
-
moveWorld(this, x, y, true);
|
|
5561
|
+
moveInner(x, y, transition) {
|
|
5562
|
+
moveWorld(this, x, y, true, transition);
|
|
5550
5563
|
}
|
|
5551
5564
|
scaleOf(origin, scaleX, scaleY, resize) {
|
|
5552
5565
|
zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize);
|
|
@@ -5560,8 +5573,8 @@ let Leaf = class Leaf {
|
|
|
5560
5573
|
transformWorld(worldTransform, resize) {
|
|
5561
5574
|
transformWorld(this, worldTransform, resize);
|
|
5562
5575
|
}
|
|
5563
|
-
moveWorld(x, y) {
|
|
5564
|
-
moveWorld(this, x, y);
|
|
5576
|
+
moveWorld(x, y, transition) {
|
|
5577
|
+
moveWorld(this, x, y, false, transition);
|
|
5565
5578
|
}
|
|
5566
5579
|
scaleOfWorld(worldOrigin, scaleX, scaleY, resize) {
|
|
5567
5580
|
zoomOfWorld(this, worldOrigin, scaleX, scaleY, resize);
|
|
@@ -5959,7 +5972,7 @@ class LeafLevelList {
|
|
|
5959
5972
|
}
|
|
5960
5973
|
}
|
|
5961
5974
|
|
|
5962
|
-
const version = "1.0
|
|
5975
|
+
const version = "1.1.0";
|
|
5963
5976
|
|
|
5964
5977
|
const debug$7 = Debug.get('LeaferCanvas');
|
|
5965
5978
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
@@ -6601,7 +6614,8 @@ class Renderer {
|
|
|
6601
6614
|
this.totalBounds = new Bounds();
|
|
6602
6615
|
debug$5.log(target.innerName, '--->');
|
|
6603
6616
|
try {
|
|
6604
|
-
target.
|
|
6617
|
+
if (!target.isApp)
|
|
6618
|
+
target.app.emit(RenderEvent.CHILD_START, target);
|
|
6605
6619
|
this.emitRender(RenderEvent.START);
|
|
6606
6620
|
this.renderOnce(callback);
|
|
6607
6621
|
this.emitRender(RenderEvent.END, this.totalBounds);
|
|
@@ -7155,6 +7169,12 @@ class UIData extends LeafData {
|
|
|
7155
7169
|
return strokeWidth;
|
|
7156
7170
|
}
|
|
7157
7171
|
get __hasStroke() { return this.stroke && this.strokeWidth; }
|
|
7172
|
+
get __hasMultiPaint() {
|
|
7173
|
+
const t = this;
|
|
7174
|
+
if ((t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect)
|
|
7175
|
+
return true;
|
|
7176
|
+
return t.fill && this.__hasStroke;
|
|
7177
|
+
}
|
|
7158
7178
|
get __clipAfterFill() { return (this.cornerRadius || this.__pathInputed); }
|
|
7159
7179
|
get __autoWidth() { return !this._width; }
|
|
7160
7180
|
get __autoHeight() { return !this._height; }
|
|
@@ -7524,9 +7544,8 @@ const RectRender = {
|
|
|
7524
7544
|
canvas.strokeRect(half, half, width, height);
|
|
7525
7545
|
canvas.restore();
|
|
7526
7546
|
}
|
|
7527
|
-
else
|
|
7547
|
+
else
|
|
7528
7548
|
canvas.strokeRect(half, half, width, height);
|
|
7529
|
-
}
|
|
7530
7549
|
break;
|
|
7531
7550
|
case 'outside':
|
|
7532
7551
|
canvas.strokeRect(-half, -half, width + __strokeWidth, height + __strokeWidth);
|
|
@@ -7556,11 +7575,15 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7556
7575
|
super(data);
|
|
7557
7576
|
}
|
|
7558
7577
|
reset(_data) { }
|
|
7559
|
-
set(data,
|
|
7560
|
-
if (
|
|
7561
|
-
|
|
7562
|
-
|
|
7563
|
-
|
|
7578
|
+
set(data, transition) {
|
|
7579
|
+
if (transition) {
|
|
7580
|
+
if (transition === 'temp') {
|
|
7581
|
+
this.lockNormalStyle = true;
|
|
7582
|
+
Object.assign(this, data);
|
|
7583
|
+
this.lockNormalStyle = false;
|
|
7584
|
+
}
|
|
7585
|
+
else
|
|
7586
|
+
this.animate(data, transition);
|
|
7564
7587
|
}
|
|
7565
7588
|
else
|
|
7566
7589
|
Object.assign(this, data);
|
|
@@ -7751,6 +7774,15 @@ __decorate([
|
|
|
7751
7774
|
__decorate([
|
|
7752
7775
|
boundsType(0)
|
|
7753
7776
|
], UI.prototype, "padding", void 0);
|
|
7777
|
+
__decorate([
|
|
7778
|
+
boundsType(false)
|
|
7779
|
+
], UI.prototype, "lockRatio", void 0);
|
|
7780
|
+
__decorate([
|
|
7781
|
+
boundsType()
|
|
7782
|
+
], UI.prototype, "widthRange", void 0);
|
|
7783
|
+
__decorate([
|
|
7784
|
+
boundsType()
|
|
7785
|
+
], UI.prototype, "heightRange", void 0);
|
|
7754
7786
|
__decorate([
|
|
7755
7787
|
dataType(false)
|
|
7756
7788
|
], UI.prototype, "draggable", void 0);
|
|
@@ -7861,17 +7893,17 @@ let Group = class Group extends UI {
|
|
|
7861
7893
|
if (!this.children)
|
|
7862
7894
|
this.children = [];
|
|
7863
7895
|
}
|
|
7864
|
-
set(data,
|
|
7896
|
+
set(data, transition) {
|
|
7865
7897
|
if (data.children) {
|
|
7866
7898
|
const { children } = data;
|
|
7867
7899
|
delete data.children;
|
|
7868
7900
|
this.children ? this.clear() : this.__setBranch();
|
|
7869
|
-
super.set(data,
|
|
7901
|
+
super.set(data, transition);
|
|
7870
7902
|
children.forEach(child => this.add(child));
|
|
7871
7903
|
data.children = children;
|
|
7872
7904
|
}
|
|
7873
7905
|
else
|
|
7874
|
-
super.set(data,
|
|
7906
|
+
super.set(data, transition);
|
|
7875
7907
|
}
|
|
7876
7908
|
toJSON(options) {
|
|
7877
7909
|
const data = super.toJSON(options);
|
|
@@ -7984,8 +8016,8 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7984
8016
|
}
|
|
7985
8017
|
onInit() { }
|
|
7986
8018
|
initType(_type) { }
|
|
7987
|
-
set(data) {
|
|
7988
|
-
this.waitInit(() => { super.set(data); });
|
|
8019
|
+
set(data, transition) {
|
|
8020
|
+
this.waitInit(() => { super.set(data, transition); });
|
|
7989
8021
|
}
|
|
7990
8022
|
start() {
|
|
7991
8023
|
clearTimeout(this.__startTimer);
|
|
@@ -8042,8 +8074,6 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8042
8074
|
__onResize(event) {
|
|
8043
8075
|
this.emitEvent(event);
|
|
8044
8076
|
DataHelper.copyAttrs(this.__, event, canvasSizeAttrs);
|
|
8045
|
-
if (!event.width || !event.height)
|
|
8046
|
-
debug$3.warn('w = 0 or h = 0');
|
|
8047
8077
|
setTimeout(() => { if (this.canvasManager)
|
|
8048
8078
|
this.canvasManager.clearRecycled(); }, 0);
|
|
8049
8079
|
}
|
|
@@ -8368,9 +8398,6 @@ __decorate([
|
|
|
8368
8398
|
__decorate([
|
|
8369
8399
|
dataType(false)
|
|
8370
8400
|
], Box.prototype, "resizeChildren", void 0);
|
|
8371
|
-
__decorate([
|
|
8372
|
-
dataType(false)
|
|
8373
|
-
], Box.prototype, "textBox", void 0);
|
|
8374
8401
|
__decorate([
|
|
8375
8402
|
affectRenderBoundsType('show')
|
|
8376
8403
|
], Box.prototype, "overflow", void 0);
|
|
@@ -9125,19 +9152,13 @@ class UIEvent extends Event {
|
|
|
9125
9152
|
Object.assign(this, params);
|
|
9126
9153
|
}
|
|
9127
9154
|
getBoxPoint(relative) {
|
|
9128
|
-
|
|
9129
|
-
relative = this.current;
|
|
9130
|
-
return relative.getBoxPoint(this);
|
|
9155
|
+
return (relative || this.current).getBoxPoint(this);
|
|
9131
9156
|
}
|
|
9132
9157
|
getInnerPoint(relative) {
|
|
9133
|
-
|
|
9134
|
-
relative = this.current;
|
|
9135
|
-
return relative.getInnerPoint(this);
|
|
9158
|
+
return (relative || this.current).getInnerPoint(this);
|
|
9136
9159
|
}
|
|
9137
9160
|
getLocalPoint(relative) {
|
|
9138
|
-
|
|
9139
|
-
relative = this.current;
|
|
9140
|
-
return relative.getLocalPoint(this);
|
|
9161
|
+
return (relative || this.current).getLocalPoint(this);
|
|
9141
9162
|
}
|
|
9142
9163
|
getPagePoint() {
|
|
9143
9164
|
return this.current.getPagePoint(this);
|
|
@@ -9185,10 +9206,8 @@ let DragEvent = class DragEvent extends PointerEvent {
|
|
|
9185
9206
|
this.data = data;
|
|
9186
9207
|
}
|
|
9187
9208
|
static getValidMove(leaf, start, total) {
|
|
9188
|
-
const { draggable, dragBounds
|
|
9189
|
-
|
|
9190
|
-
move.x += start.x - x;
|
|
9191
|
-
move.y += start.y - y;
|
|
9209
|
+
const { draggable, dragBounds } = leaf, move = leaf.getLocalPoint(total, null, true);
|
|
9210
|
+
PointHelper.move(move, start.x - leaf.x, start.y - leaf.y);
|
|
9192
9211
|
if (dragBounds)
|
|
9193
9212
|
this.getMoveInDragBounds(leaf.__local, dragBounds === 'parent' ? leaf.parent.boxBounds : dragBounds, move, true);
|
|
9194
9213
|
if (draggable === 'x')
|
|
@@ -9198,8 +9217,7 @@ let DragEvent = class DragEvent extends PointerEvent {
|
|
|
9198
9217
|
return move;
|
|
9199
9218
|
}
|
|
9200
9219
|
static getMoveInDragBounds(childBox, dragBounds, move, change) {
|
|
9201
|
-
const x = childBox.x + move.x, y = childBox.y + move.y;
|
|
9202
|
-
const right = x + childBox.width, bottom = y + childBox.height;
|
|
9220
|
+
const x = childBox.x + move.x, y = childBox.y + move.y, right = x + childBox.width, bottom = y + childBox.height;
|
|
9203
9221
|
const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
|
|
9204
9222
|
if (!change)
|
|
9205
9223
|
move = Object.assign({}, move);
|
|
@@ -9251,9 +9269,7 @@ let DragEvent = class DragEvent extends PointerEvent {
|
|
|
9251
9269
|
return this.getLocalMove(relative, true);
|
|
9252
9270
|
}
|
|
9253
9271
|
getPageBounds() {
|
|
9254
|
-
const total = this.getPageTotal();
|
|
9255
|
-
const start = this.getPagePoint();
|
|
9256
|
-
const bounds = {};
|
|
9272
|
+
const total = this.getPageTotal(), start = this.getPagePoint(), bounds = {};
|
|
9257
9273
|
BoundsHelper.set(bounds, start.x - total.x, start.y - total.y, total.x, total.y);
|
|
9258
9274
|
BoundsHelper.unsign(bounds);
|
|
9259
9275
|
return bounds;
|
|
@@ -9371,7 +9387,8 @@ const debug$2 = Debug.get('LeaferTypeCreator');
|
|
|
9371
9387
|
const LeaferTypeCreator = {
|
|
9372
9388
|
list: {},
|
|
9373
9389
|
register(name, fn) {
|
|
9374
|
-
list[name]
|
|
9390
|
+
list[name] && debug$2.repeat(name);
|
|
9391
|
+
list[name] = fn;
|
|
9375
9392
|
},
|
|
9376
9393
|
run(name, leafer) {
|
|
9377
9394
|
const fn = list[name];
|
|
@@ -10992,6 +11009,8 @@ function stroke(stroke, ui, canvas) {
|
|
|
10992
11009
|
case 'center':
|
|
10993
11010
|
canvas.setStroke(stroke, __strokeWidth, options);
|
|
10994
11011
|
canvas.stroke();
|
|
11012
|
+
if (options.__useArrow)
|
|
11013
|
+
strokeArrow(ui, canvas);
|
|
10995
11014
|
break;
|
|
10996
11015
|
case 'inside':
|
|
10997
11016
|
canvas.save();
|
|
@@ -11029,6 +11048,8 @@ function strokes(strokes, ui, canvas) {
|
|
|
11029
11048
|
case 'center':
|
|
11030
11049
|
canvas.setStroke(undefined, __strokeWidth, options);
|
|
11031
11050
|
drawStrokesStyle(strokes, false, ui, canvas);
|
|
11051
|
+
if (options.__useArrow)
|
|
11052
|
+
strokeArrow(ui, canvas);
|
|
11032
11053
|
break;
|
|
11033
11054
|
case 'inside':
|
|
11034
11055
|
canvas.save();
|
|
@@ -11054,6 +11075,14 @@ function strokes(strokes, ui, canvas) {
|
|
|
11054
11075
|
}
|
|
11055
11076
|
}
|
|
11056
11077
|
}
|
|
11078
|
+
function strokeArrow(ui, canvas) {
|
|
11079
|
+
if (ui.__.dashPattern) {
|
|
11080
|
+
canvas.beginPath();
|
|
11081
|
+
ui.__drawPathByData(canvas, ui.__.__pathForArrow);
|
|
11082
|
+
canvas.dashPattern = null;
|
|
11083
|
+
canvas.stroke();
|
|
11084
|
+
}
|
|
11085
|
+
}
|
|
11057
11086
|
|
|
11058
11087
|
const { getSpread, getOuterOf, getByMove, getIntersectData } = BoundsHelper;
|
|
11059
11088
|
function shape(ui, current, options) {
|
|
@@ -11739,16 +11768,16 @@ const EffectModule = {
|
|
|
11739
11768
|
|
|
11740
11769
|
const { excludeRenderBounds } = LeafBoundsHelper;
|
|
11741
11770
|
Group.prototype.__renderMask = function (canvas, options) {
|
|
11742
|
-
let child, maskCanvas, contentCanvas, maskOpacity, currentMask;
|
|
11771
|
+
let child, maskCanvas, contentCanvas, maskOpacity, currentMask, mask;
|
|
11743
11772
|
const { children } = this;
|
|
11744
11773
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
11745
|
-
child = children[i];
|
|
11746
|
-
if (
|
|
11774
|
+
child = children[i], mask = child.__.mask;
|
|
11775
|
+
if (mask) {
|
|
11747
11776
|
if (currentMask) {
|
|
11748
11777
|
maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity);
|
|
11749
11778
|
maskCanvas = contentCanvas = null;
|
|
11750
11779
|
}
|
|
11751
|
-
if (
|
|
11780
|
+
if (mask === 'path' || mask === 'clipping-path') {
|
|
11752
11781
|
if (child.opacity < 1) {
|
|
11753
11782
|
currentMask = 'opacity-path';
|
|
11754
11783
|
maskOpacity = child.opacity;
|
|
@@ -11762,14 +11791,14 @@ Group.prototype.__renderMask = function (canvas, options) {
|
|
|
11762
11791
|
child.__clip(contentCanvas || canvas, options);
|
|
11763
11792
|
}
|
|
11764
11793
|
else {
|
|
11765
|
-
currentMask = 'alpha';
|
|
11794
|
+
currentMask = mask === 'grayscale' ? 'grayscale' : 'alpha';
|
|
11766
11795
|
if (!maskCanvas)
|
|
11767
11796
|
maskCanvas = getCanvas(canvas);
|
|
11768
11797
|
if (!contentCanvas)
|
|
11769
11798
|
contentCanvas = getCanvas(canvas);
|
|
11770
11799
|
child.__render(maskCanvas, options);
|
|
11771
11800
|
}
|
|
11772
|
-
if (
|
|
11801
|
+
if (!(mask === 'clipping' || mask === 'clipping-path'))
|
|
11773
11802
|
continue;
|
|
11774
11803
|
}
|
|
11775
11804
|
if (excludeRenderBounds(child, options))
|
|
@@ -11780,6 +11809,8 @@ Group.prototype.__renderMask = function (canvas, options) {
|
|
|
11780
11809
|
};
|
|
11781
11810
|
function maskEnd(leaf, maskMode, canvas, contentCanvas, maskCanvas, maskOpacity) {
|
|
11782
11811
|
switch (maskMode) {
|
|
11812
|
+
case 'grayscale':
|
|
11813
|
+
maskCanvas.useGrayscaleAlpha(leaf.__nowWorld);
|
|
11783
11814
|
case 'alpha':
|
|
11784
11815
|
usePixelMask(leaf, canvas, contentCanvas, maskCanvas);
|
|
11785
11816
|
break;
|
|
@@ -12484,15 +12515,12 @@ const canvas = LeaferCanvasBase.prototype;
|
|
|
12484
12515
|
const debug = Debug.get('@leafer-ui/export');
|
|
12485
12516
|
canvas.export = function (filename, options) {
|
|
12486
12517
|
const { quality, blob } = FileHelper.getExportOptions(options);
|
|
12487
|
-
if (filename.includes('.'))
|
|
12518
|
+
if (filename.includes('.'))
|
|
12488
12519
|
return this.saveAs(filename, quality);
|
|
12489
|
-
|
|
12490
|
-
else if (blob) {
|
|
12520
|
+
else if (blob)
|
|
12491
12521
|
return this.toBlob(filename, quality);
|
|
12492
|
-
|
|
12493
|
-
else {
|
|
12522
|
+
else
|
|
12494
12523
|
return this.toDataURL(filename, quality);
|
|
12495
|
-
}
|
|
12496
12524
|
};
|
|
12497
12525
|
canvas.toBlob = function (type, quality) {
|
|
12498
12526
|
return new Promise((resolve) => {
|