@leafer-ui/image 1.9.9 → 1.9.11
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/data.ts +11 -10
- package/src/index.ts +3 -1
- package/src/mode.ts +13 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/image",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.11",
|
|
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.9.
|
|
26
|
-
"@leafer-ui/draw": "1.9.
|
|
25
|
+
"@leafer/core": "1.9.11",
|
|
26
|
+
"@leafer-ui/draw": "1.9.11"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@leafer/interface": "1.9.
|
|
30
|
-
"@leafer-ui/interface": "1.9.
|
|
29
|
+
"@leafer/interface": "1.9.11",
|
|
30
|
+
"@leafer-ui/interface": "1.9.11"
|
|
31
31
|
}
|
|
32
32
|
}
|
package/src/data.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { MatrixHelper, MathHelper, Bounds, AlignHelper, BoundsHelper, PointHelpe
|
|
|
3
3
|
|
|
4
4
|
import { IImagePaint, ILeafPaint, ILeafPaintPatternData } from '@leafer-ui/interface'
|
|
5
5
|
|
|
6
|
-
import { clipMode, fillOrFitMode, repeatMode } from './mode'
|
|
6
|
+
import { clipMode, fillOrFitMode, repeatMode, stretchMode } from './mode'
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
const { get, translate } = MatrixHelper
|
|
@@ -56,7 +56,10 @@ export function getPatternData(paint: IImagePaint, box: IBoundsData, image: ILea
|
|
|
56
56
|
|
|
57
57
|
switch (mode) {
|
|
58
58
|
case 'stretch':
|
|
59
|
-
if (!sameBox)
|
|
59
|
+
if (!sameBox) {
|
|
60
|
+
scaleX = box.width / width, scaleY = box.height / height
|
|
61
|
+
stretchMode(data, box, scaleX, scaleY)
|
|
62
|
+
}
|
|
60
63
|
break
|
|
61
64
|
case 'normal':
|
|
62
65
|
case 'clip':
|
|
@@ -64,7 +67,7 @@ export function getPatternData(paint: IImagePaint, box: IBoundsData, image: ILea
|
|
|
64
67
|
let clipScaleX: number, clipScaleY: number
|
|
65
68
|
if (clipSize) clipScaleX = box.width / clipSize.width, clipScaleY = box.height / clipSize.height
|
|
66
69
|
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY)
|
|
67
|
-
if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX :
|
|
70
|
+
if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : clipScaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY
|
|
68
71
|
}
|
|
69
72
|
break
|
|
70
73
|
case 'repeat':
|
|
@@ -80,19 +83,17 @@ export function getPatternData(paint: IImagePaint, box: IBoundsData, image: ILea
|
|
|
80
83
|
}
|
|
81
84
|
|
|
82
85
|
if (!data.transform) {
|
|
83
|
-
if (box.x || box.y)
|
|
84
|
-
data.transform = get()
|
|
85
|
-
translate(data.transform, box.x, box.y)
|
|
86
|
-
}
|
|
86
|
+
if (box.x || box.y) translate(data.transform = get(), box.x, box.y)
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
|
|
89
|
+
data.width = width
|
|
90
|
+
data.height = height
|
|
91
|
+
|
|
92
|
+
if (scaleX) {
|
|
90
93
|
data.scaleX = scaleX
|
|
91
94
|
data.scaleY = scaleY
|
|
92
95
|
}
|
|
93
96
|
|
|
94
|
-
data.width = width
|
|
95
|
-
data.height = height
|
|
96
97
|
if (opacity) data.opacity = opacity
|
|
97
98
|
if (filters) data.filters = filters
|
|
98
99
|
if (repeat) data.repeat = isString(repeat) ? (repeat === 'x' ? 'repeat-x' : 'repeat-y') : 'repeat'
|
package/src/index.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { IPaintImageModule } from '@leafer-ui/interface'
|
|
|
2
2
|
|
|
3
3
|
import { image } from './image'
|
|
4
4
|
import { createData, getPatternData } from './data'
|
|
5
|
-
import { fillOrFitMode, clipMode, repeatMode } from './mode'
|
|
5
|
+
import { fillOrFitMode, clipMode, repeatMode, stretchMode } from './mode'
|
|
6
6
|
import { createPattern } from './pattern'
|
|
7
7
|
import { checkImage } from './check'
|
|
8
8
|
import { recycleImage } from './recycle'
|
|
@@ -16,6 +16,8 @@ export const PaintImageModule: IPaintImageModule = {
|
|
|
16
16
|
|
|
17
17
|
createData,
|
|
18
18
|
getPatternData,
|
|
19
|
+
|
|
20
|
+
stretchMode,
|
|
19
21
|
fillOrFitMode,
|
|
20
22
|
clipMode,
|
|
21
23
|
repeatMode
|
package/src/mode.ts
CHANGED
|
@@ -5,7 +5,14 @@ import { ILeafPaintPatternData } from '@leafer-ui/interface'
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
let origin = {} as IPointData, tempMatrix = getMatrixData()
|
|
8
|
-
const { get, rotateOfOuter, translate, scaleOfOuter, multiplyParent, scale: scaleHelper, rotate, skew: skewHelper } = MatrixHelper
|
|
8
|
+
const { get, set, rotateOfOuter, translate, scaleOfOuter, multiplyParent, scale: scaleHelper, rotate, skew: skewHelper } = MatrixHelper
|
|
9
|
+
|
|
10
|
+
export function stretchMode(data: ILeafPaintPatternData, box: IBoundsData, scaleX: number, scaleY: number): void {
|
|
11
|
+
const transform: IMatrixData = get()
|
|
12
|
+
translate(transform, box.x, box.y)
|
|
13
|
+
if (scaleX) scaleHelper(transform, scaleX, scaleY)
|
|
14
|
+
data.transform = transform
|
|
15
|
+
}
|
|
9
16
|
|
|
10
17
|
export function fillOrFitMode(data: ILeafPaintPatternData, box: IBoundsData, x: number, y: number, scaleX: number, scaleY: number, rotation: number): void {
|
|
11
18
|
const transform: IMatrixData = get()
|
|
@@ -19,8 +26,11 @@ export function clipMode(data: ILeafPaintPatternData, box: IBoundsData, x: numbe
|
|
|
19
26
|
const transform: IMatrixData = get()
|
|
20
27
|
layout(transform, box, x, y, scaleX, scaleY, rotation, skew)
|
|
21
28
|
if (clipScaleX) {
|
|
22
|
-
|
|
23
|
-
|
|
29
|
+
if (rotation || skew) {
|
|
30
|
+
set(tempMatrix)
|
|
31
|
+
scaleOfOuter(tempMatrix, box, clipScaleX, clipScaleY)
|
|
32
|
+
multiplyParent(transform, tempMatrix)
|
|
33
|
+
} else scaleOfOuter(transform, box, clipScaleX, clipScaleY)
|
|
24
34
|
}
|
|
25
35
|
data.transform = transform
|
|
26
36
|
}
|