@leafer-ui/display 2.1.5 → 2.1.7

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/display",
3
- "version": "2.1.5",
3
+ "version": "2.1.7",
4
4
  "description": "@leafer-ui/display",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,14 +22,14 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/core": "2.1.5",
26
- "@leafer-ui/data": "2.1.5",
27
- "@leafer-ui/display-module": "2.1.5",
28
- "@leafer-ui/decorator": "2.1.5",
29
- "@leafer-ui/external": "2.1.5"
25
+ "@leafer/core": "2.1.7",
26
+ "@leafer-ui/data": "2.1.7",
27
+ "@leafer-ui/display-module": "2.1.7",
28
+ "@leafer-ui/decorator": "2.1.7",
29
+ "@leafer-ui/external": "2.1.7"
30
30
  },
31
31
  "devDependencies": {
32
- "@leafer/interface": "2.1.5",
33
- "@leafer-ui/interface": "2.1.5"
32
+ "@leafer/interface": "2.1.7",
33
+ "@leafer-ui/interface": "2.1.7"
34
34
  }
35
35
  }
package/src/Ellipse.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { INumber } from '@leafer/interface'
2
- import { PathCommandDataHelper, Platform, dataProcessor, pathType, registerUI } from '@leafer/core'
1
+ import { INumber, IPointData } from '@leafer/interface'
2
+ import { PathCommandDataHelper, Platform, dataProcessor, pathType, registerUI, PointHelper } from '@leafer/core'
3
3
 
4
4
  import { IEllipse, IEllipseInputData, IEllipseData } from '@leafer-ui/interface'
5
5
  import { EllipseData } from '@leafer-ui/data'
@@ -7,7 +7,7 @@ import { EllipseData } from '@leafer-ui/data'
7
7
  import { UI } from './UI'
8
8
 
9
9
 
10
- const { moveTo, closePath, ellipse } = PathCommandDataHelper
10
+ const { moveTo, closePath, ellipse } = PathCommandDataHelper, { tempPoint, set, rotate } = PointHelper, { abs } = Math, tempCenter = {} as IPointData
11
11
 
12
12
  @registerUI()
13
13
  export class Ellipse<TInputData = IEllipseInputData> extends UI<TInputData> implements IEllipse {
@@ -29,31 +29,54 @@ export class Ellipse<TInputData = IEllipseInputData> extends UI<TInputData> impl
29
29
 
30
30
  public __updatePath(): void {
31
31
 
32
- const data = this.__, { width, height, innerRadius, startAngle, endAngle } = data
32
+ const data = this.__, { width, height, innerRadius, startAngle, endAngle, closed } = data
33
33
  const rx = width / 2, ry = height / 2
34
34
 
35
35
  const path: number[] = data.path = []
36
- let open: boolean
36
+ let open: boolean, hasAngle: boolean, closedAngle: boolean
37
+
38
+ if (startAngle || endAngle) hasAngle = true
39
+ if (hasAngle) closedAngle = abs(endAngle - startAngle) === 360
37
40
 
38
41
  if (innerRadius) {
39
42
 
40
- if (startAngle || endAngle) {
41
- if (innerRadius < 1) ellipse(path, rx, ry, rx * innerRadius, ry * innerRadius, 0, startAngle, endAngle, false)
42
- else open = true // 画弧线时,不能闭合路径
43
- ellipse(path, rx, ry, rx, ry, 0, endAngle, startAngle, true)
43
+ const drawInnerEllipse = innerRadius < 1 || closed
44
+ let outerStartAngle = startAngle, outerEndAngle = endAngle, outerAnticlockwise: boolean
45
+
46
+ if (hasAngle) {
47
+ if (drawInnerEllipse) {
48
+ ellipse(path, rx, ry, rx * innerRadius, ry * innerRadius, 0, startAngle, endAngle)
49
+ if (closedAngle) {
50
+ set(tempPoint, width, ry)
51
+ set(tempCenter, rx, ry)
52
+ rotate(tempPoint, endAngle, tempCenter, rx, ry)
53
+ moveTo(path, tempPoint.x, tempPoint.y)
54
+ }
55
+ outerStartAngle = endAngle
56
+ outerEndAngle = startAngle
57
+ outerAnticlockwise = true
58
+ } else {
59
+ if (!closedAngle) open = true // 画弧线
60
+ }
44
61
  } else {
45
- if (innerRadius < 1) {
62
+ if (drawInnerEllipse) {
46
63
  ellipse(path, rx, ry, rx * innerRadius, ry * innerRadius)
64
+ closePath(path)
47
65
  moveTo(path, width, ry)
66
+ outerStartAngle = 360
67
+ outerAnticlockwise = true
68
+ } else {
69
+ outerEndAngle = 360
48
70
  }
49
- ellipse(path, rx, ry, rx, ry, 0, 360, 0, true)
50
71
  }
51
72
 
73
+ ellipse(path, rx, ry, rx, ry, 0, outerStartAngle, outerEndAngle, outerAnticlockwise)
74
+
52
75
  } else {
53
76
 
54
- if (startAngle || endAngle) {
55
- moveTo(path, rx, ry)
56
- ellipse(path, rx, ry, rx, ry, 0, startAngle, endAngle, false)
77
+ if (hasAngle) {
78
+ if (!closedAngle) moveTo(path, rx, ry)
79
+ ellipse(path, rx, ry, rx, ry, 0, startAngle, endAngle)
57
80
  } else {
58
81
  ellipse(path, rx, ry, rx, ry)
59
82
  }
package/src/UI.ts CHANGED
@@ -515,7 +515,7 @@ export class UI<TInputData = IUIInputData> extends Leaf<TInputData> implements I
515
515
  return Plugin.need('animate')
516
516
  }
517
517
 
518
- // create
518
+ public killAnimate(_type?: IAnimateType, _nextStyle?: IUIInputData): void { }
519
519
 
520
520
  // @leafer-in/export will rewrite
521
521
  public export(_filename: IExportFileType | string, _options?: IExportOptions | number | boolean): Promise<IExportResult> {
@@ -571,7 +571,4 @@ export interface UI {
571
571
  createProxyData(): IUIInputData
572
572
  clearProxyData(): void
573
573
 
574
- // @leafer-in/animate rewrite
575
- killAnimate(type?: IAnimateType, nextStyle?: IUIInputData): void
576
-
577
574
  }
package/types/index.d.ts CHANGED
@@ -150,6 +150,7 @@ declare class UI<TInputData = IUIInputData> extends Leaf<TInputData> implements
150
150
  __drawPathByBox(drawer: IPathDrawer, ignoreCornerRadius?: boolean): void;
151
151
  drawImagePlaceholder(_paint: ILeafPaint, canvas: ILeaferCanvas, renderOptions: IRenderOptions): void;
152
152
  animate(keyframe?: IUIInputData | IKeyframe[] | IAnimation | IAnimation[], _options?: ITransition, _type?: IAnimateType, _isTemp?: boolean): IAnimate;
153
+ killAnimate(_type?: IAnimateType, _nextStyle?: IUIInputData): void;
153
154
  export(_filename: IExportFileType | string, _options?: IExportOptions | number | boolean): Promise<IExportResult>;
154
155
  syncExport(_filename: IExportFileType | string, _options?: IExportOptions | number | boolean): IExportResult;
155
156
  clone(data?: IUIInputData): this;
@@ -165,7 +166,6 @@ interface UI {
165
166
  reset(data?: IUIInputData): void;
166
167
  createProxyData(): IUIInputData;
167
168
  clearProxyData(): void;
168
- killAnimate(type?: IAnimateType, nextStyle?: IUIInputData): void;
169
169
  }
170
170
 
171
171
  declare class Group<TInputData = IGroupInputData> extends UI<TInputData> implements IGroup {