@leafer-ui/paint 1.0.0-beta.7 → 1.0.0-beta.8
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/Fill.ts +5 -4
- package/src/Shape.ts +8 -1
- package/src/Stroke.ts +2 -0
- package/src/paint/conic.ts +3 -6
- package/src/paint/image.ts +14 -13
- package/src/paint/linear.ts +3 -5
- package/src/paint/radial.ts +3 -6
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.8",
|
|
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.8",
|
|
23
|
+
"@leafer-ui/color": "1.0.0-beta.8"
|
|
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.8",
|
|
27
|
+
"@leafer-ui/interface": "1.0.0-beta.8"
|
|
28
28
|
}
|
|
29
29
|
}
|
package/src/Fill.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { drawText } from './FillText'
|
|
|
7
7
|
|
|
8
8
|
export function fill(ui: IUI, canvas: ILeaferCanvas, fill: string | object): void {
|
|
9
9
|
canvas.fillStyle = fill
|
|
10
|
-
ui.__.__font ? drawText(ui, canvas) : canvas.fill(ui.__.windingRule)
|
|
10
|
+
ui.__.__font ? drawText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill())
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export function fills(ui: IUI, canvas: ILeaferCanvas, fills: ILeafPaint[]): void {
|
|
@@ -25,21 +25,22 @@ export function fills(ui: IUI, canvas: ILeaferCanvas, fills: ILeafPaint[]): void
|
|
|
25
25
|
|
|
26
26
|
if (item.blendMode) canvas.blendMode = item.blendMode
|
|
27
27
|
|
|
28
|
-
__font ? drawText(ui, canvas) : canvas.fill(windingRule)
|
|
28
|
+
__font ? drawText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill())
|
|
29
29
|
|
|
30
30
|
canvas.restore()
|
|
31
31
|
} else {
|
|
32
32
|
if (item.blendMode) {
|
|
33
33
|
canvas.saveBlendMode(item.blendMode)
|
|
34
34
|
|
|
35
|
-
__font ? drawText(ui, canvas) : canvas.fill(windingRule)
|
|
35
|
+
__font ? drawText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill())
|
|
36
36
|
|
|
37
37
|
canvas.restoreBlendMode()
|
|
38
38
|
} else {
|
|
39
39
|
|
|
40
|
-
__font ? drawText(ui, canvas) : canvas.fill(windingRule)
|
|
40
|
+
__font ? drawText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill())
|
|
41
41
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
+
|
|
44
45
|
}
|
|
45
46
|
}
|
package/src/Shape.ts
CHANGED
|
@@ -37,7 +37,14 @@ export function shape(ui: IUI, current: ILeaferCanvas, options: IRenderOptions):
|
|
|
37
37
|
|
|
38
38
|
} else {
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
if (options.matrix) {
|
|
41
|
+
scaleX *= options.matrix.a
|
|
42
|
+
scaleY *= options.matrix.d
|
|
43
|
+
bounds = shapeBounds = getOuterOf(__world, options.matrix)
|
|
44
|
+
} else {
|
|
45
|
+
bounds = shapeBounds = __world
|
|
46
|
+
}
|
|
47
|
+
|
|
41
48
|
worldCanvas = canvas
|
|
42
49
|
}
|
|
43
50
|
|
package/src/Stroke.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { strokeText, strokesText } from './StrokeText'
|
|
|
8
8
|
export function stroke(ui: IUI, canvas: ILeaferCanvas, stroke: string | object): void {
|
|
9
9
|
const options = ui.__
|
|
10
10
|
const { strokeWidth, strokeAlign, __font } = options
|
|
11
|
+
if (!strokeWidth) return
|
|
11
12
|
|
|
12
13
|
if (__font) {
|
|
13
14
|
|
|
@@ -58,6 +59,7 @@ export function stroke(ui: IUI, canvas: ILeaferCanvas, stroke: string | object):
|
|
|
58
59
|
export function strokes(ui: IUI, canvas: ILeaferCanvas, strokes: ILeafPaint[]): void {
|
|
59
60
|
const options = ui.__
|
|
60
61
|
const { strokeWidth, strokeAlign, __font } = options
|
|
62
|
+
if (!strokeWidth) return
|
|
61
63
|
|
|
62
64
|
if (__font) {
|
|
63
65
|
|
package/src/paint/conic.ts
CHANGED
|
@@ -41,11 +41,8 @@ export function conicGradient(paint: IGradientPaint, box: IBoundsData): ILeafPai
|
|
|
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))
|
|
42
42
|
applyStops(style, paint.stops, opacity)
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
style,
|
|
48
|
-
transform
|
|
49
|
-
}
|
|
44
|
+
const data: ILeafPaint = { type, style, transform }
|
|
45
|
+
if (blendMode) data.blendMode = blendMode
|
|
46
|
+
return data
|
|
50
47
|
|
|
51
48
|
}
|
package/src/paint/image.ts
CHANGED
|
@@ -16,7 +16,7 @@ export function image(ui: IUI, attrName: string, paint: IImagePaint, box: IBound
|
|
|
16
16
|
|
|
17
17
|
if (image.ready) {
|
|
18
18
|
|
|
19
|
-
if (
|
|
19
|
+
if (hasSize(ui, attrName, image)) {
|
|
20
20
|
|
|
21
21
|
let transform: IMatrixData
|
|
22
22
|
let { opacity, mode, offset, scale, rotation } = paint
|
|
@@ -52,7 +52,7 @@ export function image(ui: IUI, attrName: string, paint: IImagePaint, box: IBound
|
|
|
52
52
|
imageManager.load(image,
|
|
53
53
|
() => {
|
|
54
54
|
if (ui.leafer) {
|
|
55
|
-
if (
|
|
55
|
+
if (hasSize(ui, attrName, image)) ui.forceUpdate('width')
|
|
56
56
|
ui.emitEvent(new ImageEvent(ImageEvent.LOADED, ui, image, attrName, paint))
|
|
57
57
|
}
|
|
58
58
|
},
|
|
@@ -66,20 +66,21 @@ export function image(ui: IUI, attrName: string, paint: IImagePaint, box: IBound
|
|
|
66
66
|
return leaferPaint
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
function
|
|
70
|
-
let auto: boolean
|
|
69
|
+
function hasSize(ui: IUI, attrName: string, image: ISizeData): boolean {
|
|
71
70
|
const { __: data } = ui
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
71
|
+
|
|
72
|
+
if (attrName === 'fill' && data) {
|
|
73
|
+
if (!data.__naturalWidth || !data.__naturalHeight) {
|
|
74
|
+
data.__naturalWidth = image.width
|
|
75
|
+
data.__naturalHeight = image.height
|
|
76
|
+
if (!data.__getInput('width') || !data.__getInput('height')) {
|
|
77
|
+
ui.forceUpdate('width')
|
|
78
|
+
return false
|
|
79
|
+
}
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
|
|
82
|
+
|
|
83
|
+
return true
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
function getFillOrFitTransform(mode: IImagePaintMode, box: IBoundsData, width: number, height: number, rotation: number): IMatrixData {
|
package/src/paint/linear.ts
CHANGED
|
@@ -18,11 +18,9 @@ export function linearGradient(paint: IGradientPaint, box: IBoundsData): ILeafPa
|
|
|
18
18
|
const style = Platform.canvas.createLinearGradient(box.x + from.x * box.width, box.y + from.y * box.height, box.x + to.x * box.width, box.y + to.y * box.height)
|
|
19
19
|
applyStops(style, paint.stops, opacity)
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
style
|
|
25
|
-
}
|
|
21
|
+
const data: ILeafPaint = { type, style }
|
|
22
|
+
if (blendMode) data.blendMode = blendMode
|
|
23
|
+
return data
|
|
26
24
|
|
|
27
25
|
}
|
|
28
26
|
|
package/src/paint/radial.ts
CHANGED
|
@@ -37,11 +37,8 @@ export function radialGradient(paint: IGradientPaint, box: IBoundsData): ILeafPa
|
|
|
37
37
|
const style = Platform.canvas.createRadialGradient(realFrom.x, realFrom.y, 0, realFrom.x, realFrom.y, getDistance(realFrom, realTo))
|
|
38
38
|
applyStops(style, paint.stops, opacity)
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
style,
|
|
44
|
-
transform
|
|
45
|
-
}
|
|
40
|
+
const data: ILeafPaint = { type, style, transform }
|
|
41
|
+
if (blendMode) data.blendMode = blendMode
|
|
42
|
+
return data
|
|
46
43
|
|
|
47
44
|
}
|