@leafer-ui/paint 1.9.7 → 1.9.9
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 +5 -5
- package/src/Shape.ts +22 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/paint",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.9",
|
|
4
4
|
"description": "@leafer-ui/paint",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
"leaferjs"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@leafer/core": "1.9.
|
|
26
|
-
"@leafer-ui/draw": "1.9.
|
|
25
|
+
"@leafer/core": "1.9.9",
|
|
26
|
+
"@leafer-ui/draw": "1.9.9"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@leafer/interface": "1.9.
|
|
30
|
-
"@leafer-ui/interface": "1.9.
|
|
29
|
+
"@leafer/interface": "1.9.9",
|
|
30
|
+
"@leafer-ui/interface": "1.9.9"
|
|
31
31
|
}
|
|
32
32
|
}
|
package/src/Shape.ts
CHANGED
|
@@ -1,35 +1,39 @@
|
|
|
1
1
|
import { IBoundsData, ILeaferCanvas, IRenderOptions, IMatrix } from '@leafer/interface'
|
|
2
|
-
import { BoundsHelper, Matrix, Platform } from '@leafer/core'
|
|
2
|
+
import { BoundsHelper, FourNumberHelper, Matrix, Platform } from '@leafer/core'
|
|
3
3
|
|
|
4
4
|
import { IUI, ICachedShape } from '@leafer-ui/interface'
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
const { getSpread, getOuterOf, getByMove, getIntersectData } = BoundsHelper
|
|
7
|
+
const { getSpread, copyAndSpread, toOuterOf, getOuterOf, getByMove, move, getIntersectData } = BoundsHelper
|
|
8
|
+
const tempBounds = {} as IBoundsData
|
|
8
9
|
|
|
9
10
|
export function shape(ui: IUI, current: ILeaferCanvas, options: IRenderOptions): ICachedShape {
|
|
10
11
|
const canvas = current.getSameCanvas()
|
|
11
|
-
const nowWorld = ui.__nowWorld,
|
|
12
|
+
const currentBounds = current.bounds, nowWorld = ui.__nowWorld, layout = ui.__layout
|
|
13
|
+
const nowWorldShapeBounds = ui.__nowWorldShapeBounds || (ui.__nowWorldShapeBounds = {} as IBoundsData)
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
toOuterOf(layout.strokeSpread ? (copyAndSpread(tempBounds, layout.boxBounds, layout.strokeSpread), tempBounds) : layout.boxBounds, nowWorld, nowWorldShapeBounds)
|
|
16
|
+
|
|
17
|
+
let bounds: IBoundsData, renderBounds: IBoundsData, matrix: IMatrix, fitMatrix: IMatrix, shapeBounds: IBoundsData, worldCanvas: ILeaferCanvas
|
|
14
18
|
|
|
15
19
|
let { scaleX, scaleY } = ui.getRenderScaleData(true)
|
|
16
20
|
|
|
17
|
-
if (currentBounds.includes(
|
|
21
|
+
if (currentBounds.includes(nowWorldShapeBounds)) {
|
|
18
22
|
|
|
19
23
|
worldCanvas = canvas
|
|
20
|
-
bounds = shapeBounds =
|
|
24
|
+
bounds = shapeBounds = nowWorldShapeBounds
|
|
25
|
+
renderBounds = nowWorld
|
|
21
26
|
|
|
22
27
|
} else {
|
|
23
28
|
|
|
24
|
-
const { renderShapeSpread: spread } = ui.__layout
|
|
25
|
-
|
|
26
29
|
let worldClipBounds: IBoundsData // 作为绘制阴影的裁剪形状
|
|
27
30
|
|
|
28
31
|
if (Platform.fullImageShadow) { // fix: iOS Safari 18.5 以上, 只裁剪部分区域渲染阴影会有问题
|
|
29
|
-
worldClipBounds =
|
|
32
|
+
worldClipBounds = nowWorldShapeBounds
|
|
30
33
|
} else {
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
|
|
35
|
+
const spreadBounds = layout.renderShapeSpread ? getSpread(currentBounds, FourNumberHelper.swapAndScale(layout.renderShapeSpread, scaleX, scaleY)) : currentBounds // spread需要反向交换值
|
|
36
|
+
worldClipBounds = getIntersectData(spreadBounds, nowWorldShapeBounds)
|
|
33
37
|
}
|
|
34
38
|
|
|
35
39
|
fitMatrix = currentBounds.getFitMatrix(worldClipBounds)
|
|
@@ -43,9 +47,14 @@ export function shape(ui: IUI, current: ILeaferCanvas, options: IRenderOptions):
|
|
|
43
47
|
scaleY *= fitScaleY
|
|
44
48
|
}
|
|
45
49
|
|
|
46
|
-
|
|
50
|
+
|
|
51
|
+
shapeBounds = getOuterOf(nowWorldShapeBounds, fitMatrix)
|
|
47
52
|
bounds = getByMove(shapeBounds, -fitMatrix.e, -fitMatrix.f)
|
|
48
53
|
|
|
54
|
+
renderBounds = getOuterOf(nowWorld, fitMatrix)
|
|
55
|
+
move(renderBounds, -fitMatrix.e, -fitMatrix.f)
|
|
56
|
+
|
|
57
|
+
|
|
49
58
|
const userMatrix = options.matrix
|
|
50
59
|
if (userMatrix) {
|
|
51
60
|
matrix = new Matrix(fitMatrix) // 仅用于渲染
|
|
@@ -61,7 +70,7 @@ export function shape(ui: IUI, current: ILeaferCanvas, options: IRenderOptions):
|
|
|
61
70
|
ui.__renderShape(canvas, options)
|
|
62
71
|
|
|
63
72
|
return {
|
|
64
|
-
canvas, matrix, fitMatrix, bounds,
|
|
73
|
+
canvas, matrix, fitMatrix, bounds, renderBounds,
|
|
65
74
|
worldCanvas, shapeBounds, scaleX, scaleY
|
|
66
75
|
}
|
|
67
76
|
}
|