@leafer-ui/effect 1.9.9 → 1.9.11

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.
Files changed (2) hide show
  1. package/package.json +5 -5
  2. package/src/Shadow.ts +5 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-ui/effect",
3
- "version": "1.9.9",
3
+ "version": "1.9.11",
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.9.9",
26
- "@leafer-ui/draw": "1.9.9"
25
+ "@leafer/core": "1.9.11",
26
+ "@leafer-ui/draw": "1.9.11"
27
27
  },
28
28
  "devDependencies": {
29
- "@leafer/interface": "1.9.9",
30
- "@leafer-ui/interface": "1.9.9"
29
+ "@leafer/interface": "1.9.11",
30
+ "@leafer-ui/interface": "1.9.11"
31
31
  }
32
32
  }
package/src/Shadow.ts CHANGED
@@ -5,7 +5,7 @@ import { IUI, ICachedShape, ILeafShadowEffect } from '@leafer-ui/interface'
5
5
  import { ColorConvert, Effect } from '@leafer-ui/draw'
6
6
 
7
7
 
8
- const { copy, move, toOffsetOutBounds } = BoundsHelper, { max } = Math
8
+ const { copy, move, toOffsetOutBounds } = BoundsHelper, { max, abs } = Math
9
9
  const tempBounds = {} as IBoundsData, tempMatrix = new Matrix()
10
10
  const offsetOutBounds = {} as IOffsetBoundsData
11
11
 
@@ -67,7 +67,8 @@ export function shadow(ui: IUI, current: ILeaferCanvas, shape: ICachedShape): vo
67
67
  export function getShadowRenderSpread(_ui: IUI, shadow: ILeafShadowEffect[]): IFourNumber {
68
68
  let top = 0, right = 0, bottom = 0, left = 0, x: number, y: number, spread: number, blur: number
69
69
  shadow.forEach(item => {
70
- x = item.x || 0, y = item.y || 0, spread = item.spread || 0, blur = (item.blur || 0) * 1.5
70
+ x = item.x || 0, y = item.y || 0, blur = (item.blur || 0) * 1.5, spread = abs(item.spread || 0) // must abs spread
71
+
71
72
  top = max(top, spread + blur - y)
72
73
  right = max(right, spread + blur + x)
73
74
  bottom = max(bottom, spread + blur + y)
@@ -78,15 +79,14 @@ export function getShadowRenderSpread(_ui: IUI, shadow: ILeafShadowEffect[]): IF
78
79
 
79
80
  export function getShadowTransform(ui: IUI, canvas: ILeaferCanvas, _shape: ICachedShape, shadow: ILeafShadowEffect, outBounds: IBoundsData, otherScale: number, isInnerShaodw?: boolean): IMatrixData {
80
81
  if (shadow.spread) {
81
- const spreadScale = 1 + shadow.spread * 2 / ui.__layout.strokeBounds.width * otherScale * (isInnerShaodw ? -1 : 1)
82
- tempMatrix.set().scaleOfOuter({ x: (outBounds.x + outBounds.width / 2) * canvas.pixelRatio, y: (outBounds.y + outBounds.height / 2) * canvas.pixelRatio }, spreadScale)
82
+ const spread = shadow.spread * 2 * otherScale * (isInnerShaodw ? -1 : 1), { width, height } = ui.__layout.strokeBounds
83
+ tempMatrix.set().scaleOfOuter({ x: (outBounds.x + outBounds.width / 2) * canvas.pixelRatio, y: (outBounds.y + outBounds.height / 2) * canvas.pixelRatio }, 1 + spread / width, 1 + spread / height)
83
84
  return tempMatrix
84
85
  }
85
86
  return undefined
86
87
  }
87
88
 
88
89
  export function drawWorldShadow(canvas: ILeaferCanvas, outBounds: IBoundsData, shape: ICachedShape): void {
89
-
90
90
  const { shapeBounds } = shape
91
91
  let from: IBoundsData, to: IBoundsData
92
92