@leafer-ui/image 2.1.4 → 2.1.6

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": "2.1.4",
3
+ "version": "2.1.6",
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": "2.1.4",
26
- "@leafer-ui/draw": "2.1.4"
25
+ "@leafer/core": "2.1.6",
26
+ "@leafer-ui/draw": "2.1.6"
27
27
  },
28
28
  "devDependencies": {
29
- "@leafer/interface": "2.1.4",
30
- "@leafer-ui/interface": "2.1.4"
29
+ "@leafer/interface": "2.1.6",
30
+ "@leafer-ui/interface": "2.1.6"
31
31
  }
32
32
  }
package/src/data.ts CHANGED
@@ -66,8 +66,8 @@ export function getPatternData(paint: IImagePaint, box: IBoundsData, image: ILea
66
66
  }
67
67
  break
68
68
  case 'repeat':
69
- case 'brush':
70
69
  if (!sameBox || scaleX || rotation || skew) PaintImage.repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform)
70
+ case 'brush':
71
71
  if (!repeat) data.repeat = 'repeat'
72
72
  const count = isObject(repeat)
73
73
  if (gap || count) data.gap = getGapData(gap, count && repeat, tempImage.width, tempImage.height, box)
@@ -78,7 +78,7 @@ export function getPatternData(paint: IImagePaint, box: IBoundsData, image: ILea
78
78
  if (scaleX) PaintImage.fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation)
79
79
  }
80
80
 
81
- if (!data.transform) {
81
+ if (!data.transform && mode !== 'brush') {
82
82
  if (box.x || box.y) translate(data.transform = get(), box.x, box.y)
83
83
  }
84
84
 
package/src/image.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { IBoundsData, IImageEvent, ILeaferImage, IObject } from '@leafer/interface'
2
2
  import { Bounds, BoundsHelper, ImageEvent, ImageManager, LeafHelper } from '@leafer/core'
3
3
 
4
- import { IUI, IImagePaint, ILeafPaint } from '@leafer-ui/interface'
4
+ import { IUI, IImagePaint, ILeafPaint, IPaintAttr } from '@leafer-ui/interface'
5
5
  import { PaintImage } from "@leafer-ui/draw"
6
6
 
7
7
 
@@ -14,7 +14,7 @@ interface IImagePaintCache {
14
14
  let cache: IImagePaintCache, box = new Bounds()
15
15
  const { isSame } = BoundsHelper
16
16
 
17
- export function image(ui: IUI, attrName: string, paint: IImagePaint, boxBounds: IBoundsData, firstUse: boolean): ILeafPaint {
17
+ export function image(ui: IUI, attrName: IPaintAttr, paint: IImagePaint, boxBounds: IBoundsData, firstUse: boolean): ILeafPaint {
18
18
  let leafPaint: ILeafPaint, event: IImageEvent
19
19
  const image = ImageManager.get(paint, paint.type)
20
20
 
@@ -85,7 +85,7 @@ export function image(ui: IUI, attrName: string, paint: IImagePaint, boxBounds:
85
85
  }
86
86
 
87
87
 
88
- function checkSizeAndCreateData(ui: IUI, attrName: string, paint: IImagePaint, image: ILeaferImage, leafPaint: ILeafPaint, boxBounds: IBoundsData): boolean {
88
+ function checkSizeAndCreateData(ui: IUI, attrName: IPaintAttr, paint: IImagePaint, image: ILeaferImage, leafPaint: ILeafPaint, boxBounds: IBoundsData): boolean {
89
89
  let needUpdate = true
90
90
  const data = ui.__
91
91
 
@@ -103,7 +103,7 @@ function checkSizeAndCreateData(ui: IUI, attrName: string, paint: IImagePaint, i
103
103
  }
104
104
  }
105
105
 
106
- if (paint.mode === 'brush') PaintImage.brush(leafPaint, ui)
106
+ if (paint.mode === 'brush') PaintImage.brush(leafPaint, ui, attrName)
107
107
 
108
108
  if (!leafPaint.data) {
109
109
  PaintImage.createData(leafPaint, image, paint, boxBounds)
package/src/pattern.ts CHANGED
@@ -26,9 +26,10 @@ export function createPattern(paint: ILeafPaint, ui: IUI, canvas: ILeaferCanvas,
26
26
  if (paint.patternId !== id && !ui.destroyed) {
27
27
  if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
28
28
 
29
- const { image, brush, data } = paint, { opacity } = paint.originPaint as IImagePaint, { transform, gap } = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY)
30
- let imageMatrix: IMatrixData, xGap: number, yGap: number, { width, height } = image
29
+ const { image, brush, data } = paint, { transform, gap } = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY)
30
+ let imageMatrix: IMatrixData, xGap: number, yGap: number, { width, height } = image, { opacity } = paint.originPaint as IImagePaint
31
31
 
32
+ if (brush || opacity === 1) opacity = undefined
32
33
  if (fixScale) scaleX *= fixScale, scaleY *= fixScale
33
34
 
34
35
  width *= scaleX