@leafer-ui/display 2.0.8 → 2.0.9
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 +8 -8
- package/src/Pen.ts +2 -1
- package/src/Polygon.ts +13 -4
- package/src/Star.ts +13 -4
- package/src/UI.ts +1 -1
- package/types/index.d.ts +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/display",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.9",
|
|
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.0.
|
|
26
|
-
"@leafer-ui/data": "2.0.
|
|
27
|
-
"@leafer-ui/display-module": "2.0.
|
|
28
|
-
"@leafer-ui/decorator": "2.0.
|
|
29
|
-
"@leafer-ui/external": "2.0.
|
|
25
|
+
"@leafer/core": "2.0.9",
|
|
26
|
+
"@leafer-ui/data": "2.0.9",
|
|
27
|
+
"@leafer-ui/display-module": "2.0.9",
|
|
28
|
+
"@leafer-ui/decorator": "2.0.9",
|
|
29
|
+
"@leafer-ui/external": "2.0.9"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@leafer/interface": "2.0.
|
|
33
|
-
"@leafer-ui/interface": "2.0.
|
|
32
|
+
"@leafer/interface": "2.0.9",
|
|
33
|
+
"@leafer-ui/interface": "2.0.9"
|
|
34
34
|
}
|
|
35
35
|
}
|
package/src/Pen.ts
CHANGED
|
@@ -72,7 +72,8 @@ export class Pen<TInputData = IPenInputData> extends Group<TInputData> implement
|
|
|
72
72
|
|
|
73
73
|
|
|
74
74
|
public paint(): void {
|
|
75
|
-
|
|
75
|
+
const { pathElement } = this
|
|
76
|
+
if (!pathElement.__layout.boxChanged) pathElement.forceUpdate('path')
|
|
76
77
|
}
|
|
77
78
|
|
|
78
79
|
}
|
package/src/Polygon.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { INumber, IPointData } from '@leafer/interface'
|
|
2
|
-
import { PathCommandDataHelper, dataProcessor, pathType, registerUI, rewriteAble } from '@leafer/core'
|
|
2
|
+
import { PathCommandDataHelper, dataProcessor, pathType, registerUI, rewriteAble, OneRadian } from '@leafer/core'
|
|
3
3
|
|
|
4
4
|
import { IPolygon, IPolygonData, IPolygonInputData } from '@leafer-ui/interface'
|
|
5
5
|
import { PolygonData } from '@leafer-ui/data'
|
|
@@ -22,6 +22,9 @@ export class Polygon<TInputData = IPolygonInputData> extends UI<TInputData> impl
|
|
|
22
22
|
@pathType(3)
|
|
23
23
|
public sides?: INumber
|
|
24
24
|
|
|
25
|
+
@pathType(0)
|
|
26
|
+
public startAngle?: INumber
|
|
27
|
+
|
|
25
28
|
@pathType()
|
|
26
29
|
public points?: number[] | IPointData[]
|
|
27
30
|
|
|
@@ -40,13 +43,19 @@ export class Polygon<TInputData = IPolygonInputData> extends UI<TInputData> impl
|
|
|
40
43
|
|
|
41
44
|
} else {
|
|
42
45
|
|
|
43
|
-
const { width, height, sides } = data
|
|
46
|
+
const { width, height, sides, startAngle } = data
|
|
44
47
|
const rx = width / 2, ry = height / 2
|
|
45
48
|
|
|
46
|
-
|
|
49
|
+
let startRadian = 0, radian: number
|
|
50
|
+
|
|
51
|
+
if (startAngle) {
|
|
52
|
+
startRadian = startAngle * OneRadian
|
|
53
|
+
moveTo(path, rx + rx * sin(startRadian), ry - ry * cos(startRadian))
|
|
54
|
+
} else moveTo(path, rx, 0)
|
|
47
55
|
|
|
48
56
|
for (let i = 1; i < sides; i++) {
|
|
49
|
-
|
|
57
|
+
radian = (i * 2 * PI) / sides + startRadian
|
|
58
|
+
lineTo(path, rx + rx * sin(radian), ry - ry * cos(radian))
|
|
50
59
|
}
|
|
51
60
|
|
|
52
61
|
closePath(path)
|
package/src/Star.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { INumber } from '@leafer/interface'
|
|
2
|
-
import { PathCommandDataHelper, dataProcessor, pathType, registerUI } from '@leafer/core'
|
|
2
|
+
import { OneRadian, PathCommandDataHelper, dataProcessor, pathType, registerUI } from '@leafer/core'
|
|
3
3
|
|
|
4
4
|
import { IStar, IStarData, IStarInputData } from '@leafer-ui/interface'
|
|
5
5
|
import { StarData } from '@leafer-ui/data'
|
|
@@ -25,17 +25,26 @@ export class Star<TInputData = IStarInputData> extends UI<TInputData> implements
|
|
|
25
25
|
@pathType(0.382)
|
|
26
26
|
public innerRadius?: INumber
|
|
27
27
|
|
|
28
|
+
@pathType(0)
|
|
29
|
+
public startAngle?: INumber
|
|
28
30
|
|
|
29
31
|
public __updatePath() {
|
|
30
32
|
|
|
31
|
-
const { width, height, corners, innerRadius } = this.__
|
|
33
|
+
const { width, height, corners, innerRadius, startAngle } = this.__
|
|
32
34
|
const rx = width / 2, ry = height / 2
|
|
33
35
|
|
|
34
36
|
const path: number[] = this.__.path = []
|
|
35
|
-
|
|
37
|
+
|
|
38
|
+
let startRadian = 0, radian: number
|
|
39
|
+
|
|
40
|
+
if (startAngle) {
|
|
41
|
+
startRadian = startAngle * OneRadian
|
|
42
|
+
moveTo(path, rx + rx * sin(startRadian), ry - ry * cos(startRadian))
|
|
43
|
+
} else moveTo(path, rx, 0)
|
|
36
44
|
|
|
37
45
|
for (let i = 1; i < corners * 2; i++) {
|
|
38
|
-
|
|
46
|
+
radian = (i * PI) / corners + startRadian
|
|
47
|
+
lineTo(path, rx + (i % 2 === 0 ? rx : rx * innerRadius) * sin(radian), ry - (i % 2 === 0 ? ry : ry * innerRadius) * cos(radian))
|
|
39
48
|
}
|
|
40
49
|
|
|
41
50
|
closePath(path)
|
package/src/UI.ts
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -101,7 +101,7 @@ declare class UI<TInputData = IUIInputData> extends Leaf<TInputData> implements
|
|
|
101
101
|
animationOut?: IAnimation | IAnimation[];
|
|
102
102
|
transition?: ITransition;
|
|
103
103
|
transitionOut?: ITransition;
|
|
104
|
-
motionPath?: boolean;
|
|
104
|
+
motionPath?: boolean | 'text-path';
|
|
105
105
|
motionPrecision?: INumber;
|
|
106
106
|
motion?: INumber | IUnitData;
|
|
107
107
|
motionRotation?: INumber | IBoolean;
|
|
@@ -344,6 +344,7 @@ declare class Polygon<TInputData = IPolygonInputData> extends UI<TInputData> imp
|
|
|
344
344
|
get __tag(): string;
|
|
345
345
|
__: IPolygonData;
|
|
346
346
|
sides?: INumber;
|
|
347
|
+
startAngle?: INumber;
|
|
347
348
|
points?: number[] | IPointData[];
|
|
348
349
|
curve?: boolean | number;
|
|
349
350
|
__updatePath(): void;
|
|
@@ -354,6 +355,7 @@ declare class Star<TInputData = IStarInputData> extends UI<TInputData> implement
|
|
|
354
355
|
__: IStarData;
|
|
355
356
|
corners?: INumber;
|
|
356
357
|
innerRadius?: INumber;
|
|
358
|
+
startAngle?: INumber;
|
|
357
359
|
__updatePath(): void;
|
|
358
360
|
}
|
|
359
361
|
|