@leafer-ui/effect 1.0.0-rc.8 → 1.0.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 +5 -5
- package/src/BackgroundBlur.ts +6 -0
- package/src/Blur.ts +2 -2
- package/src/InnerShadow.ts +10 -10
- package/src/Shadow.ts +11 -11
- package/src/index.ts +14 -3
- package/types/index.d.ts +3 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/effect",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "@leafer-ui/effect",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,17 +15,17 @@
|
|
|
15
15
|
"type": "git",
|
|
16
16
|
"url": "https://github.com/leaferjs/ui.git"
|
|
17
17
|
},
|
|
18
|
-
"homepage": "https://github.com/leaferjs/ui/tree/main/packages/effect",
|
|
18
|
+
"homepage": "https://github.com/leaferjs/ui/tree/main/packages/partner/effect",
|
|
19
19
|
"bugs": "https://github.com/leaferjs/ui/issues",
|
|
20
20
|
"keywords": [
|
|
21
21
|
"leafer-ui",
|
|
22
22
|
"leaferjs"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@leafer/core": "1.0.0
|
|
25
|
+
"@leafer/core": "1.0.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@leafer/interface": "1.0.0
|
|
29
|
-
"@leafer-ui/interface": "1.0.0
|
|
28
|
+
"@leafer/interface": "1.0.0",
|
|
29
|
+
"@leafer-ui/interface": "1.0.0"
|
|
30
30
|
}
|
|
31
31
|
}
|
package/src/Blur.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { IUI } from '@leafer-ui/interface'
|
|
|
4
4
|
|
|
5
5
|
export function blur(ui: IUI, current: ILeaferCanvas, origin: ILeaferCanvas): void {
|
|
6
6
|
const { blur } = ui.__
|
|
7
|
-
origin.setWorldBlur(blur * ui.
|
|
8
|
-
origin.copyWorldToInner(current, ui.
|
|
7
|
+
origin.setWorldBlur(blur * ui.__nowWorld.a)
|
|
8
|
+
origin.copyWorldToInner(current, ui.__nowWorld, ui.__layout.renderBounds)
|
|
9
9
|
origin.filter = 'none'
|
|
10
10
|
}
|
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,17 +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
|
-
if (ui.__worldFlipped
|
|
49
|
-
current.copyWorldByReset(other, copyBounds,
|
|
48
|
+
if (ui.__worldFlipped) {
|
|
49
|
+
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode)
|
|
50
50
|
} else {
|
|
51
51
|
current.copyWorldToInner(other, copyBounds as IMatrixWithBoundsData, __layout.renderBounds, item.blendMode)
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
if (end && index < end) other.
|
|
54
|
+
if (end && index < end) other.clearWorld(copyBounds, true)
|
|
55
55
|
|
|
56
56
|
})
|
|
57
57
|
|
|
58
|
-
other.recycle()
|
|
58
|
+
other.recycle(copyBounds)
|
|
59
59
|
|
|
60
60
|
}
|
|
61
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,27 +33,27 @@ export function shadow(ui: IUI, current: ILeaferCanvas, shape: ICachedShape, ren
|
|
|
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
|
-
if (ui.__worldFlipped
|
|
48
|
-
current.copyWorldByReset(other, copyBounds,
|
|
47
|
+
if (ui.__worldFlipped) {
|
|
48
|
+
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode)
|
|
49
49
|
} else {
|
|
50
50
|
current.copyWorldToInner(other, copyBounds as IMatrixWithBoundsData, __layout.renderBounds, item.blendMode)
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
if (end && index < end) other.
|
|
53
|
+
if (end && index < end) other.clearWorld(copyBounds, true)
|
|
54
54
|
})
|
|
55
55
|
|
|
56
|
-
other.recycle()
|
|
56
|
+
other.recycle(copyBounds)
|
|
57
57
|
|
|
58
58
|
}
|
|
59
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
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { IUI, ICachedShape } from '@leafer-ui/interface';
|
|
1
|
+
import { IEffectModule } from '@leafer-ui/interface';
|
|
3
2
|
|
|
4
|
-
declare
|
|
3
|
+
declare const EffectModule: IEffectModule;
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
declare function blur(ui: IUI, current: ILeaferCanvas, origin: ILeaferCanvas): void;
|
|
9
|
-
|
|
10
|
-
export { blur, innerShadow, shadow };
|
|
5
|
+
export { EffectModule };
|