@leafer-ui/paint 1.0.0-rc.7 → 1.0.0-rc.8

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/paint",
3
- "version": "1.0.0-rc.7",
3
+ "version": "1.0.0-rc.8",
4
4
  "description": "@leafer-ui/paint",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,10 +22,10 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/core": "1.0.0-rc.7"
25
+ "@leafer/core": "1.0.0-rc.8"
26
26
  },
27
27
  "devDependencies": {
28
- "@leafer/interface": "1.0.0-rc.7",
29
- "@leafer-ui/interface": "1.0.0-rc.7"
28
+ "@leafer/interface": "1.0.0-rc.8",
29
+ "@leafer-ui/interface": "1.0.0-rc.8"
30
30
  }
31
31
  }
@@ -19,7 +19,7 @@ export function checkImage(ui: IUI, canvas: ILeaferCanvas, paint: ILeafPaint, al
19
19
  const { data } = paint
20
20
 
21
21
  if (allowPaint) {
22
- if (data.mode !== 'repeat') {
22
+ if (!data.repeat) {
23
23
  let { width, height } = data
24
24
  width *= abs(scaleX) * canvas.pixelRatio
25
25
  height *= abs(scaleY) * canvas.pixelRatio
@@ -11,7 +11,7 @@ const { get, translate } = MatrixHelper
11
11
  export function createData(leafPaint: ILeafPaint, image: ILeaferImage, paint: IImagePaint, box: IBoundsData): void {
12
12
  let { width, height } = image
13
13
 
14
- const { opacity, mode, offset, scale, rotation, blendMode } = paint
14
+ const { opacity, mode, offset, scale, rotation, blendMode, repeat } = paint
15
15
  const sameBox = box.width === width && box.height === height
16
16
  if (blendMode) leafPaint.blendMode = blendMode
17
17
 
@@ -30,6 +30,7 @@ export function createData(leafPaint: ILeafPaint, image: ILeaferImage, paint: II
30
30
  break
31
31
  case 'repeat':
32
32
  if (!sameBox || scale || rotation) repeatMode(data, box, width, height, scale as number, rotation)
33
+ if (!repeat) data.repeat = 'repeat'
33
34
  break
34
35
  case 'fit':
35
36
  case 'cover':
@@ -40,4 +41,5 @@ export function createData(leafPaint: ILeafPaint, image: ILeaferImage, paint: II
40
41
  data.width = width
41
42
  data.height = height
42
43
  if (opacity) data.opacity = opacity
44
+ if (repeat) data.repeat = typeof repeat === 'string' ? (repeat === 'x' ? 'repeat-x' : 'repeat-y') : 'repeat'
43
45
  }
@@ -64,11 +64,11 @@ function hasNaturalSize(ui: IUI, attrName: string, image: ISizeData): boolean {
64
64
  d.__naturalWidth = image.width
65
65
  d.__naturalHeight = image.height
66
66
  if (!d.__getInput('width') || !d.__getInput('height')) {
67
+ ui.forceUpdate('width')
67
68
  if (ui.__proxyData) {
68
69
  ui.setProxyAttr('width', ui.__.width)
69
70
  ui.setProxyAttr('height', ui.__.height)
70
71
  }
71
- ui.forceUpdate('width')
72
72
  return false
73
73
  }
74
74
  }
@@ -17,7 +17,7 @@ export function createPattern(ui: IUI, paint: ILeafPaint, pixelRatio: number): b
17
17
  scaleY = Math.abs(scaleY)
18
18
 
19
19
  const { image, data } = paint
20
- let imageScale: number, imageMatrix: IMatrixData, { width, height, scaleX: sx, scaleY: sy, opacity, transform, mode } = data
20
+ let imageScale: number, imageMatrix: IMatrixData, { width, height, scaleX: sx, scaleY: sy, opacity, transform, repeat } = data
21
21
 
22
22
  if (sx) {
23
23
  imageMatrix = get()
@@ -34,7 +34,7 @@ export function createPattern(ui: IUI, paint: ILeafPaint, pixelRatio: number): b
34
34
 
35
35
  const size = width * height
36
36
 
37
- if (paint.data.mode !== 'repeat') {
37
+ if (!repeat) {
38
38
  if (size > Platform.image.maxCacheSize) return false // same as check()
39
39
  }
40
40
 
@@ -67,7 +67,7 @@ export function createPattern(ui: IUI, paint: ILeafPaint, pixelRatio: number): b
67
67
  scale(imageMatrix, 1 / scaleX, 1 / scaleY)
68
68
  }
69
69
 
70
- const pattern = Platform.canvas.createPattern(image.getCanvas(width < 1 ? 1 : width, height < 1 ? 1 : height, opacity) as any, mode === 'repeat' ? 'repeat' : (Platform.origin.noRepeat || 'no-repeat'))
70
+ const pattern = Platform.canvas.createPattern(image.getCanvas(width < 1 ? 1 : width, height < 1 ? 1 : height, opacity) as any, repeat || (Platform.origin.noRepeat || 'no-repeat'))
71
71
 
72
72
  try {
73
73
  if (paint.transform) paint.transform = null