@leafer-ui/effect 1.9.4 → 1.9.6

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.9.4",
3
+ "version": "1.9.6",
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.4",
26
- "@leafer-ui/draw": "1.9.4"
25
+ "@leafer/core": "1.9.6",
26
+ "@leafer-ui/draw": "1.9.6"
27
27
  },
28
28
  "devDependencies": {
29
- "@leafer/interface": "1.9.4",
30
- "@leafer-ui/interface": "1.9.4"
29
+ "@leafer/interface": "1.9.6",
30
+ "@leafer-ui/interface": "1.9.6"
31
31
  }
32
32
  }
package/src/Shadow.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { IBoundsData, ILeaferCanvas, IOffsetBoundsData } from '@leafer/interface'
2
2
  import { BoundsHelper, LeafHelper, Platform } from '@leafer/core'
3
3
 
4
- import { IUI, ICachedShape } from '@leafer-ui/interface'
5
- import { ColorConvert } from '@leafer-ui/draw'
4
+ import { IUI, ICachedShape, ILeafShadowEffect } from '@leafer-ui/interface'
5
+ import { ColorConvert, Effect } from '@leafer-ui/draw'
6
6
 
7
7
 
8
8
  const { copy, toOffsetOutBounds } = BoundsHelper
@@ -52,7 +52,8 @@ export function shadow(ui: IUI, current: ILeaferCanvas, shape: ICachedShape): vo
52
52
  worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out')
53
53
  }
54
54
 
55
- LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode)
55
+ if (Effect.isTransformShadow(item)) Effect.renderTransformShadow(ui, current, other, copyBounds, item)
56
+ else LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode)
56
57
 
57
58
  if (end && index < end) other.clearWorld(copyBounds)
58
59
  })
@@ -62,6 +63,13 @@ export function shadow(ui: IUI, current: ILeaferCanvas, shape: ICachedShape): vo
62
63
  }
63
64
 
64
65
 
66
+ export function getShadowSpread(_ui: IUI, shadow: ILeafShadowEffect[]): number {
67
+ let width = 0
68
+ shadow.forEach(item => width = Math.max(width, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread > 0 ? item.spread : 0) + item.blur * 1.5))
69
+ return width
70
+ }
71
+
72
+
65
73
  export function drawWorldShadow(canvas: ILeaferCanvas, outBounds: IBoundsData, spreadScale: number, shape: ICachedShape): void {
66
74
 
67
75
  const { bounds, shapeBounds } = shape
package/src/index.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { IEffectModule } from '@leafer-ui/interface'
1
+ import { IEffectModule, ILeafShadowEffect } from '@leafer-ui/interface'
2
2
 
3
- import { shadow } from './Shadow'
3
+ import { shadow, getShadowSpread } from './Shadow'
4
4
  import { innerShadow } from './InnerShadow'
5
5
  import { blur } from './Blur'
6
6
  import { backgroundBlur } from './BackgroundBlur'
@@ -10,5 +10,9 @@ export const EffectModule: IEffectModule = {
10
10
  shadow,
11
11
  innerShadow,
12
12
  blur,
13
- backgroundBlur
13
+ backgroundBlur,
14
+
15
+ // @leafer-in/shadow will rewrite
16
+ getShadowSpread,
17
+ isTransformShadow(_shadow: ILeafShadowEffect): boolean { return undefined }
14
18
  }