@leafer-ui/image 1.6.6 → 1.7.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-ui/image",
3
- "version": "1.6.6",
3
+ "version": "1.7.0",
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.6.6",
26
- "@leafer-ui/draw": "1.6.6"
25
+ "@leafer/core": "1.7.0",
26
+ "@leafer-ui/draw": "1.7.0"
27
27
  },
28
28
  "devDependencies": {
29
- "@leafer/interface": "1.6.6",
30
- "@leafer-ui/interface": "1.6.6"
29
+ "@leafer/interface": "1.7.0",
30
+ "@leafer-ui/interface": "1.7.0"
31
31
  }
32
32
  }
package/src/data.ts CHANGED
@@ -12,9 +12,10 @@ const tempScaleData = {} as IScaleData
12
12
  const tempImage = {} as IBoundsData
13
13
 
14
14
  export function createData(leafPaint: ILeafPaint, image: ILeaferImage, paint: IImagePaint, box: IBoundsData): void {
15
- const { changeful, sync } = paint
15
+ const { changeful, sync, editing } = paint
16
16
  if (changeful) leafPaint.changeful = changeful
17
17
  if (sync) leafPaint.sync = sync
18
+ if (editing) leafPaint.editing = editing
18
19
  leafPaint.data = getPatternData(paint, box, image)
19
20
  }
20
21
 
@@ -23,7 +24,7 @@ export function getPatternData(paint: IImagePaint, box: IBoundsData, image: ILea
23
24
  if (paint.mode === 'strench' as string) paint.mode = 'stretch' // 兼容代码,后续可移除
24
25
 
25
26
  let { width, height } = image
26
- const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint
27
+ const { opacity, mode, align, offset, scale, size, rotation, skew, repeat, filters } = paint
27
28
  const sameBox = box.width === width && box.height === height
28
29
 
29
30
  const data: ILeafPaintPatternData = { mode }
@@ -59,7 +60,7 @@ export function getPatternData(paint: IImagePaint, box: IBoundsData, image: ILea
59
60
  break
60
61
  case 'normal':
61
62
  case 'clip':
62
- if (tempImage.x || tempImage.y || scaleX || rotation) clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation)
63
+ if (tempImage.x || tempImage.y || scaleX || rotation || skew) clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew)
63
64
  break
64
65
  case 'repeat':
65
66
  if (!sameBox || scaleX || rotation) repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, align)
package/src/image.ts CHANGED
@@ -60,12 +60,12 @@ export function image(ui: IUI, attrName: string, paint: IImagePaint, boxBounds:
60
60
  }
61
61
  onLoadSuccess(ui, event)
62
62
  }
63
- leafPaint.loadId = null
63
+ leafPaint.loadId = undefined
64
64
  },
65
65
  (error) => {
66
66
  ignoreRender(ui, false)
67
67
  onLoadError(ui, event, error)
68
- leafPaint.loadId = null
68
+ leafPaint.loadId = undefined
69
69
  }
70
70
  )
71
71
 
package/src/mode.ts CHANGED
@@ -5,7 +5,7 @@ import { ILeafPaintPatternData } from '@leafer-ui/interface'
5
5
 
6
6
 
7
7
  let origin = {} as IPointData
8
- const { get, rotateOfOuter, translate, scaleOfOuter, scale: scaleHelper, rotate } = MatrixHelper
8
+ const { get, rotateOfOuter, translate, scaleOfOuter, scale: scaleHelper, rotate, skew: skewHelper } = MatrixHelper
9
9
 
10
10
  export function fillOrFitMode(data: ILeafPaintPatternData, box: IBoundsData, x: number, y: number, scaleX: number, scaleY: number, rotation: number): void {
11
11
  const transform: IMatrixData = get()
@@ -16,11 +16,13 @@ export function fillOrFitMode(data: ILeafPaintPatternData, box: IBoundsData, x:
16
16
  }
17
17
 
18
18
 
19
- export function clipMode(data: ILeafPaintPatternData, box: IBoundsData, x: number, y: number, scaleX: number, scaleY: number, rotation: number): void {
19
+ export function clipMode(data: ILeafPaintPatternData, box: IBoundsData, x: number, y: number, scaleX: number, scaleY: number, rotation: number, skew: IPointData): void {
20
+ // rotate -> skew -> scale -> translate
20
21
  const transform: IMatrixData = get()
21
- translate(transform, box.x + x, box.y + y)
22
- if (scaleX) scaleHelper(transform, scaleX, scaleY)
23
22
  if (rotation) rotate(transform, rotation)
23
+ if (skew) skewHelper(transform, skew.x, skew.y)
24
+ if (scaleX) scaleHelper(transform, scaleX, scaleY)
25
+ translate(transform, box.x + x, box.y + y)
24
26
  data.transform = transform
25
27
  }
26
28
 
package/src/pattern.ts CHANGED
@@ -21,6 +21,8 @@ export function createPattern(ui: IUI, paint: ILeafPaint, pixelRatio: number): b
21
21
  let imageScale: number, imageMatrix: IMatrixData, { width, height, scaleX: sx, scaleY: sy, transform, repeat } = data
22
22
 
23
23
  if (sx) {
24
+ sx = abs(sx) // maybe -1
25
+ sy = abs(sy)
24
26
  imageMatrix = get()
25
27
  copy(imageMatrix, transform)
26
28
  scale(imageMatrix, 1 / sx, 1 / sy)