@leafer-ui/render 1.6.7 → 1.8.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/render",
3
- "version": "1.6.7",
3
+ "version": "1.8.0",
4
4
  "description": "@leafer-ui/render",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,10 +22,10 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer-ui/external": "1.6.7"
25
+ "@leafer-ui/external": "1.8.0"
26
26
  },
27
27
  "devDependencies": {
28
- "@leafer/interface": "1.6.7",
29
- "@leafer-ui/interface": "1.6.7"
28
+ "@leafer/interface": "1.8.0",
29
+ "@leafer-ui/interface": "1.8.0"
30
30
  }
31
31
  }
package/src/RectRender.ts CHANGED
@@ -19,18 +19,18 @@ export const RectRender: IRectRenderModule = {
19
19
 
20
20
  if (stroke) {
21
21
 
22
- const { strokeAlign, __strokeWidth } = this.__
23
- if (!__strokeWidth) return
22
+ const { strokeAlign, __strokeWidth: strokeWidth } = this.__
23
+ if (!strokeWidth) return
24
24
 
25
- canvas.setStroke(stroke, __strokeWidth, this.__)
26
- const half = __strokeWidth / 2
25
+ canvas.setStroke(stroke, strokeWidth, this.__)
26
+ const half = strokeWidth / 2
27
27
 
28
28
  switch (strokeAlign) {
29
29
  case 'center':
30
30
  canvas.strokeRect(0, 0, width, height)
31
31
  break
32
32
  case 'inside':
33
- width -= __strokeWidth, height -= __strokeWidth
33
+ width -= strokeWidth, height -= strokeWidth
34
34
  if (width < 0 || height < 0) {
35
35
  canvas.save()
36
36
  this.__clip(canvas, options)
@@ -39,7 +39,7 @@ export const RectRender: IRectRenderModule = {
39
39
  } else canvas.strokeRect(x + half, y + half, width, height)
40
40
  break
41
41
  case 'outside':
42
- canvas.strokeRect(x - half, y - half, width + __strokeWidth, height + __strokeWidth)
42
+ canvas.strokeRect(x - half, y - half, width + strokeWidth, height + strokeWidth)
43
43
  break
44
44
  }
45
45
 
package/src/UIRender.ts CHANGED
@@ -11,19 +11,21 @@ export const UIRender: IUIRenderModule = {
11
11
  __updateChange(): void {
12
12
  const data = this.__
13
13
 
14
+ if (data.__useStroke) {
15
+ const useStroke = data.__useStroke = !!(data.stroke && data.strokeWidth)
16
+ stintSet(this.__world, 'half', useStroke && data.strokeAlign === 'center' && data.strokeWidth % 2) // 是否存在半逻辑像素渲染(奇数线宽的居中线条),可以半像素为起点绘制,防止模糊
17
+ stintSet(data, '__fillAfterStroke', useStroke && data.strokeAlign === 'outside' && data.fill && !data.__isTransparentFill)
18
+ }
19
+
14
20
  if (data.__useEffect) {
15
21
  const { shadow, fill, stroke } = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter
16
- stintSet(data, '__isFastShadow', shadow && !otherEffect && shadow.length < 2 && !shadow[0].spread && !(shadow[0].box && data.__isTransparentFill) && fill && !(fill instanceof Array && fill.length > 1) && (this.useFastShadow || !stroke || (stroke && data.strokeAlign === 'inside')))
22
+ stintSet(data, '__isFastShadow', shadow && !otherEffect && shadow.length < 2 && !shadow[0].spread && fill && !data.__isTransparentFill && !(fill instanceof Array && fill.length > 1) && (this.useFastShadow || !stroke || (stroke && data.strokeAlign === 'inside'))) // 高性能阴影条件, @leafer-ui/image check.ts 中的 allowDraw 逻辑需与此处关联
17
23
  data.__useEffect = !!(shadow || otherEffect)
18
24
  }
19
25
 
20
- stintSet(this.__world, 'half', data.__hasHalf)
21
-
22
- stintSet(data, '__fillAfterStroke', data.stroke && data.strokeAlign === 'outside' && data.fill && !data.__isTransparentFill)
23
-
24
26
  data.__checkSingle()
25
27
 
26
- stintSet(data, '__complex', data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect)
28
+ stintSet(data, '__complex', (data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect) as boolean)
27
29
  },
28
30
 
29
31
  __drawFast(canvas: ILeaferCanvas, options: IRenderOptions): void {
@@ -92,18 +94,14 @@ export const UIRender: IUIRenderModule = {
92
94
  }
93
95
  },
94
96
 
95
- __renderShape(canvas: ILeaferCanvas, options: IRenderOptions, ignoreFill?: boolean, ignoreStroke?: boolean): void {
96
- if (this.__worldOpacity) {
97
- canvas.setWorld(this.__nowWorld = this.__getNowWorld(options))
97
+ __drawShape(canvas: ILeaferCanvas, options: IRenderOptions): void {
98
+ this.__drawRenderPath(canvas)
98
99
 
99
- const { fill, stroke } = this.__
100
+ const data = this.__, { fill, stroke } = data
100
101
 
101
- this.__drawRenderPath(canvas)
102
-
103
- if (fill && !ignoreFill) this.__.__isAlphaPixelFill ? Paint.fills(fill as ILeafPaint[], this, canvas) : Paint.fill('#000000', this, canvas)
104
- if (this.__.__isCanvas) this.__drawAfterFill(canvas, options)
105
- if (stroke && !ignoreStroke) this.__.__isAlphaPixelStroke ? Paint.strokes(stroke as ILeafStrokePaint[], this, canvas) : Paint.stroke('#000000', this, canvas)
106
- }
102
+ if (fill && !options.ignoreFill) data.__isAlphaPixelFill ? Paint.fills(fill as ILeafPaint[], this, canvas) : Paint.fill('#000000', this, canvas)
103
+ if (data.__isCanvas) this.__drawAfterFill(canvas, options)
104
+ if (stroke && !options.ignoreStroke) data.__isAlphaPixelStroke ? Paint.strokes(stroke as ILeafStrokePaint[], this, canvas) : Paint.stroke('#000000', this, canvas)
107
105
  },
108
106
 
109
107
  __drawAfterFill(canvas: ILeaferCanvas, options: IRenderOptions): void {