@leafer-ui/image 1.0.2 → 1.0.3
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/check.ts +6 -5
- package/src/data.ts +3 -2
- package/src/pattern.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/image",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "@leafer-ui/image",
|
|
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.0.
|
|
26
|
-
"@leafer-ui/draw": "1.0.
|
|
25
|
+
"@leafer/core": "1.0.3",
|
|
26
|
+
"@leafer-ui/draw": "1.0.3"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@leafer/interface": "1.0.
|
|
30
|
-
"@leafer-ui/interface": "1.0.
|
|
29
|
+
"@leafer/interface": "1.0.3",
|
|
30
|
+
"@leafer-ui/interface": "1.0.3"
|
|
31
31
|
}
|
|
32
32
|
}
|
package/src/check.ts
CHANGED
|
@@ -11,8 +11,9 @@ const { abs } = Math
|
|
|
11
11
|
|
|
12
12
|
export function checkImage(ui: IUI, canvas: ILeaferCanvas, paint: ILeafPaint, allowPaint?: boolean): boolean {
|
|
13
13
|
const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld
|
|
14
|
+
const { pixelRatio } = canvas
|
|
14
15
|
|
|
15
|
-
if (!paint.data || (paint.patternId === scaleX + '-' + scaleY && !Export.running)) {
|
|
16
|
+
if (!paint.data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !Export.running)) {
|
|
16
17
|
return false
|
|
17
18
|
} else {
|
|
18
19
|
|
|
@@ -21,8 +22,8 @@ export function checkImage(ui: IUI, canvas: ILeaferCanvas, paint: ILeafPaint, al
|
|
|
21
22
|
if (allowPaint) {
|
|
22
23
|
if (!data.repeat) {
|
|
23
24
|
let { width, height } = data
|
|
24
|
-
width *= abs(scaleX) *
|
|
25
|
-
height *= abs(scaleY) *
|
|
25
|
+
width *= abs(scaleX) * pixelRatio
|
|
26
|
+
height *= abs(scaleY) * pixelRatio
|
|
26
27
|
if (data.scaleX) {
|
|
27
28
|
width *= data.scaleX
|
|
28
29
|
height *= data.scaleY
|
|
@@ -44,12 +45,12 @@ export function checkImage(ui: IUI, canvas: ILeaferCanvas, paint: ILeafPaint, al
|
|
|
44
45
|
return true
|
|
45
46
|
} else {
|
|
46
47
|
if (!paint.style || paint.sync || Export.running) {
|
|
47
|
-
createPattern(ui, paint,
|
|
48
|
+
createPattern(ui, paint, pixelRatio)
|
|
48
49
|
} else {
|
|
49
50
|
if (!paint.patternTask) {
|
|
50
51
|
paint.patternTask = ImageManager.patternTasker.add(async () => {
|
|
51
52
|
paint.patternTask = null
|
|
52
|
-
if (canvas.bounds.hit(ui.__nowWorld)) createPattern(ui, paint,
|
|
53
|
+
if (canvas.bounds.hit(ui.__nowWorld)) createPattern(ui, paint, pixelRatio)
|
|
53
54
|
ui.forceUpdate('surface')
|
|
54
55
|
}, 300)
|
|
55
56
|
}
|
package/src/data.ts
CHANGED
|
@@ -21,6 +21,7 @@ export function createData(leafPaint: ILeafPaint, image: ILeaferImage, paint: II
|
|
|
21
21
|
export function getPatternData(paint: IImagePaint, box: IBoundsData, image: ILeaferImage): ILeafPaintPatternData {
|
|
22
22
|
let { width, height } = image
|
|
23
23
|
if (paint.padding) box = tempBox.set(box).shrink(paint.padding)
|
|
24
|
+
if (paint.mode === 'strench' as string) paint.mode = 'stretch' // 兼容代码,后续可移除
|
|
24
25
|
|
|
25
26
|
const { opacity, mode, align, offset, scale, size, rotation, repeat } = paint
|
|
26
27
|
const sameBox = box.width === width && box.height === height
|
|
@@ -53,7 +54,7 @@ export function getPatternData(paint: IImagePaint, box: IBoundsData, image: ILea
|
|
|
53
54
|
if (offset) x += offset.x, y += offset.y
|
|
54
55
|
|
|
55
56
|
switch (mode) {
|
|
56
|
-
case '
|
|
57
|
+
case 'stretch':
|
|
57
58
|
if (!sameBox) width = box.width, height = box.height
|
|
58
59
|
break
|
|
59
60
|
case 'normal':
|
|
@@ -77,7 +78,7 @@ export function getPatternData(paint: IImagePaint, box: IBoundsData, image: ILea
|
|
|
77
78
|
}
|
|
78
79
|
}
|
|
79
80
|
|
|
80
|
-
if (scaleX && mode !== '
|
|
81
|
+
if (scaleX && mode !== 'stretch') {
|
|
81
82
|
data.scaleX = scaleX
|
|
82
83
|
data.scaleY = scaleY
|
|
83
84
|
}
|
package/src/pattern.ts
CHANGED
|
@@ -10,7 +10,7 @@ export function createPattern(ui: IUI, paint: ILeafPaint, pixelRatio: number): b
|
|
|
10
10
|
|
|
11
11
|
let { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld
|
|
12
12
|
|
|
13
|
-
const id = scaleX + '-' + scaleY
|
|
13
|
+
const id = scaleX + '-' + scaleY + '-' + pixelRatio
|
|
14
14
|
|
|
15
15
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
16
16
|
|