@leafer-ui/paint 1.0.0-beta.4 → 1.0.0-beta.5
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/paint/conic.ts +5 -5
- package/src/paint/image.ts +16 -12
- package/src/paint/radial.ts +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/paint",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.5",
|
|
4
4
|
"description": "@leafer-ui/paint",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
"leaferjs"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@leafer/core": "1.0.0-beta.
|
|
23
|
-
"@leafer-ui/color": "1.0.0-beta.
|
|
22
|
+
"@leafer/core": "1.0.0-beta.5",
|
|
23
|
+
"@leafer-ui/color": "1.0.0-beta.5"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@leafer/interface": "1.0.0-beta.
|
|
27
|
-
"@leafer-ui/interface": "1.0.0-beta.
|
|
26
|
+
"@leafer/interface": "1.0.0-beta.5",
|
|
27
|
+
"@leafer-ui/interface": "1.0.0-beta.5"
|
|
28
28
|
}
|
|
29
29
|
}
|
package/src/paint/conic.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { applyStops } from './linear'
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
const { set, getAngle, getDistance } = PointHelper
|
|
10
|
-
const { get,
|
|
10
|
+
const { get, rotateOfOuter, scaleOfOuter } = MatrixHelper
|
|
11
11
|
|
|
12
12
|
const defaultFrom = { x: 0.5, y: 0.5 }
|
|
13
13
|
const defaultTo = { x: 0.5, y: 1 }
|
|
@@ -31,11 +31,11 @@ export function conicGradient(paint: IGradientPaint, box: IBoundsData): ILeafPai
|
|
|
31
31
|
const angle = getAngle(realFrom, realTo)
|
|
32
32
|
|
|
33
33
|
if (Platform.conicGradientRotate90) {
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
scaleOfOuter(transform, realFrom, width / height * (stretch || 1), 1)
|
|
35
|
+
rotateOfOuter(transform, realFrom, angle + 90)
|
|
36
36
|
} else {
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
scaleOfOuter(transform, realFrom, 1, width / height * (stretch || 1))
|
|
38
|
+
rotateOfOuter(transform, realFrom, angle)
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
const style = Platform.conicGradientSupport ? Platform.canvas.createConicGradient(0, realFrom.x, realFrom.y) : Platform.canvas.createRadialGradient(realFrom.x, realFrom.y, 0, realFrom.x, realFrom.y, getDistance(realFrom, realTo))
|
package/src/paint/image.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Platform, MatrixHelper, ImageEvent } from '@leafer/core'
|
|
|
4
4
|
import { IUI, IImagePaint, ILeafPaint, IMatrixData, IImagePaintMode, IPointData } from '@leafer-ui/interface'
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
const { get,
|
|
7
|
+
const { get, rotateOfOuter, translate, scaleOfOuter, scale: scaleHelper, rotate } = MatrixHelper
|
|
8
8
|
|
|
9
9
|
export function image(ui: IUI, attrName: string, paint: IImagePaint, box: IBoundsData): ILeafPaint {
|
|
10
10
|
let { type, blendMode } = paint
|
|
@@ -14,7 +14,8 @@ export function image(ui: IUI, attrName: string, paint: IImagePaint, box: IBound
|
|
|
14
14
|
style: 'rgba(255,255,255,0)'
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
const
|
|
17
|
+
const { imageManager } = ui.leafer
|
|
18
|
+
const image = imageManager.get(paint)
|
|
18
19
|
|
|
19
20
|
if (image.ready) {
|
|
20
21
|
|
|
@@ -47,14 +48,17 @@ export function image(ui: IUI, attrName: string, paint: IImagePaint, box: IBound
|
|
|
47
48
|
|
|
48
49
|
} else {
|
|
49
50
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
imageManager.load(image,
|
|
52
|
+
() => {
|
|
53
|
+
if (!ui.__.__getInput('width')) ui.width = image.width
|
|
54
|
+
if (!ui.__.__getInput('height')) ui.height = image.height
|
|
55
|
+
ui.forceUpdate('width')
|
|
56
|
+
ui.emitEvent(new ImageEvent(ImageEvent.LOADED, ui, image, attrName, paint))
|
|
57
|
+
},
|
|
58
|
+
(error) => {
|
|
59
|
+
ui.emitEvent(new ImageEvent(ImageEvent.ERROR, ui, image, attrName, paint, error))
|
|
60
|
+
}
|
|
61
|
+
)
|
|
58
62
|
|
|
59
63
|
}
|
|
60
64
|
|
|
@@ -71,7 +75,7 @@ function getFillOrFitTransform(mode: IImagePaintMode, box: IBoundsData, width: n
|
|
|
71
75
|
const y = box.y + (box.height - height * scale) / 2
|
|
72
76
|
translate(transform, x, y)
|
|
73
77
|
scaleHelper(transform, scale)
|
|
74
|
-
if (rotation)
|
|
78
|
+
if (rotation) rotateOfOuter(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation)
|
|
75
79
|
return transform
|
|
76
80
|
}
|
|
77
81
|
|
|
@@ -102,7 +106,7 @@ function getRepeatTransform(box: IBoundsData, width: number, height: number, sca
|
|
|
102
106
|
}
|
|
103
107
|
}
|
|
104
108
|
translate(transform, box.x, box.y)
|
|
105
|
-
if (scale)
|
|
109
|
+
if (scale) scaleOfOuter(transform, box, scale)
|
|
106
110
|
return transform
|
|
107
111
|
}
|
|
108
112
|
|
package/src/paint/radial.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { applyStops } from './linear'
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
const { set, getAngle, getDistance } = PointHelper
|
|
10
|
-
const { get,
|
|
10
|
+
const { get, rotateOfOuter, scaleOfOuter } = MatrixHelper
|
|
11
11
|
|
|
12
12
|
const defaultFrom = { x: 0.5, y: 0.5 }
|
|
13
13
|
const defaultTo = { x: 0.5, y: 1 }
|
|
@@ -30,8 +30,8 @@ export function radialGradient(paint: IGradientPaint, box: IBoundsData): ILeafPa
|
|
|
30
30
|
|
|
31
31
|
if (width !== height || stretch) {
|
|
32
32
|
transform = get()
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
scaleOfOuter(transform, realFrom, width / height * (stretch || 1), 1)
|
|
34
|
+
rotateOfOuter(transform, realFrom, getAngle(realFrom, realTo) + 90)
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
const style = Platform.canvas.createRadialGradient(realFrom.x, realFrom.y, 0, realFrom.x, realFrom.y, getDistance(realFrom, realTo))
|