@leafer-ui/effect 1.7.0 → 1.9.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-ui/effect",
3
- "version": "1.7.0",
3
+ "version": "1.9.0",
4
4
  "description": "@leafer-ui/effect",
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.7.0",
26
- "@leafer-ui/draw": "1.7.0"
25
+ "@leafer/core": "1.9.0",
26
+ "@leafer-ui/draw": "1.9.0"
27
27
  },
28
28
  "devDependencies": {
29
- "@leafer/interface": "1.7.0",
30
- "@leafer-ui/interface": "1.7.0"
29
+ "@leafer/interface": "1.9.0",
30
+ "@leafer-ui/interface": "1.9.0"
31
31
  }
32
32
  }
@@ -1,5 +1,5 @@
1
- import { IBoundsData, ILeaferCanvas, IMatrixWithBoundsData, IOffsetBoundsData } from '@leafer/interface'
2
- import { BoundsHelper } from '@leafer/core'
1
+ import { IBoundsData, ILeaferCanvas, IOffsetBoundsData } from '@leafer/interface'
2
+ import { BoundsHelper, LeafHelper } from '@leafer/core'
3
3
 
4
4
  import { IUI, ICachedShape } from '@leafer-ui/interface'
5
5
  import { ColorConvert } from '@leafer-ui/draw'
@@ -25,11 +25,18 @@ export function innerShadow(ui: IUI, current: ILeaferCanvas, shape: ICachedShape
25
25
 
26
26
  innerShadow.forEach((item, index) => {
27
27
 
28
+ let otherScale = 1 // 关联 scaleFixed 逻辑
29
+
30
+ if (item.scaleFixed) {
31
+ const sx = Math.abs(nowWorld.scaleX)
32
+ if (sx > 1) otherScale = 1 / sx
33
+ }
34
+
28
35
  other.save()
29
36
 
30
- other.setWorldShadow((offsetOutBounds.offsetX + item.x * scaleX), (offsetOutBounds.offsetY + item.y * scaleY), item.blur * scaleX)
37
+ other.setWorldShadow((offsetOutBounds.offsetX + item.x * scaleX * otherScale), (offsetOutBounds.offsetY + item.y * scaleY * otherScale), item.blur * scaleX * otherScale)
31
38
 
32
- spreadScale = item.spread ? 1 - item.spread * 2 / (__layout.boxBounds.width + (__layout.strokeBoxSpread || 0) * 2) : 0
39
+ spreadScale = item.spread ? 1 - item.spread * 2 / (__layout.boxBounds.width + (__layout.strokeBoxSpread || 0) * 2) * otherScale : 0
33
40
 
34
41
  drawWorldShadow(other, offsetOutBounds, spreadScale, shape)
35
42
 
@@ -46,8 +53,7 @@ export function innerShadow(ui: IUI, current: ILeaferCanvas, shape: ICachedShape
46
53
 
47
54
  other.fillWorld(copyBounds, ColorConvert.string(item.color), 'source-in')
48
55
 
49
- if (ui.__worldFlipped) current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode)
50
- else current.copyWorldToInner(other, copyBounds as IMatrixWithBoundsData, __layout.renderBounds, item.blendMode)
56
+ LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode)
51
57
 
52
58
  if (end && index < end) other.clearWorld(copyBounds, true)
53
59
 
package/src/Shadow.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { IBoundsData, ILeaferCanvas, IMatrixWithBoundsData, IOffsetBoundsData } from '@leafer/interface'
2
- import { BoundsHelper, Platform } from '@leafer/core'
1
+ import { IBoundsData, ILeaferCanvas, IOffsetBoundsData } from '@leafer/interface'
2
+ import { BoundsHelper, LeafHelper, Platform } from '@leafer/core'
3
3
 
4
4
  import { IUI, ICachedShape } from '@leafer-ui/interface'
5
5
  import { ColorConvert } from '@leafer-ui/draw'
@@ -24,9 +24,16 @@ export function shadow(ui: IUI, current: ILeaferCanvas, shape: ICachedShape): vo
24
24
 
25
25
  shadow.forEach((item, index) => {
26
26
 
27
- other.setWorldShadow((offsetOutBounds.offsetX + item.x * scaleX), (offsetOutBounds.offsetY + item.y * scaleY), item.blur * scaleX, ColorConvert.string(item.color))
27
+ let otherScale = 1 // 关联 scaleFixed 逻辑
28
28
 
29
- spreadScale = item.spread ? 1 + item.spread * 2 / (__layout.boxBounds.width + (__layout.strokeBoxSpread || 0) * 2) : 0
29
+ if (item.scaleFixed) {
30
+ const sx = Math.abs(nowWorld.scaleX)
31
+ if (sx > 1) otherScale = 1 / sx
32
+ }
33
+
34
+ other.setWorldShadow((offsetOutBounds.offsetX + item.x * scaleX * otherScale), (offsetOutBounds.offsetY + item.y * scaleY * otherScale), item.blur * scaleX * otherScale, ColorConvert.string(item.color))
35
+
36
+ spreadScale = item.spread ? 1 + item.spread * 2 / (__layout.boxBounds.width + (__layout.strokeBoxSpread || 0) * 2) * otherScale : 0
30
37
 
31
38
  drawWorldShadow(other, offsetOutBounds, spreadScale, shape)
32
39
 
@@ -45,8 +52,7 @@ export function shadow(ui: IUI, current: ILeaferCanvas, shape: ICachedShape): vo
45
52
  worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out')
46
53
  }
47
54
 
48
- if (ui.__worldFlipped) current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode)
49
- else current.copyWorldToInner(other, copyBounds as IMatrixWithBoundsData, __layout.renderBounds, item.blendMode)
55
+ LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode)
50
56
 
51
57
  if (end && index < end) other.clearWorld(copyBounds, true)
52
58
  })
@@ -56,7 +62,7 @@ export function shadow(ui: IUI, current: ILeaferCanvas, shape: ICachedShape): vo
56
62
  }
57
63
 
58
64
 
59
- export function drawWorldShadow(canvas: ILeaferCanvas, outBounds: IBoundsData, spreadScale: number, shape: ICachedShape,): void {
65
+ export function drawWorldShadow(canvas: ILeaferCanvas, outBounds: IBoundsData, spreadScale: number, shape: ICachedShape): void {
60
66
 
61
67
  const { bounds, shapeBounds } = shape
62
68
 
@@ -67,9 +73,9 @@ export function drawWorldShadow(canvas: ILeaferCanvas, outBounds: IBoundsData, s
67
73
  tempBounds.y += (outBounds.y - shapeBounds.y)
68
74
 
69
75
  if (spreadScale) {
70
- const { matrix } = shape
71
- tempBounds.x -= (bounds.x + (matrix ? matrix.e : 0) + bounds.width / 2) * (spreadScale - 1)
72
- tempBounds.y -= (bounds.y + (matrix ? matrix.f : 0) + bounds.height / 2) * (spreadScale - 1)
76
+ const { fitMatrix } = shape
77
+ tempBounds.x -= (bounds.x + (fitMatrix ? fitMatrix.e : 0) + bounds.width / 2) * (spreadScale - 1)
78
+ tempBounds.y -= (bounds.y + (fitMatrix ? fitMatrix.f : 0) + bounds.height / 2) * (spreadScale - 1)
73
79
  tempBounds.width *= spreadScale
74
80
  tempBounds.height *= spreadScale
75
81
  }