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.js
CHANGED
|
@@ -111,7 +111,7 @@ var LeaferUI = (function (exports) {
|
|
|
111
111
|
return rotation - oldRotation;
|
|
112
112
|
},
|
|
113
113
|
float(num, maxLength) {
|
|
114
|
-
const a = maxLength ? pow$1(10, maxLength) : 1000000000000;
|
|
114
|
+
const a = maxLength !== undefined ? pow$1(10, maxLength) : 1000000000000;
|
|
115
115
|
num = round(num * a) / a;
|
|
116
116
|
return num === -0 ? 0 : num;
|
|
117
117
|
},
|
|
@@ -1414,14 +1414,13 @@ var LeaferUI = (function (exports) {
|
|
|
1414
1414
|
list: {},
|
|
1415
1415
|
register(UI) {
|
|
1416
1416
|
const { __tag: tag } = UI.prototype;
|
|
1417
|
-
if (list$2[tag])
|
|
1417
|
+
if (list$2[tag])
|
|
1418
1418
|
debug$f.repeat(tag);
|
|
1419
|
-
|
|
1420
|
-
else {
|
|
1421
|
-
list$2[tag] = UI;
|
|
1422
|
-
}
|
|
1419
|
+
list$2[tag] = UI;
|
|
1423
1420
|
},
|
|
1424
1421
|
get(tag, data, x, y, width, height) {
|
|
1422
|
+
if (!list$2[tag])
|
|
1423
|
+
debug$f.error('not register ' + tag);
|
|
1425
1424
|
const ui = new list$2[tag](data);
|
|
1426
1425
|
if (x !== undefined) {
|
|
1427
1426
|
ui.x = x;
|
|
@@ -1445,7 +1444,7 @@ var LeaferUI = (function (exports) {
|
|
|
1445
1444
|
Object.keys(Event).forEach(key => {
|
|
1446
1445
|
name = Event[key];
|
|
1447
1446
|
if (typeof name === 'string')
|
|
1448
|
-
nameList[name]
|
|
1447
|
+
nameList[name] && debug$e.repeat(name), nameList[name] = Event;
|
|
1449
1448
|
});
|
|
1450
1449
|
},
|
|
1451
1450
|
changeName(oldName, newName) {
|
|
@@ -1647,7 +1646,7 @@ var LeaferUI = (function (exports) {
|
|
|
1647
1646
|
const t = this;
|
|
1648
1647
|
if (t.blendMode === 'pass-through') {
|
|
1649
1648
|
const leaf = this.__leaf;
|
|
1650
|
-
if ((t.opacity < 1 && leaf.isBranch) || leaf.__hasEraser || t.eraser) {
|
|
1649
|
+
if ((t.opacity < 1 && (leaf.isBranch || t.__hasMultiPaint)) || leaf.__hasEraser || t.eraser) {
|
|
1651
1650
|
t.__single = true;
|
|
1652
1651
|
}
|
|
1653
1652
|
else if (t.__single) {
|
|
@@ -2045,8 +2044,9 @@ var LeaferUI = (function (exports) {
|
|
|
2045
2044
|
takeCanvas = this.getSameCanvas();
|
|
2046
2045
|
takeCanvas.copyWorld(this);
|
|
2047
2046
|
}
|
|
2048
|
-
|
|
2049
|
-
|
|
2047
|
+
const s = this.size;
|
|
2048
|
+
DataHelper.copyAttrs(s, size, canvasSizeAttrs);
|
|
2049
|
+
canvasSizeAttrs.forEach(key => s[key] || (s[key] = 1));
|
|
2050
2050
|
this.bounds = new Bounds(0, 0, this.width, this.height);
|
|
2051
2051
|
if (this.context && !this.unreal) {
|
|
2052
2052
|
this.updateViewSize();
|
|
@@ -2160,6 +2160,17 @@ var LeaferUI = (function (exports) {
|
|
|
2160
2160
|
if (!onlyResetTransform)
|
|
2161
2161
|
this.useWorldTransform();
|
|
2162
2162
|
}
|
|
2163
|
+
useGrayscaleAlpha(bounds) {
|
|
2164
|
+
this.setTempBounds(bounds, true, true);
|
|
2165
|
+
let alpha, pixel;
|
|
2166
|
+
const { context } = this, imageData = context.getImageData(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height), { data } = imageData;
|
|
2167
|
+
for (let i = 0, len = data.length; i < len; i += 4) {
|
|
2168
|
+
pixel = data[i] * 0.299 + data[i + 1] * 0.587 + data[i + 2] * 0.114;
|
|
2169
|
+
if (alpha = data[i + 3])
|
|
2170
|
+
data[i + 3] = alpha === 255 ? pixel : alpha * (pixel / 255);
|
|
2171
|
+
}
|
|
2172
|
+
context.putImageData(imageData, tempBounds$1.x, tempBounds$1.y);
|
|
2173
|
+
}
|
|
2163
2174
|
useMask(maskCanvas, fromBounds, toBounds) {
|
|
2164
2175
|
this.copyWorld(maskCanvas, fromBounds, toBounds, 'destination-in');
|
|
2165
2176
|
}
|
|
@@ -2170,7 +2181,7 @@ var LeaferUI = (function (exports) {
|
|
|
2170
2181
|
if (blendMode)
|
|
2171
2182
|
this.blendMode = blendMode;
|
|
2172
2183
|
this.fillStyle = color;
|
|
2173
|
-
|
|
2184
|
+
this.setTempBounds(bounds);
|
|
2174
2185
|
this.fillRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
|
|
2175
2186
|
if (blendMode)
|
|
2176
2187
|
this.blendMode = 'source-over';
|
|
@@ -2179,22 +2190,18 @@ var LeaferUI = (function (exports) {
|
|
|
2179
2190
|
if (blendMode)
|
|
2180
2191
|
this.blendMode = blendMode;
|
|
2181
2192
|
this.strokeStyle = color;
|
|
2182
|
-
|
|
2193
|
+
this.setTempBounds(bounds);
|
|
2183
2194
|
this.strokeRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
|
|
2184
2195
|
if (blendMode)
|
|
2185
2196
|
this.blendMode = 'source-over';
|
|
2186
2197
|
}
|
|
2187
2198
|
clearWorld(bounds, ceilPixel) {
|
|
2188
|
-
|
|
2189
|
-
if (ceilPixel)
|
|
2190
|
-
tempBounds$1.ceil();
|
|
2199
|
+
this.setTempBounds(bounds, ceilPixel);
|
|
2191
2200
|
this.clearRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
|
|
2192
2201
|
}
|
|
2193
2202
|
clipWorld(bounds, ceilPixel) {
|
|
2194
2203
|
this.beginPath();
|
|
2195
|
-
|
|
2196
|
-
if (ceilPixel)
|
|
2197
|
-
tempBounds$1.ceil();
|
|
2204
|
+
this.setTempBounds(bounds, ceilPixel);
|
|
2198
2205
|
this.rect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
|
|
2199
2206
|
this.clip();
|
|
2200
2207
|
}
|
|
@@ -2202,6 +2209,14 @@ var LeaferUI = (function (exports) {
|
|
|
2202
2209
|
const { pixelRatio } = this;
|
|
2203
2210
|
this.clearRect(0, 0, this.width * pixelRatio + 2, this.height * pixelRatio + 2);
|
|
2204
2211
|
}
|
|
2212
|
+
setTempBounds(bounds, ceil, intersect) {
|
|
2213
|
+
tempBounds$1.set(bounds);
|
|
2214
|
+
if (intersect)
|
|
2215
|
+
tempBounds$1.intersect(this.bounds);
|
|
2216
|
+
tempBounds$1.scale(this.pixelRatio);
|
|
2217
|
+
if (ceil)
|
|
2218
|
+
tempBounds$1.ceil();
|
|
2219
|
+
}
|
|
2205
2220
|
isSameSize(size) {
|
|
2206
2221
|
return this.width === size.width && this.height === size.height && this.pixelRatio === size.pixelRatio;
|
|
2207
2222
|
}
|
|
@@ -4153,20 +4168,17 @@ var LeaferUI = (function (exports) {
|
|
|
4153
4168
|
}
|
|
4154
4169
|
return true;
|
|
4155
4170
|
},
|
|
4156
|
-
moveWorld(t, x, y = 0, isInnerPoint) {
|
|
4171
|
+
moveWorld(t, x, y = 0, isInnerPoint, transition) {
|
|
4157
4172
|
const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
|
|
4158
4173
|
isInnerPoint ? toOuterPoint$1(t.localTransform, local, local, true) : (t.parent && toInnerPoint$1(t.parent.worldTransform, local, local, true));
|
|
4159
|
-
L.moveLocal(t, local.x, local.y);
|
|
4174
|
+
L.moveLocal(t, local.x, local.y, transition);
|
|
4160
4175
|
},
|
|
4161
|
-
moveLocal(t, x, y = 0) {
|
|
4162
|
-
if (typeof x === 'object')
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
t.x += x;
|
|
4168
|
-
t.y += y;
|
|
4169
|
-
}
|
|
4176
|
+
moveLocal(t, x, y = 0, transition) {
|
|
4177
|
+
if (typeof x === 'object')
|
|
4178
|
+
y = x.y, x = x.x;
|
|
4179
|
+
x += t.x;
|
|
4180
|
+
y += t.y;
|
|
4181
|
+
transition ? t.animate({ x, y }, transition) : (t.x = x, t.y = y);
|
|
4170
4182
|
},
|
|
4171
4183
|
zoomOfWorld(t, origin, scaleX, scaleY, resize) {
|
|
4172
4184
|
L.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize);
|
|
@@ -5215,13 +5227,14 @@ var LeaferUI = (function (exports) {
|
|
|
5215
5227
|
this.__.__checkSingle();
|
|
5216
5228
|
},
|
|
5217
5229
|
__render(canvas, options) {
|
|
5230
|
+
this.__nowWorld = this.__getNowWorld(options);
|
|
5218
5231
|
if (this.__worldOpacity) {
|
|
5219
5232
|
if (this.__.__single) {
|
|
5220
5233
|
if (this.__.eraser === 'path')
|
|
5221
5234
|
return this.__renderEraser(canvas, options);
|
|
5222
5235
|
const tempCanvas = canvas.getSameCanvas(false, true);
|
|
5223
5236
|
this.__renderBranch(tempCanvas, options);
|
|
5224
|
-
const nowWorld = this.
|
|
5237
|
+
const nowWorld = this.__nowWorld;
|
|
5225
5238
|
canvas.opacity = this.__.opacity;
|
|
5226
5239
|
canvas.copyWorldByReset(tempCanvas, nowWorld, nowWorld, this.__.__blendMode, true);
|
|
5227
5240
|
tempCanvas.recycle(nowWorld);
|
|
@@ -5545,11 +5558,11 @@ var LeaferUI = (function (exports) {
|
|
|
5545
5558
|
transform(matrix, resize) {
|
|
5546
5559
|
transform(this, matrix, resize);
|
|
5547
5560
|
}
|
|
5548
|
-
move(x, y) {
|
|
5549
|
-
moveLocal(this, x, y);
|
|
5561
|
+
move(x, y, transition) {
|
|
5562
|
+
moveLocal(this, x, y, transition);
|
|
5550
5563
|
}
|
|
5551
|
-
moveInner(x, y) {
|
|
5552
|
-
moveWorld(this, x, y, true);
|
|
5564
|
+
moveInner(x, y, transition) {
|
|
5565
|
+
moveWorld(this, x, y, true, transition);
|
|
5553
5566
|
}
|
|
5554
5567
|
scaleOf(origin, scaleX, scaleY, resize) {
|
|
5555
5568
|
zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize);
|
|
@@ -5563,8 +5576,8 @@ var LeaferUI = (function (exports) {
|
|
|
5563
5576
|
transformWorld(worldTransform, resize) {
|
|
5564
5577
|
transformWorld(this, worldTransform, resize);
|
|
5565
5578
|
}
|
|
5566
|
-
moveWorld(x, y) {
|
|
5567
|
-
moveWorld(this, x, y);
|
|
5579
|
+
moveWorld(x, y, transition) {
|
|
5580
|
+
moveWorld(this, x, y, false, transition);
|
|
5568
5581
|
}
|
|
5569
5582
|
scaleOfWorld(worldOrigin, scaleX, scaleY, resize) {
|
|
5570
5583
|
zoomOfWorld(this, worldOrigin, scaleX, scaleY, resize);
|
|
@@ -5962,7 +5975,7 @@ var LeaferUI = (function (exports) {
|
|
|
5962
5975
|
}
|
|
5963
5976
|
}
|
|
5964
5977
|
|
|
5965
|
-
const version = "1.0
|
|
5978
|
+
const version = "1.1.0";
|
|
5966
5979
|
|
|
5967
5980
|
const debug$7 = Debug.get('LeaferCanvas');
|
|
5968
5981
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
@@ -6604,7 +6617,8 @@ var LeaferUI = (function (exports) {
|
|
|
6604
6617
|
this.totalBounds = new Bounds();
|
|
6605
6618
|
debug$5.log(target.innerName, '--->');
|
|
6606
6619
|
try {
|
|
6607
|
-
target.
|
|
6620
|
+
if (!target.isApp)
|
|
6621
|
+
target.app.emit(RenderEvent.CHILD_START, target);
|
|
6608
6622
|
this.emitRender(RenderEvent.START);
|
|
6609
6623
|
this.renderOnce(callback);
|
|
6610
6624
|
this.emitRender(RenderEvent.END, this.totalBounds);
|
|
@@ -7158,6 +7172,12 @@ var LeaferUI = (function (exports) {
|
|
|
7158
7172
|
return strokeWidth;
|
|
7159
7173
|
}
|
|
7160
7174
|
get __hasStroke() { return this.stroke && this.strokeWidth; }
|
|
7175
|
+
get __hasMultiPaint() {
|
|
7176
|
+
const t = this;
|
|
7177
|
+
if ((t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect)
|
|
7178
|
+
return true;
|
|
7179
|
+
return t.fill && this.__hasStroke;
|
|
7180
|
+
}
|
|
7161
7181
|
get __clipAfterFill() { return (this.cornerRadius || this.__pathInputed); }
|
|
7162
7182
|
get __autoWidth() { return !this._width; }
|
|
7163
7183
|
get __autoHeight() { return !this._height; }
|
|
@@ -7527,9 +7547,8 @@ var LeaferUI = (function (exports) {
|
|
|
7527
7547
|
canvas.strokeRect(half, half, width, height);
|
|
7528
7548
|
canvas.restore();
|
|
7529
7549
|
}
|
|
7530
|
-
else
|
|
7550
|
+
else
|
|
7531
7551
|
canvas.strokeRect(half, half, width, height);
|
|
7532
|
-
}
|
|
7533
7552
|
break;
|
|
7534
7553
|
case 'outside':
|
|
7535
7554
|
canvas.strokeRect(-half, -half, width + __strokeWidth, height + __strokeWidth);
|
|
@@ -7559,11 +7578,15 @@ var LeaferUI = (function (exports) {
|
|
|
7559
7578
|
super(data);
|
|
7560
7579
|
}
|
|
7561
7580
|
reset(_data) { }
|
|
7562
|
-
set(data,
|
|
7563
|
-
if (
|
|
7564
|
-
|
|
7565
|
-
|
|
7566
|
-
|
|
7581
|
+
set(data, transition) {
|
|
7582
|
+
if (transition) {
|
|
7583
|
+
if (transition === 'temp') {
|
|
7584
|
+
this.lockNormalStyle = true;
|
|
7585
|
+
Object.assign(this, data);
|
|
7586
|
+
this.lockNormalStyle = false;
|
|
7587
|
+
}
|
|
7588
|
+
else
|
|
7589
|
+
this.animate(data, transition);
|
|
7567
7590
|
}
|
|
7568
7591
|
else
|
|
7569
7592
|
Object.assign(this, data);
|
|
@@ -7754,6 +7777,15 @@ var LeaferUI = (function (exports) {
|
|
|
7754
7777
|
__decorate([
|
|
7755
7778
|
boundsType(0)
|
|
7756
7779
|
], exports.UI.prototype, "padding", void 0);
|
|
7780
|
+
__decorate([
|
|
7781
|
+
boundsType(false)
|
|
7782
|
+
], exports.UI.prototype, "lockRatio", void 0);
|
|
7783
|
+
__decorate([
|
|
7784
|
+
boundsType()
|
|
7785
|
+
], exports.UI.prototype, "widthRange", void 0);
|
|
7786
|
+
__decorate([
|
|
7787
|
+
boundsType()
|
|
7788
|
+
], exports.UI.prototype, "heightRange", void 0);
|
|
7757
7789
|
__decorate([
|
|
7758
7790
|
dataType(false)
|
|
7759
7791
|
], exports.UI.prototype, "draggable", void 0);
|
|
@@ -7864,17 +7896,17 @@ var LeaferUI = (function (exports) {
|
|
|
7864
7896
|
if (!this.children)
|
|
7865
7897
|
this.children = [];
|
|
7866
7898
|
}
|
|
7867
|
-
set(data,
|
|
7899
|
+
set(data, transition) {
|
|
7868
7900
|
if (data.children) {
|
|
7869
7901
|
const { children } = data;
|
|
7870
7902
|
delete data.children;
|
|
7871
7903
|
this.children ? this.clear() : this.__setBranch();
|
|
7872
|
-
super.set(data,
|
|
7904
|
+
super.set(data, transition);
|
|
7873
7905
|
children.forEach(child => this.add(child));
|
|
7874
7906
|
data.children = children;
|
|
7875
7907
|
}
|
|
7876
7908
|
else
|
|
7877
|
-
super.set(data,
|
|
7909
|
+
super.set(data, transition);
|
|
7878
7910
|
}
|
|
7879
7911
|
toJSON(options) {
|
|
7880
7912
|
const data = super.toJSON(options);
|
|
@@ -7987,8 +8019,8 @@ var LeaferUI = (function (exports) {
|
|
|
7987
8019
|
}
|
|
7988
8020
|
onInit() { }
|
|
7989
8021
|
initType(_type) { }
|
|
7990
|
-
set(data) {
|
|
7991
|
-
this.waitInit(() => { super.set(data); });
|
|
8022
|
+
set(data, transition) {
|
|
8023
|
+
this.waitInit(() => { super.set(data, transition); });
|
|
7992
8024
|
}
|
|
7993
8025
|
start() {
|
|
7994
8026
|
clearTimeout(this.__startTimer);
|
|
@@ -8045,8 +8077,6 @@ var LeaferUI = (function (exports) {
|
|
|
8045
8077
|
__onResize(event) {
|
|
8046
8078
|
this.emitEvent(event);
|
|
8047
8079
|
DataHelper.copyAttrs(this.__, event, canvasSizeAttrs);
|
|
8048
|
-
if (!event.width || !event.height)
|
|
8049
|
-
debug$3.warn('w = 0 or h = 0');
|
|
8050
8080
|
setTimeout(() => { if (this.canvasManager)
|
|
8051
8081
|
this.canvasManager.clearRecycled(); }, 0);
|
|
8052
8082
|
}
|
|
@@ -8371,9 +8401,6 @@ var LeaferUI = (function (exports) {
|
|
|
8371
8401
|
__decorate([
|
|
8372
8402
|
dataType(false)
|
|
8373
8403
|
], exports.Box.prototype, "resizeChildren", void 0);
|
|
8374
|
-
__decorate([
|
|
8375
|
-
dataType(false)
|
|
8376
|
-
], exports.Box.prototype, "textBox", void 0);
|
|
8377
8404
|
__decorate([
|
|
8378
8405
|
affectRenderBoundsType('show')
|
|
8379
8406
|
], exports.Box.prototype, "overflow", void 0);
|
|
@@ -9128,19 +9155,13 @@ var LeaferUI = (function (exports) {
|
|
|
9128
9155
|
Object.assign(this, params);
|
|
9129
9156
|
}
|
|
9130
9157
|
getBoxPoint(relative) {
|
|
9131
|
-
|
|
9132
|
-
relative = this.current;
|
|
9133
|
-
return relative.getBoxPoint(this);
|
|
9158
|
+
return (relative || this.current).getBoxPoint(this);
|
|
9134
9159
|
}
|
|
9135
9160
|
getInnerPoint(relative) {
|
|
9136
|
-
|
|
9137
|
-
relative = this.current;
|
|
9138
|
-
return relative.getInnerPoint(this);
|
|
9161
|
+
return (relative || this.current).getInnerPoint(this);
|
|
9139
9162
|
}
|
|
9140
9163
|
getLocalPoint(relative) {
|
|
9141
|
-
|
|
9142
|
-
relative = this.current;
|
|
9143
|
-
return relative.getLocalPoint(this);
|
|
9164
|
+
return (relative || this.current).getLocalPoint(this);
|
|
9144
9165
|
}
|
|
9145
9166
|
getPagePoint() {
|
|
9146
9167
|
return this.current.getPagePoint(this);
|
|
@@ -9188,10 +9209,8 @@ var LeaferUI = (function (exports) {
|
|
|
9188
9209
|
this.data = data;
|
|
9189
9210
|
}
|
|
9190
9211
|
static getValidMove(leaf, start, total) {
|
|
9191
|
-
const { draggable, dragBounds
|
|
9192
|
-
|
|
9193
|
-
move.x += start.x - x;
|
|
9194
|
-
move.y += start.y - y;
|
|
9212
|
+
const { draggable, dragBounds } = leaf, move = leaf.getLocalPoint(total, null, true);
|
|
9213
|
+
PointHelper.move(move, start.x - leaf.x, start.y - leaf.y);
|
|
9195
9214
|
if (dragBounds)
|
|
9196
9215
|
this.getMoveInDragBounds(leaf.__local, dragBounds === 'parent' ? leaf.parent.boxBounds : dragBounds, move, true);
|
|
9197
9216
|
if (draggable === 'x')
|
|
@@ -9201,8 +9220,7 @@ var LeaferUI = (function (exports) {
|
|
|
9201
9220
|
return move;
|
|
9202
9221
|
}
|
|
9203
9222
|
static getMoveInDragBounds(childBox, dragBounds, move, change) {
|
|
9204
|
-
const x = childBox.x + move.x, y = childBox.y + move.y;
|
|
9205
|
-
const right = x + childBox.width, bottom = y + childBox.height;
|
|
9223
|
+
const x = childBox.x + move.x, y = childBox.y + move.y, right = x + childBox.width, bottom = y + childBox.height;
|
|
9206
9224
|
const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
|
|
9207
9225
|
if (!change)
|
|
9208
9226
|
move = Object.assign({}, move);
|
|
@@ -9254,9 +9272,7 @@ var LeaferUI = (function (exports) {
|
|
|
9254
9272
|
return this.getLocalMove(relative, true);
|
|
9255
9273
|
}
|
|
9256
9274
|
getPageBounds() {
|
|
9257
|
-
const total = this.getPageTotal();
|
|
9258
|
-
const start = this.getPagePoint();
|
|
9259
|
-
const bounds = {};
|
|
9275
|
+
const total = this.getPageTotal(), start = this.getPagePoint(), bounds = {};
|
|
9260
9276
|
BoundsHelper.set(bounds, start.x - total.x, start.y - total.y, total.x, total.y);
|
|
9261
9277
|
BoundsHelper.unsign(bounds);
|
|
9262
9278
|
return bounds;
|
|
@@ -9374,7 +9390,8 @@ var LeaferUI = (function (exports) {
|
|
|
9374
9390
|
const LeaferTypeCreator = {
|
|
9375
9391
|
list: {},
|
|
9376
9392
|
register(name, fn) {
|
|
9377
|
-
list[name]
|
|
9393
|
+
list[name] && debug$2.repeat(name);
|
|
9394
|
+
list[name] = fn;
|
|
9378
9395
|
},
|
|
9379
9396
|
run(name, leafer) {
|
|
9380
9397
|
const fn = list[name];
|
|
@@ -10995,6 +11012,8 @@ var LeaferUI = (function (exports) {
|
|
|
10995
11012
|
case 'center':
|
|
10996
11013
|
canvas.setStroke(stroke, __strokeWidth, options);
|
|
10997
11014
|
canvas.stroke();
|
|
11015
|
+
if (options.__useArrow)
|
|
11016
|
+
strokeArrow(ui, canvas);
|
|
10998
11017
|
break;
|
|
10999
11018
|
case 'inside':
|
|
11000
11019
|
canvas.save();
|
|
@@ -11032,6 +11051,8 @@ var LeaferUI = (function (exports) {
|
|
|
11032
11051
|
case 'center':
|
|
11033
11052
|
canvas.setStroke(undefined, __strokeWidth, options);
|
|
11034
11053
|
drawStrokesStyle(strokes, false, ui, canvas);
|
|
11054
|
+
if (options.__useArrow)
|
|
11055
|
+
strokeArrow(ui, canvas);
|
|
11035
11056
|
break;
|
|
11036
11057
|
case 'inside':
|
|
11037
11058
|
canvas.save();
|
|
@@ -11057,6 +11078,14 @@ var LeaferUI = (function (exports) {
|
|
|
11057
11078
|
}
|
|
11058
11079
|
}
|
|
11059
11080
|
}
|
|
11081
|
+
function strokeArrow(ui, canvas) {
|
|
11082
|
+
if (ui.__.dashPattern) {
|
|
11083
|
+
canvas.beginPath();
|
|
11084
|
+
ui.__drawPathByData(canvas, ui.__.__pathForArrow);
|
|
11085
|
+
canvas.dashPattern = null;
|
|
11086
|
+
canvas.stroke();
|
|
11087
|
+
}
|
|
11088
|
+
}
|
|
11060
11089
|
|
|
11061
11090
|
const { getSpread, getOuterOf, getByMove, getIntersectData } = BoundsHelper;
|
|
11062
11091
|
function shape(ui, current, options) {
|
|
@@ -11742,16 +11771,16 @@ var LeaferUI = (function (exports) {
|
|
|
11742
11771
|
|
|
11743
11772
|
const { excludeRenderBounds } = LeafBoundsHelper;
|
|
11744
11773
|
exports.Group.prototype.__renderMask = function (canvas, options) {
|
|
11745
|
-
let child, maskCanvas, contentCanvas, maskOpacity, currentMask;
|
|
11774
|
+
let child, maskCanvas, contentCanvas, maskOpacity, currentMask, mask;
|
|
11746
11775
|
const { children } = this;
|
|
11747
11776
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
11748
|
-
child = children[i];
|
|
11749
|
-
if (
|
|
11777
|
+
child = children[i], mask = child.__.mask;
|
|
11778
|
+
if (mask) {
|
|
11750
11779
|
if (currentMask) {
|
|
11751
11780
|
maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity);
|
|
11752
11781
|
maskCanvas = contentCanvas = null;
|
|
11753
11782
|
}
|
|
11754
|
-
if (
|
|
11783
|
+
if (mask === 'path' || mask === 'clipping-path') {
|
|
11755
11784
|
if (child.opacity < 1) {
|
|
11756
11785
|
currentMask = 'opacity-path';
|
|
11757
11786
|
maskOpacity = child.opacity;
|
|
@@ -11765,14 +11794,14 @@ var LeaferUI = (function (exports) {
|
|
|
11765
11794
|
child.__clip(contentCanvas || canvas, options);
|
|
11766
11795
|
}
|
|
11767
11796
|
else {
|
|
11768
|
-
currentMask = 'alpha';
|
|
11797
|
+
currentMask = mask === 'grayscale' ? 'grayscale' : 'alpha';
|
|
11769
11798
|
if (!maskCanvas)
|
|
11770
11799
|
maskCanvas = getCanvas(canvas);
|
|
11771
11800
|
if (!contentCanvas)
|
|
11772
11801
|
contentCanvas = getCanvas(canvas);
|
|
11773
11802
|
child.__render(maskCanvas, options);
|
|
11774
11803
|
}
|
|
11775
|
-
if (
|
|
11804
|
+
if (!(mask === 'clipping' || mask === 'clipping-path'))
|
|
11776
11805
|
continue;
|
|
11777
11806
|
}
|
|
11778
11807
|
if (excludeRenderBounds(child, options))
|
|
@@ -11783,6 +11812,8 @@ var LeaferUI = (function (exports) {
|
|
|
11783
11812
|
};
|
|
11784
11813
|
function maskEnd(leaf, maskMode, canvas, contentCanvas, maskCanvas, maskOpacity) {
|
|
11785
11814
|
switch (maskMode) {
|
|
11815
|
+
case 'grayscale':
|
|
11816
|
+
maskCanvas.useGrayscaleAlpha(leaf.__nowWorld);
|
|
11786
11817
|
case 'alpha':
|
|
11787
11818
|
usePixelMask(leaf, canvas, contentCanvas, maskCanvas);
|
|
11788
11819
|
break;
|
|
@@ -12487,15 +12518,12 @@ var LeaferUI = (function (exports) {
|
|
|
12487
12518
|
const debug = Debug.get('@leafer-ui/export');
|
|
12488
12519
|
canvas.export = function (filename, options) {
|
|
12489
12520
|
const { quality, blob } = FileHelper.getExportOptions(options);
|
|
12490
|
-
if (filename.includes('.'))
|
|
12521
|
+
if (filename.includes('.'))
|
|
12491
12522
|
return this.saveAs(filename, quality);
|
|
12492
|
-
|
|
12493
|
-
else if (blob) {
|
|
12523
|
+
else if (blob)
|
|
12494
12524
|
return this.toBlob(filename, quality);
|
|
12495
|
-
|
|
12496
|
-
else {
|
|
12525
|
+
else
|
|
12497
12526
|
return this.toDataURL(filename, quality);
|
|
12498
|
-
}
|
|
12499
12527
|
};
|
|
12500
12528
|
canvas.toBlob = function (type, quality) {
|
|
12501
12529
|
return new Promise((resolve) => {
|