leafer-ui 1.9.6 → 1.9.8
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 +97 -86
- package/dist/web.cjs +117 -81
- package/dist/web.esm.js +119 -83
- package/dist/web.esm.min.js +1 -1
- package/dist/web.esm.min.js.map +1 -1
- package/dist/web.js +281 -188
- package/dist/web.min.cjs +1 -1
- package/dist/web.min.cjs.map +1 -1
- package/dist/web.min.js +1 -1
- package/dist/web.min.js.map +1 -1
- package/dist/web.module.js +290 -188
- package/dist/web.module.min.js +1 -1
- package/dist/web.module.min.js.map +1 -1
- package/package.json +11 -11
package/dist/web.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Debug, LeaferCanvasBase, Platform, isString, isUndefined, DataHelper, canvasSizeAttrs, ResizeEvent, canvasPatch, FileHelper, Creator, LeaferImage, defineKey, LeafList, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, LeafBoundsHelper, Bounds, isArray, LeafLevelList, LayoutEvent, Run, ImageManager, BoundsHelper, Plugin, MathHelper, isObject, Matrix, getMatrixData, MatrixHelper, AlignHelper, PointHelper, ImageEvent, AroundHelper, Direction4, isNumber } from "@leafer/core";
|
|
1
|
+
import { Debug, LeaferCanvasBase, Platform, isString, isUndefined, DataHelper, canvasSizeAttrs, ResizeEvent, canvasPatch, FileHelper, Creator, LeaferImage, defineKey, LeafList, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, LeafBoundsHelper, Bounds, isArray, LeafLevelList, LayoutEvent, Run, ImageManager, BoundsHelper, Plugin, MathHelper, isObject, FourNumberHelper, Matrix, getMatrixData, MatrixHelper, AlignHelper, PointHelper, ImageEvent, AroundHelper, Direction4, isNumber } from "@leafer/core";
|
|
2
2
|
|
|
3
3
|
export * from "@leafer/core";
|
|
4
4
|
|
|
@@ -8,7 +8,7 @@ import { InteractionHelper, InteractionBase, Cursor, HitCanvasManager } from "@l
|
|
|
8
8
|
|
|
9
9
|
export * from "@leafer-ui/core";
|
|
10
10
|
|
|
11
|
-
import { PaintImage, Paint, ColorConvert, PaintGradient, Export,
|
|
11
|
+
import { PaintImage, Paint, ColorConvert, PaintGradient, Export, Group, TextConvert, Effect } from "@leafer-ui/draw";
|
|
12
12
|
|
|
13
13
|
const debug$2 = Debug.get("LeaferCanvas");
|
|
14
14
|
|
|
@@ -43,7 +43,7 @@ class LeaferCanvas extends LeaferCanvasBase {
|
|
|
43
43
|
}
|
|
44
44
|
if (Platform.syncDomFont && !this.parentView) {
|
|
45
45
|
style.display = "none";
|
|
46
|
-
document.body.appendChild(this.view);
|
|
46
|
+
if (document.body) document.body.appendChild(this.view);
|
|
47
47
|
}
|
|
48
48
|
this.__createContext();
|
|
49
49
|
if (!this.autoLayout) this.resize(config);
|
|
@@ -639,6 +639,7 @@ class Renderer {
|
|
|
639
639
|
usePartRender: true,
|
|
640
640
|
maxFPS: 120
|
|
641
641
|
};
|
|
642
|
+
this.frames = [];
|
|
642
643
|
this.target = target;
|
|
643
644
|
this.canvas = canvas;
|
|
644
645
|
if (userConfig) this.config = DataHelper.default(userConfig, this.config);
|
|
@@ -768,7 +769,7 @@ class Renderer {
|
|
|
768
769
|
};
|
|
769
770
|
if (this.needFill) canvas.fillWorld(bounds, this.config.fill);
|
|
770
771
|
if (Debug.showRepaint) Debug.drawRepaint(canvas, bounds);
|
|
771
|
-
this.target
|
|
772
|
+
Platform.render(this.target, canvas, options);
|
|
772
773
|
this.renderBounds = realBounds = realBounds || bounds;
|
|
773
774
|
this.renderOptions = options;
|
|
774
775
|
this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
|
|
@@ -791,12 +792,15 @@ class Renderer {
|
|
|
791
792
|
const target = this.target;
|
|
792
793
|
if (this.requestTime || !target) return;
|
|
793
794
|
if (target.parentApp) return target.parentApp.requestRender(false);
|
|
794
|
-
|
|
795
|
+
this.requestTime = this.frameTime || Date.now();
|
|
795
796
|
const render = () => {
|
|
796
|
-
const nowFPS = 1e3 / (Date.now() - requestTime);
|
|
797
|
+
const nowFPS = 1e3 / ((this.frameTime = Date.now()) - this.requestTime);
|
|
797
798
|
const {maxFPS: maxFPS} = this.config;
|
|
798
|
-
if (maxFPS && nowFPS > maxFPS
|
|
799
|
-
|
|
799
|
+
if (maxFPS && nowFPS > maxFPS) return Platform.requestRender(render);
|
|
800
|
+
const {frames: frames} = this;
|
|
801
|
+
if (frames.length > 30) frames.shift();
|
|
802
|
+
frames.push(nowFPS);
|
|
803
|
+
this.FPS = Math.round(frames.reduce((a, b) => a + b, 0) / frames.length);
|
|
800
804
|
this.requestTime = 0;
|
|
801
805
|
this.checkRender();
|
|
802
806
|
};
|
|
@@ -1044,6 +1048,15 @@ Object.assign(Creator, {
|
|
|
1044
1048
|
|
|
1045
1049
|
Platform.layout = Layouter.fullLayout;
|
|
1046
1050
|
|
|
1051
|
+
Platform.render = function(target, canvas, options) {
|
|
1052
|
+
const topOptions = Object.assign(Object.assign({}, options), {
|
|
1053
|
+
topRendering: true
|
|
1054
|
+
});
|
|
1055
|
+
options.topList = new LeafList;
|
|
1056
|
+
target.__render(canvas, options);
|
|
1057
|
+
if (options.topList.length) options.topList.forEach(item => item.__render(canvas, topOptions));
|
|
1058
|
+
};
|
|
1059
|
+
|
|
1047
1060
|
const PointerEventHelper = {
|
|
1048
1061
|
convert(e, local) {
|
|
1049
1062
|
const base = InteractionHelper.getBase(e), {x: x, y: y} = local;
|
|
@@ -1565,24 +1578,29 @@ function drawOutside(stroke, ui, canvas) {
|
|
|
1565
1578
|
}
|
|
1566
1579
|
}
|
|
1567
1580
|
|
|
1568
|
-
const {getSpread: getSpread, getOuterOf: getOuterOf, getByMove: getByMove, getIntersectData: getIntersectData} = BoundsHelper;
|
|
1581
|
+
const {getSpread: getSpread, copyAndSpread: copyAndSpread, toOuterOf: toOuterOf, getOuterOf: getOuterOf, getByMove: getByMove, move: move$1, getIntersectData: getIntersectData} = BoundsHelper;
|
|
1582
|
+
|
|
1583
|
+
const tempBounds$1 = {};
|
|
1569
1584
|
|
|
1570
1585
|
function shape(ui, current, options) {
|
|
1571
1586
|
const canvas = current.getSameCanvas();
|
|
1572
|
-
const nowWorld = ui.__nowWorld,
|
|
1573
|
-
|
|
1587
|
+
const currentBounds = current.bounds, nowWorld = ui.__nowWorld, layout = ui.__layout;
|
|
1588
|
+
const nowWorldShapeBounds = ui.__nowWorldShapeBounds || (ui.__nowWorldShapeBounds = {});
|
|
1589
|
+
toOuterOf(layout.strokeSpread ? (copyAndSpread(tempBounds$1, layout.boxBounds, layout.strokeSpread),
|
|
1590
|
+
tempBounds$1) : layout.boxBounds, nowWorld, nowWorldShapeBounds);
|
|
1591
|
+
let bounds, renderBounds, matrix, fitMatrix, shapeBounds, worldCanvas;
|
|
1574
1592
|
let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
|
|
1575
|
-
if (currentBounds.includes(
|
|
1593
|
+
if (currentBounds.includes(nowWorldShapeBounds)) {
|
|
1576
1594
|
worldCanvas = canvas;
|
|
1577
|
-
bounds = shapeBounds =
|
|
1595
|
+
bounds = shapeBounds = nowWorldShapeBounds;
|
|
1596
|
+
renderBounds = nowWorld;
|
|
1578
1597
|
} else {
|
|
1579
|
-
const {renderShapeSpread: spread} = ui.__layout;
|
|
1580
1598
|
let worldClipBounds;
|
|
1581
1599
|
if (Platform.fullImageShadow) {
|
|
1582
|
-
worldClipBounds =
|
|
1600
|
+
worldClipBounds = nowWorldShapeBounds;
|
|
1583
1601
|
} else {
|
|
1584
|
-
const spreadBounds =
|
|
1585
|
-
worldClipBounds = getIntersectData(spreadBounds,
|
|
1602
|
+
const spreadBounds = layout.renderShapeSpread ? getSpread(currentBounds, FourNumberHelper.swapAndScale(layout.renderShapeSpread, scaleX, scaleY)) : currentBounds;
|
|
1603
|
+
worldClipBounds = getIntersectData(spreadBounds, nowWorldShapeBounds);
|
|
1586
1604
|
}
|
|
1587
1605
|
fitMatrix = currentBounds.getFitMatrix(worldClipBounds);
|
|
1588
1606
|
let {a: fitScaleX, d: fitScaleY} = fitMatrix;
|
|
@@ -1592,8 +1610,10 @@ function shape(ui, current, options) {
|
|
|
1592
1610
|
scaleX *= fitScaleX;
|
|
1593
1611
|
scaleY *= fitScaleY;
|
|
1594
1612
|
}
|
|
1595
|
-
shapeBounds = getOuterOf(
|
|
1613
|
+
shapeBounds = getOuterOf(nowWorldShapeBounds, fitMatrix);
|
|
1596
1614
|
bounds = getByMove(shapeBounds, -fitMatrix.e, -fitMatrix.f);
|
|
1615
|
+
renderBounds = getOuterOf(nowWorld, fitMatrix);
|
|
1616
|
+
move$1(renderBounds, -fitMatrix.e, -fitMatrix.f);
|
|
1597
1617
|
const userMatrix = options.matrix;
|
|
1598
1618
|
if (userMatrix) {
|
|
1599
1619
|
matrix = new Matrix(fitMatrix);
|
|
@@ -1612,6 +1632,7 @@ function shape(ui, current, options) {
|
|
|
1612
1632
|
matrix: matrix,
|
|
1613
1633
|
fitMatrix: fitMatrix,
|
|
1614
1634
|
bounds: bounds,
|
|
1635
|
+
renderBounds: renderBounds,
|
|
1615
1636
|
worldCanvas: worldCanvas,
|
|
1616
1637
|
shapeBounds: shapeBounds,
|
|
1617
1638
|
scaleX: scaleX,
|
|
@@ -1715,7 +1736,7 @@ const PaintModule = {
|
|
|
1715
1736
|
shape: shape
|
|
1716
1737
|
};
|
|
1717
1738
|
|
|
1718
|
-
let origin = {}, tempMatrix = getMatrixData();
|
|
1739
|
+
let origin = {}, tempMatrix$1 = getMatrixData();
|
|
1719
1740
|
|
|
1720
1741
|
const {get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
|
|
1721
1742
|
|
|
@@ -1730,12 +1751,12 @@ function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
|
1730
1751
|
data.transform = transform;
|
|
1731
1752
|
}
|
|
1732
1753
|
|
|
1733
|
-
function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew,
|
|
1754
|
+
function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY) {
|
|
1734
1755
|
const transform = get$3();
|
|
1735
1756
|
layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
|
|
1736
|
-
if (
|
|
1737
|
-
tempMatrix.a =
|
|
1738
|
-
multiplyParent(transform, tempMatrix);
|
|
1757
|
+
if (clipScaleX) {
|
|
1758
|
+
tempMatrix$1.a = clipScaleX, tempMatrix$1.d = clipScaleY;
|
|
1759
|
+
multiplyParent(transform, tempMatrix$1);
|
|
1739
1760
|
}
|
|
1740
1761
|
data.transform = transform;
|
|
1741
1762
|
}
|
|
@@ -1836,7 +1857,12 @@ function getPatternData(paint, box, image) {
|
|
|
1836
1857
|
|
|
1837
1858
|
case "normal":
|
|
1838
1859
|
case "clip":
|
|
1839
|
-
if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew)
|
|
1860
|
+
if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew) {
|
|
1861
|
+
let clipScaleX, clipScaleY;
|
|
1862
|
+
if (clipSize) clipScaleX = box.width / clipSize.width, clipScaleY = box.height / clipSize.height;
|
|
1863
|
+
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
|
|
1864
|
+
if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : scaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
|
|
1865
|
+
}
|
|
1840
1866
|
break;
|
|
1841
1867
|
|
|
1842
1868
|
case "repeat":
|
|
@@ -1994,7 +2020,7 @@ function ignoreRender(ui, value) {
|
|
|
1994
2020
|
|
|
1995
2021
|
const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
|
|
1996
2022
|
|
|
1997
|
-
const {floor: floor, ceil: ceil, max: max, abs: abs} = Math;
|
|
2023
|
+
const {floor: floor, ceil: ceil, max: max$1, abs: abs} = Math;
|
|
1998
2024
|
|
|
1999
2025
|
function createPattern(ui, paint, pixelRatio) {
|
|
2000
2026
|
let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
|
|
@@ -2043,8 +2069,8 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
2043
2069
|
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
2044
2070
|
const canvasWidth = width + (xGap || 0);
|
|
2045
2071
|
const canvasHeight = height + (yGap || 0);
|
|
2046
|
-
scaleX /= canvasWidth / max(floor(canvasWidth), 1);
|
|
2047
|
-
scaleY /= canvasHeight / max(floor(canvasHeight), 1);
|
|
2072
|
+
scaleX /= canvasWidth / max$1(floor(canvasWidth), 1);
|
|
2073
|
+
scaleY /= canvasHeight / max$1(floor(canvasHeight), 1);
|
|
2048
2074
|
if (!imageMatrix) {
|
|
2049
2075
|
imageMatrix = get$1();
|
|
2050
2076
|
if (transform) copy$1(imageMatrix, transform);
|
|
@@ -2103,17 +2129,15 @@ function checkImage(ui, canvas, paint, allowDraw) {
|
|
|
2103
2129
|
if (allowDraw) {
|
|
2104
2130
|
if (data.repeat) {
|
|
2105
2131
|
allowDraw = false;
|
|
2106
|
-
} else {
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
height *= data.scaleY;
|
|
2114
|
-
}
|
|
2115
|
-
allowDraw = width * height > Platform.image.maxCacheSize;
|
|
2132
|
+
} else if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || Export.running)) {
|
|
2133
|
+
let {width: width, height: height} = data;
|
|
2134
|
+
width *= scaleX * pixelRatio;
|
|
2135
|
+
height *= scaleY * pixelRatio;
|
|
2136
|
+
if (data.scaleX) {
|
|
2137
|
+
width *= data.scaleX;
|
|
2138
|
+
height *= data.scaleY;
|
|
2116
2139
|
}
|
|
2140
|
+
allowDraw = width * height > Platform.image.maxCacheSize;
|
|
2117
2141
|
}
|
|
2118
2142
|
}
|
|
2119
2143
|
if (allowDraw) {
|
|
@@ -2293,20 +2317,20 @@ const PaintGradientModule = {
|
|
|
2293
2317
|
getTransform: getTransform
|
|
2294
2318
|
};
|
|
2295
2319
|
|
|
2296
|
-
const {copy: copy, toOffsetOutBounds: toOffsetOutBounds$1} = BoundsHelper;
|
|
2320
|
+
const {copy: copy, move: move, toOffsetOutBounds: toOffsetOutBounds$1} = BoundsHelper, {max: max} = Math;
|
|
2297
2321
|
|
|
2298
|
-
const tempBounds = {};
|
|
2322
|
+
const tempBounds = {}, tempMatrix = new Matrix;
|
|
2299
2323
|
|
|
2300
2324
|
const offsetOutBounds$1 = {};
|
|
2301
2325
|
|
|
2302
2326
|
function shadow(ui, current, shape) {
|
|
2303
|
-
let copyBounds,
|
|
2304
|
-
const {__nowWorld: nowWorld
|
|
2327
|
+
let copyBounds, transform;
|
|
2328
|
+
const {__nowWorld: nowWorld} = ui;
|
|
2305
2329
|
const {shadow: shadow} = ui.__;
|
|
2306
|
-
const {worldCanvas: worldCanvas, bounds: bounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
|
|
2330
|
+
const {worldCanvas: worldCanvas, bounds: bounds, renderBounds: renderBounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
|
|
2307
2331
|
const other = current.getSameCanvas();
|
|
2308
2332
|
const end = shadow.length - 1;
|
|
2309
|
-
toOffsetOutBounds$1(bounds, offsetOutBounds$1);
|
|
2333
|
+
toOffsetOutBounds$1(bounds, offsetOutBounds$1, renderBounds);
|
|
2310
2334
|
shadow.forEach((item, index) => {
|
|
2311
2335
|
let otherScale = 1;
|
|
2312
2336
|
if (item.scaleFixed) {
|
|
@@ -2314,54 +2338,61 @@ function shadow(ui, current, shape) {
|
|
|
2314
2338
|
if (sx > 1) otherScale = 1 / sx;
|
|
2315
2339
|
}
|
|
2316
2340
|
other.setWorldShadow(offsetOutBounds$1.offsetX + item.x * scaleX * otherScale, offsetOutBounds$1.offsetY + item.y * scaleY * otherScale, item.blur * scaleX * otherScale, ColorConvert.string(item.color));
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2341
|
+
transform = getShadowTransform(ui, other, shape, item, offsetOutBounds$1, otherScale);
|
|
2342
|
+
if (transform) other.setTransform(transform);
|
|
2343
|
+
drawWorldShadow(other, offsetOutBounds$1, shape);
|
|
2344
|
+
if (transform) other.resetTransform();
|
|
2345
|
+
copyBounds = renderBounds;
|
|
2320
2346
|
if (item.box) {
|
|
2321
2347
|
other.restore();
|
|
2322
2348
|
other.save();
|
|
2323
2349
|
if (worldCanvas) {
|
|
2324
|
-
other.copyWorld(other,
|
|
2350
|
+
other.copyWorld(other, renderBounds, nowWorld, "copy");
|
|
2325
2351
|
copyBounds = nowWorld;
|
|
2326
2352
|
}
|
|
2327
2353
|
worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, "destination-out") : other.copyWorld(shape.canvas, shapeBounds, bounds, "destination-out");
|
|
2328
2354
|
}
|
|
2329
|
-
|
|
2355
|
+
LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
|
|
2330
2356
|
if (end && index < end) other.clearWorld(copyBounds);
|
|
2331
2357
|
});
|
|
2332
2358
|
other.recycle(copyBounds);
|
|
2333
2359
|
}
|
|
2334
2360
|
|
|
2335
|
-
function
|
|
2336
|
-
let
|
|
2337
|
-
shadow.forEach(item =>
|
|
2338
|
-
|
|
2361
|
+
function getShadowRenderSpread(_ui, shadow) {
|
|
2362
|
+
let top = 0, right = 0, bottom = 0, left = 0, x, y, spread, blur;
|
|
2363
|
+
shadow.forEach(item => {
|
|
2364
|
+
x = item.x || 0, y = item.y || 0, spread = item.spread || 0, blur = (item.blur || 0) * 1.5;
|
|
2365
|
+
top = max(top, spread + blur - y);
|
|
2366
|
+
right = max(right, spread + blur + x);
|
|
2367
|
+
bottom = max(bottom, spread + blur + y);
|
|
2368
|
+
left = max(left, spread + blur - x);
|
|
2369
|
+
});
|
|
2370
|
+
return top === right && right === bottom && bottom === left ? top : [ top, right, bottom, left ];
|
|
2371
|
+
}
|
|
2372
|
+
|
|
2373
|
+
function getShadowTransform(ui, canvas, _shape, shadow, outBounds, otherScale, isInnerShaodw) {
|
|
2374
|
+
if (shadow.spread) {
|
|
2375
|
+
const spreadScale = 1 + shadow.spread * 2 / ui.__layout.strokeBounds.width * otherScale * (isInnerShaodw ? -1 : 1);
|
|
2376
|
+
tempMatrix.set().scaleOfOuter({
|
|
2377
|
+
x: (outBounds.x + outBounds.width / 2) * canvas.pixelRatio,
|
|
2378
|
+
y: (outBounds.y + outBounds.height / 2) * canvas.pixelRatio
|
|
2379
|
+
}, spreadScale);
|
|
2380
|
+
return tempMatrix;
|
|
2381
|
+
}
|
|
2382
|
+
return undefined;
|
|
2339
2383
|
}
|
|
2340
2384
|
|
|
2341
|
-
function drawWorldShadow(canvas, outBounds,
|
|
2342
|
-
const {
|
|
2385
|
+
function drawWorldShadow(canvas, outBounds, shape) {
|
|
2386
|
+
const {shapeBounds: shapeBounds} = shape;
|
|
2387
|
+
let from, to;
|
|
2343
2388
|
if (Platform.fullImageShadow) {
|
|
2344
2389
|
copy(tempBounds, canvas.bounds);
|
|
2345
|
-
tempBounds.x
|
|
2346
|
-
|
|
2347
|
-
if (spreadScale) {
|
|
2348
|
-
const {fitMatrix: fitMatrix} = shape;
|
|
2349
|
-
tempBounds.x -= (bounds.x + (fitMatrix ? fitMatrix.e : 0) + bounds.width / 2) * (spreadScale - 1);
|
|
2350
|
-
tempBounds.y -= (bounds.y + (fitMatrix ? fitMatrix.f : 0) + bounds.height / 2) * (spreadScale - 1);
|
|
2351
|
-
tempBounds.width *= spreadScale;
|
|
2352
|
-
tempBounds.height *= spreadScale;
|
|
2353
|
-
}
|
|
2354
|
-
canvas.copyWorld(shape.canvas, canvas.bounds, tempBounds);
|
|
2390
|
+
move(tempBounds, outBounds.x - shapeBounds.x, outBounds.y - shapeBounds.y);
|
|
2391
|
+
from = canvas.bounds, to = tempBounds;
|
|
2355
2392
|
} else {
|
|
2356
|
-
|
|
2357
|
-
copy(tempBounds, outBounds);
|
|
2358
|
-
tempBounds.x -= outBounds.width / 2 * (spreadScale - 1);
|
|
2359
|
-
tempBounds.y -= outBounds.height / 2 * (spreadScale - 1);
|
|
2360
|
-
tempBounds.width *= spreadScale;
|
|
2361
|
-
tempBounds.height *= spreadScale;
|
|
2362
|
-
}
|
|
2363
|
-
canvas.copyWorld(shape.canvas, shapeBounds, spreadScale ? tempBounds : outBounds);
|
|
2393
|
+
from = shapeBounds, to = outBounds;
|
|
2364
2394
|
}
|
|
2395
|
+
canvas.copyWorld(shape.canvas, from, to);
|
|
2365
2396
|
}
|
|
2366
2397
|
|
|
2367
2398
|
const {toOffsetOutBounds: toOffsetOutBounds} = BoundsHelper;
|
|
@@ -2369,13 +2400,13 @@ const {toOffsetOutBounds: toOffsetOutBounds} = BoundsHelper;
|
|
|
2369
2400
|
const offsetOutBounds = {};
|
|
2370
2401
|
|
|
2371
2402
|
function innerShadow(ui, current, shape) {
|
|
2372
|
-
let copyBounds,
|
|
2373
|
-
const {__nowWorld: nowWorld
|
|
2403
|
+
let copyBounds, transform;
|
|
2404
|
+
const {__nowWorld: nowWorld} = ui;
|
|
2374
2405
|
const {innerShadow: innerShadow} = ui.__;
|
|
2375
|
-
const {worldCanvas: worldCanvas, bounds: bounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
|
|
2406
|
+
const {worldCanvas: worldCanvas, bounds: bounds, renderBounds: renderBounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
|
|
2376
2407
|
const other = current.getSameCanvas();
|
|
2377
2408
|
const end = innerShadow.length - 1;
|
|
2378
|
-
toOffsetOutBounds(bounds, offsetOutBounds);
|
|
2409
|
+
toOffsetOutBounds(bounds, offsetOutBounds, renderBounds);
|
|
2379
2410
|
innerShadow.forEach((item, index) => {
|
|
2380
2411
|
let otherScale = 1;
|
|
2381
2412
|
if (item.scaleFixed) {
|
|
@@ -2384,16 +2415,17 @@ function innerShadow(ui, current, shape) {
|
|
|
2384
2415
|
}
|
|
2385
2416
|
other.save();
|
|
2386
2417
|
other.setWorldShadow(offsetOutBounds.offsetX + item.x * scaleX * otherScale, offsetOutBounds.offsetY + item.y * scaleY * otherScale, item.blur * scaleX * otherScale);
|
|
2387
|
-
|
|
2388
|
-
|
|
2418
|
+
transform = getShadowTransform(ui, other, shape, item, offsetOutBounds, otherScale, true);
|
|
2419
|
+
if (transform) other.setTransform(transform);
|
|
2420
|
+
drawWorldShadow(other, offsetOutBounds, shape);
|
|
2389
2421
|
other.restore();
|
|
2390
2422
|
if (worldCanvas) {
|
|
2391
|
-
other.copyWorld(other,
|
|
2423
|
+
other.copyWorld(other, renderBounds, nowWorld, "copy");
|
|
2392
2424
|
other.copyWorld(worldCanvas, nowWorld, nowWorld, "source-out");
|
|
2393
2425
|
copyBounds = nowWorld;
|
|
2394
2426
|
} else {
|
|
2395
2427
|
other.copyWorld(shape.canvas, shapeBounds, bounds, "source-out");
|
|
2396
|
-
copyBounds =
|
|
2428
|
+
copyBounds = renderBounds;
|
|
2397
2429
|
}
|
|
2398
2430
|
other.fillWorld(copyBounds, ColorConvert.string(item.color), "source-in");
|
|
2399
2431
|
LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
|
|
@@ -2402,6 +2434,8 @@ function innerShadow(ui, current, shape) {
|
|
|
2402
2434
|
other.recycle(copyBounds);
|
|
2403
2435
|
}
|
|
2404
2436
|
|
|
2437
|
+
const getInnerShadowSpread = getShadowRenderSpread;
|
|
2438
|
+
|
|
2405
2439
|
function blur(ui, current, origin) {
|
|
2406
2440
|
const {blur: blur} = ui.__;
|
|
2407
2441
|
origin.setWorldBlur(blur * ui.__nowWorld.a);
|
|
@@ -2416,10 +2450,12 @@ const EffectModule = {
|
|
|
2416
2450
|
innerShadow: innerShadow,
|
|
2417
2451
|
blur: blur,
|
|
2418
2452
|
backgroundBlur: backgroundBlur,
|
|
2419
|
-
|
|
2453
|
+
getShadowRenderSpread: getShadowRenderSpread,
|
|
2454
|
+
getShadowTransform: getShadowTransform,
|
|
2420
2455
|
isTransformShadow(_shadow) {
|
|
2421
2456
|
return undefined;
|
|
2422
|
-
}
|
|
2457
|
+
},
|
|
2458
|
+
getInnerShadowSpread: getInnerShadowSpread
|
|
2423
2459
|
};
|
|
2424
2460
|
|
|
2425
2461
|
const {excludeRenderBounds: excludeRenderBounds} = LeafBoundsHelper;
|
|
@@ -2436,6 +2472,7 @@ Group.prototype.__renderMask = function(canvas, options) {
|
|
|
2436
2472
|
maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity, undefined, true);
|
|
2437
2473
|
maskCanvas = contentCanvas = null;
|
|
2438
2474
|
}
|
|
2475
|
+
if (mask === "clipping" || mask === "clipping-path") excludeRenderBounds(child, options) || child.__render(canvas, options);
|
|
2439
2476
|
maskOpacity = child.__.opacity;
|
|
2440
2477
|
usedGrayscaleAlpha = false;
|
|
2441
2478
|
if (mask === "path" || mask === "clipping-path") {
|
|
@@ -2453,7 +2490,6 @@ Group.prototype.__renderMask = function(canvas, options) {
|
|
|
2453
2490
|
if (!contentCanvas) contentCanvas = getCanvas(canvas);
|
|
2454
2491
|
child.__render(maskCanvas, options);
|
|
2455
2492
|
}
|
|
2456
|
-
if (mask === "clipping" || mask === "clipping-path") excludeRenderBounds(child, options) || child.__render(canvas, options);
|
|
2457
2493
|
continue;
|
|
2458
2494
|
}
|
|
2459
2495
|
const childBlendMode = maskOpacity === 1 && child.__.__blendMode;
|