@leafer-ui/image 1.0.0-rc.22 → 1.0.0-rc.24
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 +6 -6
- package/src/mode.ts +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/image",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.24",
|
|
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.0-rc.
|
|
26
|
-
"@leafer-ui/draw": "1.0.0-rc.
|
|
25
|
+
"@leafer/core": "1.0.0-rc.24",
|
|
26
|
+
"@leafer-ui/draw": "1.0.0-rc.24"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@leafer/interface": "1.0.0-rc.
|
|
30
|
-
"@leafer-ui/interface": "1.0.0-rc.
|
|
29
|
+
"@leafer/interface": "1.0.0-rc.24",
|
|
30
|
+
"@leafer-ui/interface": "1.0.0-rc.24"
|
|
31
31
|
}
|
|
32
32
|
}
|
package/src/data.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IBoundsData, ILeaferImage, IPointData } from '@leafer/interface'
|
|
2
|
-
import { MatrixHelper, Bounds,
|
|
2
|
+
import { MatrixHelper, Bounds, AlignHelper } from '@leafer/core'
|
|
3
3
|
|
|
4
4
|
import { IImagePaint, ILeafPaint, ILeafPaintPatternData } from '@leafer-ui/interface'
|
|
5
5
|
|
|
@@ -14,12 +14,12 @@ export function createData(leafPaint: ILeafPaint, image: ILeaferImage, paint: II
|
|
|
14
14
|
let { width, height } = image
|
|
15
15
|
if (paint.padding) box = tempBox.set(box).shrink(paint.padding)
|
|
16
16
|
|
|
17
|
-
const { opacity, mode,
|
|
17
|
+
const { opacity, mode, align, offset, scale, size, rotation, blendMode, repeat } = paint
|
|
18
18
|
const sameBox = box.width === width && box.height === height
|
|
19
19
|
if (blendMode) leafPaint.blendMode = blendMode
|
|
20
20
|
|
|
21
21
|
const data: ILeafPaintPatternData = leafPaint.data = { mode }
|
|
22
|
-
const swapSize =
|
|
22
|
+
const swapSize = align !== 'center' && (rotation || 0) % 180 === 90
|
|
23
23
|
const swapWidth = swapSize ? height : width, swapHeight = swapSize ? width : height
|
|
24
24
|
|
|
25
25
|
let x = 0, y = 0, scaleX: number, scaleY: number
|
|
@@ -38,10 +38,10 @@ export function createData(leafPaint: ILeafPaint, image: ILeaferImage, paint: II
|
|
|
38
38
|
scaleY = typeof scale === 'number' ? scale : scale.y
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
if (
|
|
41
|
+
if (align) {
|
|
42
42
|
const imageBounds = { x, y, width: swapWidth, height: swapHeight }
|
|
43
43
|
if (scaleX) imageBounds.width *= scaleX, imageBounds.height *= scaleY
|
|
44
|
-
|
|
44
|
+
AlignHelper.toPoint(align, imageBounds, box, tempPoint, true)
|
|
45
45
|
x += tempPoint.x, y += tempPoint.y
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -56,7 +56,7 @@ export function createData(leafPaint: ILeafPaint, image: ILeaferImage, paint: II
|
|
|
56
56
|
if (x || y || scaleX || rotation) clipMode(data, box, x, y, scaleX, scaleY, rotation)
|
|
57
57
|
break
|
|
58
58
|
case 'repeat':
|
|
59
|
-
if (!sameBox || scaleX || rotation) repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation,
|
|
59
|
+
if (!sameBox || scaleX || rotation) repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align)
|
|
60
60
|
if (!repeat) data.repeat = 'repeat'
|
|
61
61
|
break
|
|
62
62
|
case 'fit':
|
package/src/mode.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IBoundsData, IPointData, IMatrixData,
|
|
1
|
+
import { IBoundsData, IPointData, IMatrixData, IAlign, } from '@leafer/interface'
|
|
2
2
|
import { MatrixHelper } from '@leafer/core'
|
|
3
3
|
|
|
4
4
|
import { ILeafPaintPatternData } from '@leafer-ui/interface'
|
|
@@ -25,10 +25,10 @@ export function clipMode(data: ILeafPaintPatternData, box: IBoundsData, x: numbe
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
export function repeatMode(data: ILeafPaintPatternData, box: IBoundsData, width: number, height: number, x: number, y: number, scaleX: number, scaleY: number, rotation: number,
|
|
28
|
+
export function repeatMode(data: ILeafPaintPatternData, box: IBoundsData, width: number, height: number, x: number, y: number, scaleX: number, scaleY: number, rotation: number, align: IAlign): void {
|
|
29
29
|
const transform = get()
|
|
30
30
|
if (rotation) {
|
|
31
|
-
if (
|
|
31
|
+
if (align === 'center') {
|
|
32
32
|
rotateOfOuter(transform, { x: width / 2, y: height / 2 }, rotation)
|
|
33
33
|
} else {
|
|
34
34
|
rotate(transform, rotation)
|