@leafer-ui/paint 1.10.0 → 1.10.1
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/Compute.ts +26 -21
- package/src/Fill.ts +12 -10
- package/src/StrokeText.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/paint",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.1",
|
|
4
4
|
"description": "@leafer-ui/paint",
|
|
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.10.
|
|
26
|
-
"@leafer-ui/draw": "1.10.
|
|
25
|
+
"@leafer/core": "1.10.1",
|
|
26
|
+
"@leafer-ui/draw": "1.10.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@leafer/interface": "1.10.
|
|
30
|
-
"@leafer-ui/interface": "1.10.
|
|
29
|
+
"@leafer/interface": "1.10.1",
|
|
30
|
+
"@leafer-ui/interface": "1.10.1"
|
|
31
31
|
}
|
|
32
32
|
}
|
package/src/Compute.ts
CHANGED
|
@@ -32,61 +32,66 @@ export function compute(attrName: IPaintAttr, ui: IUI): void {
|
|
|
32
32
|
(data as IObject)['_' + attrName] = leafPaints.length ? leafPaints : undefined
|
|
33
33
|
|
|
34
34
|
if (leafPaints.length) {
|
|
35
|
+
|
|
35
36
|
if (leafPaints.every(item => item.isTransparent)) {
|
|
36
37
|
if (leafPaints.some(item => item.image)) isAlphaPixel = true
|
|
37
38
|
isTransparent = true
|
|
38
39
|
}
|
|
39
|
-
}
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
if (attrName === 'fill') {
|
|
42
|
+
stintSet(data, '__isAlphaPixelFill', isAlphaPixel)
|
|
43
|
+
stintSet(data, '__isTransparentFill', isTransparent)
|
|
44
|
+
} else {
|
|
45
|
+
stintSet(data, '__isAlphaPixelStroke', isAlphaPixel)
|
|
46
|
+
stintSet(data, '__isTransparentStroke', isTransparent)
|
|
47
|
+
stintSet(data, '__hasMultiStrokeStyle', maxChildStrokeWidth)
|
|
48
|
+
}
|
|
49
|
+
|
|
44
50
|
} else {
|
|
45
|
-
|
|
46
|
-
stintSet(data, '__isTransparentStroke', isTransparent)
|
|
47
|
-
stintSet(data, '__hasMultiStrokeStyle', maxChildStrokeWidth)
|
|
51
|
+
data.__removePaint(attrName, false)
|
|
48
52
|
}
|
|
53
|
+
|
|
49
54
|
}
|
|
50
55
|
|
|
51
56
|
|
|
52
57
|
function getLeafPaint(attrName: string, paint: IPaint, ui: IUI): ILeafPaint {
|
|
53
58
|
if (!isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined
|
|
54
59
|
|
|
55
|
-
let
|
|
60
|
+
let leafPaint: ILeafPaint
|
|
56
61
|
const { boxBounds } = ui.__layout
|
|
57
62
|
|
|
58
63
|
switch (paint.type) {
|
|
59
64
|
case 'image':
|
|
60
|
-
|
|
65
|
+
leafPaint = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url])
|
|
61
66
|
break
|
|
62
67
|
case 'linear':
|
|
63
|
-
|
|
68
|
+
leafPaint = PaintGradient.linearGradient(paint, boxBounds)
|
|
64
69
|
break
|
|
65
70
|
case 'radial':
|
|
66
|
-
|
|
71
|
+
leafPaint = PaintGradient.radialGradient(paint, boxBounds)
|
|
67
72
|
break
|
|
68
73
|
case 'angular':
|
|
69
|
-
|
|
74
|
+
leafPaint = PaintGradient.conicGradient(paint, boxBounds)
|
|
70
75
|
break
|
|
71
76
|
case 'solid':
|
|
72
77
|
const { type, color, opacity } = paint
|
|
73
|
-
|
|
78
|
+
leafPaint = { type, style: ColorConvert.string(color, opacity) }
|
|
74
79
|
break
|
|
75
80
|
default:
|
|
76
|
-
if (!isUndefined((paint as IRGB).r))
|
|
81
|
+
if (!isUndefined((paint as IRGB).r)) leafPaint = { type: 'solid', style: ColorConvert.string(paint) }
|
|
77
82
|
}
|
|
78
83
|
|
|
79
|
-
if (
|
|
84
|
+
if (leafPaint) {
|
|
85
|
+
// 原始paint
|
|
86
|
+
leafPaint.originPaint = paint
|
|
87
|
+
|
|
80
88
|
// 描边样式
|
|
81
|
-
if (isString(
|
|
89
|
+
if (isString(leafPaint.style) && hasTransparent(leafPaint.style)) leafPaint.isTransparent = true
|
|
82
90
|
if (paint.style) {
|
|
83
91
|
if (paint.style.strokeWidth === 0) return undefined
|
|
84
|
-
|
|
92
|
+
leafPaint.strokeStyle = paint.style as IStrokeComputedStyle
|
|
85
93
|
}
|
|
86
|
-
|
|
87
|
-
if (paint.editing) data.editing = paint.editing
|
|
88
|
-
if (paint.blendMode) data.blendMode = paint.blendMode
|
|
89
94
|
}
|
|
90
95
|
|
|
91
|
-
return
|
|
96
|
+
return leafPaint
|
|
92
97
|
}
|
package/src/Fill.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ILeaferCanvas, IRenderOptions } from '@leafer/interface'
|
|
2
2
|
|
|
3
|
-
import { ILeafPaint, IUI } from '@leafer-ui/interface'
|
|
3
|
+
import { IImagePaint, ILeafPaint, IUI } from '@leafer-ui/interface'
|
|
4
4
|
import { PaintImage, Paint } from "@leafer-ui/draw"
|
|
5
5
|
|
|
6
6
|
|
|
@@ -11,16 +11,18 @@ export function fill(fill: string, ui: IUI, canvas: ILeaferCanvas, renderOptions
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
export function fills(fills: ILeafPaint[], ui: IUI, canvas: ILeaferCanvas, renderOptions: IRenderOptions): void {
|
|
14
|
-
let item: ILeafPaint
|
|
14
|
+
let item: ILeafPaint, originPaint: IImagePaint, countImage: number
|
|
15
15
|
for (let i = 0, len = fills.length; i < len; i++) {
|
|
16
|
-
item = fills[i]
|
|
16
|
+
item = fills[i], originPaint = item.originPaint as IImagePaint
|
|
17
17
|
|
|
18
18
|
if (item.image) {
|
|
19
19
|
|
|
20
|
+
countImage ? countImage++ : countImage = 1
|
|
21
|
+
|
|
20
22
|
if (PaintImage.checkImage(item, !ui.__.__font, ui, canvas, renderOptions)) continue
|
|
21
23
|
|
|
22
24
|
if (!item.style) {
|
|
23
|
-
if (
|
|
25
|
+
if (countImage === 1 && item.image.isPlacehold) ui.drawImagePlaceholder(item, canvas, renderOptions) // 图片加载中或加载失败
|
|
24
26
|
continue
|
|
25
27
|
}
|
|
26
28
|
|
|
@@ -28,23 +30,23 @@ export function fills(fills: ILeafPaint[], ui: IUI, canvas: ILeaferCanvas, rende
|
|
|
28
30
|
|
|
29
31
|
canvas.fillStyle = item.style
|
|
30
32
|
|
|
31
|
-
if (item.transform ||
|
|
33
|
+
if (item.transform || originPaint.scaleFixed) {
|
|
32
34
|
|
|
33
35
|
canvas.save()
|
|
34
36
|
if (item.transform) canvas.transform(item.transform)
|
|
35
|
-
if (
|
|
37
|
+
if (originPaint.scaleFixed) {
|
|
36
38
|
const { scaleX, scaleY } = ui.getRenderScaleData(true)
|
|
37
|
-
if (
|
|
39
|
+
if (originPaint.scaleFixed === true || (originPaint.scaleFixed === 'zoom-in' && scaleX > 1 && scaleY > 1)) canvas.scale(1 / scaleX, 1 / scaleY)
|
|
38
40
|
}
|
|
39
|
-
if (
|
|
41
|
+
if (originPaint.blendMode) canvas.blendMode = originPaint.blendMode
|
|
40
42
|
fillPathOrText(ui, canvas, renderOptions)
|
|
41
43
|
canvas.restore()
|
|
42
44
|
|
|
43
45
|
} else {
|
|
44
46
|
|
|
45
|
-
if (
|
|
47
|
+
if (originPaint.blendMode) {
|
|
46
48
|
|
|
47
|
-
canvas.saveBlendMode(
|
|
49
|
+
canvas.saveBlendMode(originPaint.blendMode)
|
|
48
50
|
fillPathOrText(ui, canvas, renderOptions)
|
|
49
51
|
canvas.restoreBlendMode()
|
|
50
52
|
|
package/src/StrokeText.ts
CHANGED
|
@@ -79,8 +79,8 @@ export function drawStrokesStyle(strokes: ILeafStrokePaint[], strokeWidthScale:
|
|
|
79
79
|
strokeStyle ? canvas.setStroke(item.style, data.__getRealStrokeWidth(strokeStyle) * strokeWidthScale, data, strokeStyle) : canvas.setStroke(item.style, data.__strokeWidth * strokeWidthScale, data)
|
|
80
80
|
} else canvas.strokeStyle = item.style
|
|
81
81
|
|
|
82
|
-
if (item.blendMode) {
|
|
83
|
-
canvas.saveBlendMode(item.blendMode)
|
|
82
|
+
if (item.originPaint.blendMode) {
|
|
83
|
+
canvas.saveBlendMode(item.originPaint.blendMode)
|
|
84
84
|
isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke()
|
|
85
85
|
canvas.restoreBlendMode()
|
|
86
86
|
} else {
|