@leafer-ui/effect 1.0.0-beta.9 → 1.0.0-rc.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.
- package/package.json +14 -4
- package/src/BackgroundBlur.ts +6 -0
- package/src/InnerShadow.ts +13 -9
- package/src/Shadow.ts +14 -10
- package/src/index.ts +14 -3
- package/types/index.d.ts +5 -0
package/package.json
CHANGED
|
@@ -1,21 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/effect",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-rc.11",
|
|
4
4
|
"description": "@leafer-ui/effect",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "src/index.ts",
|
|
8
|
+
"types": "types/index.d.ts",
|
|
8
9
|
"files": [
|
|
9
|
-
"src"
|
|
10
|
+
"src",
|
|
11
|
+
"types",
|
|
12
|
+
"dist"
|
|
10
13
|
],
|
|
11
14
|
"repository": {
|
|
12
15
|
"type": "git",
|
|
13
16
|
"url": "https://github.com/leaferjs/ui.git"
|
|
14
17
|
},
|
|
15
|
-
"homepage": "https://github.com/leaferjs/ui/tree/main/packages/effect",
|
|
18
|
+
"homepage": "https://github.com/leaferjs/ui/tree/main/packages/partner/effect",
|
|
16
19
|
"bugs": "https://github.com/leaferjs/ui/issues",
|
|
17
20
|
"keywords": [
|
|
18
21
|
"leafer-ui",
|
|
19
22
|
"leaferjs"
|
|
20
|
-
]
|
|
23
|
+
],
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@leafer/core": "1.0.0-rc.11"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@leafer/interface": "1.0.0-rc.11",
|
|
29
|
+
"@leafer-ui/interface": "1.0.0-rc.11"
|
|
30
|
+
}
|
|
21
31
|
}
|
package/src/InnerShadow.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IBoundsData, ILeaferCanvas, IMatrixWithBoundsData, IOffsetBoundsData
|
|
1
|
+
import { IBoundsData, ILeaferCanvas, IMatrixWithBoundsData, IOffsetBoundsData } from '@leafer/interface'
|
|
2
2
|
import { BoundsHelper } from '@leafer/core'
|
|
3
3
|
|
|
4
4
|
import { IUI, ICachedShape } from '@leafer-ui/interface'
|
|
@@ -9,11 +9,11 @@ import { drawWorldShadow } from './Shadow'
|
|
|
9
9
|
const { toOffsetOutBounds } = BoundsHelper
|
|
10
10
|
const offsetOutBounds = {} as IOffsetBoundsData
|
|
11
11
|
|
|
12
|
-
export function innerShadow(ui: IUI, current: ILeaferCanvas, shape: ICachedShape
|
|
12
|
+
export function innerShadow(ui: IUI, current: ILeaferCanvas, shape: ICachedShape): void {
|
|
13
13
|
|
|
14
14
|
let copyBounds: IBoundsData, spreadScale: number
|
|
15
15
|
|
|
16
|
-
const {
|
|
16
|
+
const { __nowWorld: nowWorld, __layout: __layout } = ui
|
|
17
17
|
const { innerShadow } = ui.__
|
|
18
18
|
const { worldCanvas, bounds, shapeBounds, scaleX, scaleY } = shape
|
|
19
19
|
|
|
@@ -35,9 +35,9 @@ export function innerShadow(ui: IUI, current: ILeaferCanvas, shape: ICachedShape
|
|
|
35
35
|
other.restore()
|
|
36
36
|
|
|
37
37
|
if (worldCanvas) {
|
|
38
|
-
other.copyWorld(other, bounds,
|
|
39
|
-
other.copyWorld(worldCanvas,
|
|
40
|
-
copyBounds =
|
|
38
|
+
other.copyWorld(other, bounds, nowWorld, 'copy')
|
|
39
|
+
other.copyWorld(worldCanvas, nowWorld, nowWorld, 'source-out')
|
|
40
|
+
copyBounds = nowWorld
|
|
41
41
|
} else {
|
|
42
42
|
other.copyWorld(shape.canvas, shapeBounds, bounds, 'source-out')
|
|
43
43
|
copyBounds = bounds
|
|
@@ -45,13 +45,17 @@ export function innerShadow(ui: IUI, current: ILeaferCanvas, shape: ICachedShape
|
|
|
45
45
|
|
|
46
46
|
other.fillWorld(copyBounds, item.color, 'source-in')
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
if (ui.__worldFlipped) {
|
|
49
|
+
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode)
|
|
50
|
+
} else {
|
|
51
|
+
current.copyWorldToInner(other, copyBounds as IMatrixWithBoundsData, __layout.renderBounds, item.blendMode)
|
|
52
|
+
}
|
|
49
53
|
|
|
50
|
-
if (end && index < end) other.
|
|
54
|
+
if (end && index < end) other.clearWorld(copyBounds, true)
|
|
51
55
|
|
|
52
56
|
})
|
|
53
57
|
|
|
54
|
-
other.recycle()
|
|
58
|
+
other.recycle(copyBounds)
|
|
55
59
|
|
|
56
60
|
}
|
|
57
61
|
|
package/src/Shadow.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IBoundsData, ILeaferCanvas, IMatrixWithBoundsData, IOffsetBoundsData
|
|
1
|
+
import { IBoundsData, ILeaferCanvas, IMatrixWithBoundsData, IOffsetBoundsData } from '@leafer/interface'
|
|
2
2
|
import { BoundsHelper, Platform } from '@leafer/core'
|
|
3
3
|
|
|
4
4
|
import { IUI, ICachedShape } from '@leafer-ui/interface'
|
|
@@ -8,11 +8,11 @@ const { copy, toOffsetOutBounds } = BoundsHelper
|
|
|
8
8
|
const tempBounds = {} as IBoundsData
|
|
9
9
|
const offsetOutBounds = {} as IOffsetBoundsData
|
|
10
10
|
|
|
11
|
-
export function shadow(ui: IUI, current: ILeaferCanvas, shape: ICachedShape
|
|
11
|
+
export function shadow(ui: IUI, current: ILeaferCanvas, shape: ICachedShape): void {
|
|
12
12
|
|
|
13
13
|
let copyBounds: IBoundsData, spreadScale: number
|
|
14
14
|
|
|
15
|
-
const {
|
|
15
|
+
const { __nowWorld: nowWorld, __layout } = ui
|
|
16
16
|
const { shadow } = ui.__
|
|
17
17
|
const { worldCanvas, bounds, shapeBounds, scaleX, scaleY } = shape
|
|
18
18
|
|
|
@@ -33,23 +33,27 @@ export function shadow(ui: IUI, current: ILeaferCanvas, shape: ICachedShape, _op
|
|
|
33
33
|
|
|
34
34
|
if (item.box) {
|
|
35
35
|
|
|
36
|
-
other.restore()
|
|
36
|
+
other.restore() // remove shadow style
|
|
37
37
|
other.save()
|
|
38
38
|
|
|
39
39
|
if (worldCanvas) {
|
|
40
|
-
other.copyWorld(other, bounds,
|
|
41
|
-
copyBounds =
|
|
40
|
+
other.copyWorld(other, bounds, nowWorld, 'copy')
|
|
41
|
+
copyBounds = nowWorld
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
worldCanvas ? other.copyWorld(worldCanvas,
|
|
44
|
+
worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out')
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
if (ui.__worldFlipped) {
|
|
48
|
+
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode)
|
|
49
|
+
} else {
|
|
50
|
+
current.copyWorldToInner(other, copyBounds as IMatrixWithBoundsData, __layout.renderBounds, item.blendMode)
|
|
51
|
+
}
|
|
48
52
|
|
|
49
|
-
if (end && index < end) other.
|
|
53
|
+
if (end && index < end) other.clearWorld(copyBounds, true)
|
|
50
54
|
})
|
|
51
55
|
|
|
52
|
-
other.recycle()
|
|
56
|
+
other.recycle(copyBounds)
|
|
53
57
|
|
|
54
58
|
}
|
|
55
59
|
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { IEffectModule } from '@leafer-ui/interface'
|
|
2
|
+
|
|
3
|
+
import { shadow } from './Shadow'
|
|
4
|
+
import { innerShadow } from './InnerShadow'
|
|
5
|
+
import { blur } from './Blur'
|
|
6
|
+
import { backgroundBlur } from './BackgroundBlur'
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export const EffectModule: IEffectModule = {
|
|
10
|
+
shadow,
|
|
11
|
+
innerShadow,
|
|
12
|
+
blur,
|
|
13
|
+
backgroundBlur
|
|
14
|
+
}
|