@leafer/interface 1.0.0-rc.2 → 1.0.0-rc.21
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 +1 -1
- package/src/app/IApp.ts +3 -3
- package/src/app/ILeafer.ts +44 -20
- package/src/canvas/ICanvas.ts +7 -2
- package/src/canvas/IHitCanvasManager.ts +3 -3
- package/src/canvas/ILeaferCanvas.ts +19 -11
- package/src/canvas/ISkiaCanvas.ts +20 -1
- package/src/data/IData.ts +6 -5
- package/src/data/ILeafData.ts +11 -6
- package/src/data/IList.ts +9 -6
- package/src/display/IBranch.ts +2 -1
- package/src/display/ILeaf.ts +266 -93
- package/src/display/IView.ts +2 -6
- package/src/display/module/IBranchRender.ts +2 -2
- package/src/display/module/ILeafBounds.ts +2 -0
- package/src/display/module/ILeafDataProxy.ts +5 -3
- package/src/display/module/ILeafHit.ts +4 -1
- package/src/display/module/ILeafRender.ts +2 -1
- package/src/event/IEvent.ts +3 -23
- package/src/event/IEventer.ts +6 -1
- package/src/event/IUIEvent.ts +11 -8
- package/src/file/IExport.ts +34 -0
- package/src/file/IFileType.ts +1 -1
- package/src/function/IFunction.ts +9 -0
- package/src/image/IImageManager.ts +4 -0
- package/src/image/ILeaferImage.ts +13 -0
- package/src/index.ts +16 -15
- package/src/interaction/ICursor.ts +16 -0
- package/src/interaction/IInteraction.ts +33 -4
- package/src/layout/ILeafLayout.ts +30 -14
- package/src/layouter/ILayouter.ts +3 -0
- package/src/math/IMath.ts +72 -35
- package/src/path/IPathDrawer.ts +6 -3
- package/src/platform/IPlatform.ts +17 -2
- package/src/plugin/IPlugin.ts +2 -2
- package/src/renderer/IRenderer.ts +4 -2
- package/src/selector/ISelector.ts +26 -9
- package/types/index.d.ts +619 -325
- package/src/display/module/ILeafMask.ts +0 -12
package/src/math/IMath.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IObject } from '../data/IData'
|
|
1
|
+
import { IFourNumber, IObject } from '../data/IData'
|
|
2
2
|
|
|
3
3
|
export interface IPointData {
|
|
4
4
|
x: number
|
|
@@ -6,21 +6,28 @@ export interface IPointData {
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export interface IPoint extends IPointData {
|
|
9
|
-
set(x?: number, y?: number):
|
|
10
|
-
|
|
9
|
+
set(x?: number | IPointData, y?: number): IPoint
|
|
10
|
+
get(): IPointData
|
|
11
11
|
clone(): IPoint
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
move(x: number, y: number): IPoint
|
|
14
|
+
scale(scaleX: number, scaleY?: number): IPoint
|
|
15
|
+
scaleOf(origin: IPointData, scaleX: number, scaleY?: number): IPoint
|
|
16
|
+
rotate(rotation: number, origin?: IPointData): IPoint
|
|
17
|
+
rotateOf(origin: IPointData, rotation: number): IPoint
|
|
18
|
+
getRotation(origin: IPointData, to: IPointData, toOrigin?: IPointData): number
|
|
14
19
|
|
|
15
20
|
toInnerOf(matrix: IMatrixData, to?: IPointData): IPoint
|
|
16
21
|
toOuterOf(matrix: IMatrixData, to?: IPointData): IPoint
|
|
17
22
|
|
|
18
|
-
getCenter(to: IPointData):
|
|
23
|
+
getCenter(to: IPointData): IPoint
|
|
19
24
|
getDistance(to: IPointData): number
|
|
25
|
+
getDistancePoint(to: IPointData, distance: number, changeTo?: boolean): IPoint
|
|
26
|
+
|
|
20
27
|
getAngle(to: IPointData): number
|
|
21
28
|
getAtan2(to: IPointData): number
|
|
22
29
|
|
|
23
|
-
reset():
|
|
30
|
+
reset(): IPoint
|
|
24
31
|
}
|
|
25
32
|
|
|
26
33
|
export interface IRadiusPointData extends IPointData {
|
|
@@ -47,29 +54,37 @@ export interface IOffsetBoundsData extends IBoundsData {
|
|
|
47
54
|
offsetY: number
|
|
48
55
|
}
|
|
49
56
|
|
|
50
|
-
export interface
|
|
57
|
+
export interface IBoundsDataFn {
|
|
51
58
|
(target: any): IBoundsData
|
|
52
59
|
}
|
|
53
60
|
|
|
54
|
-
export interface IBounds extends IBoundsData {
|
|
55
|
-
set(x?: number, y?: number, width?: number, height?: number):
|
|
56
|
-
|
|
61
|
+
export interface IBounds extends IBoundsData, ITwoPointBoundsData {
|
|
62
|
+
set(x?: number | IBoundsData, y?: number, width?: number, height?: number): IBounds
|
|
63
|
+
get(): IBoundsData
|
|
57
64
|
clone(): IBounds
|
|
58
65
|
|
|
66
|
+
move(x: number, y: number): IBounds
|
|
59
67
|
scale(scaleX: number, scaleY?: number): IBounds
|
|
68
|
+
scaleOf(origin: IPointData, scaleX: number, scaleY?: number): IBounds
|
|
60
69
|
toOuterOf(matrix: IMatrixData, to?: IBoundsData): IBounds
|
|
61
|
-
|
|
70
|
+
toInnerOf(matrix: IMatrixData, to?: IBoundsData): IBounds
|
|
71
|
+
getFitMatrix(put: IBoundsData, baseScale?: number): IMatrix
|
|
62
72
|
|
|
63
|
-
spread(
|
|
73
|
+
spread(fourNumber: IFourNumber, spreadY?: number): IBounds
|
|
74
|
+
shrink(fourNumber: IFourNumber): IBounds
|
|
64
75
|
ceil(): IBounds
|
|
65
76
|
unsign(): IBounds
|
|
77
|
+
float(maxLength?: number): IBounds
|
|
66
78
|
|
|
67
79
|
add(bounds: IBoundsData): IBounds
|
|
68
|
-
addList(boundsList:
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
80
|
+
addList(boundsList: IBoundsData[]): IBounds
|
|
81
|
+
setList(boundsList: IBoundsData[]): IBounds
|
|
82
|
+
addListWithFn(list: IObject[], boundsDataHandle: IBoundsDataFn): IBounds
|
|
83
|
+
setListWithFn(list: IObject[], boundsDataHandle: IBoundsDataFn): IBounds
|
|
84
|
+
|
|
85
|
+
setPoints(points: IPointData[]): IBounds
|
|
86
|
+
addPoint(point: IPointData): IBounds
|
|
87
|
+
getPoints(): IPointData[] // topLeft, topRight, bottomRight, bottomLeft
|
|
73
88
|
|
|
74
89
|
hitPoint(point: IPointData, pointMatrix?: IMatrixData): boolean
|
|
75
90
|
hitRadiusPoint(point: IRadiusPointData, pointMatrix?: IMatrixWithLayoutData): boolean
|
|
@@ -91,12 +106,6 @@ export interface ITwoPointBoundsData {
|
|
|
91
106
|
maxY: number
|
|
92
107
|
}
|
|
93
108
|
|
|
94
|
-
export interface ITwoPointBounds extends ITwoPointBoundsData {
|
|
95
|
-
addPoint(x: number, y: number): void
|
|
96
|
-
addBounds(x: number, y: number, width: number, height: number): void
|
|
97
|
-
add(pointBounds: ITwoPointBoundsData): void
|
|
98
|
-
}
|
|
99
|
-
|
|
100
109
|
|
|
101
110
|
export interface IAutoBoundsData {
|
|
102
111
|
top?: number
|
|
@@ -125,17 +134,24 @@ export interface IMatrixData {
|
|
|
125
134
|
f: number
|
|
126
135
|
}
|
|
127
136
|
|
|
128
|
-
export interface
|
|
129
|
-
x: number
|
|
130
|
-
y: number
|
|
137
|
+
export interface IScaleData {
|
|
131
138
|
scaleX: number
|
|
132
139
|
scaleY: number
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export interface IScaleRotationData extends IScaleData {
|
|
133
143
|
rotation: number
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export interface ISkewData {
|
|
134
147
|
skewX: number
|
|
135
148
|
skewY: number
|
|
136
149
|
}
|
|
137
150
|
|
|
138
|
-
export
|
|
151
|
+
export interface ILayoutData extends IScaleRotationData, ISkewData, IPointData {
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export type ILayoutAttr =
|
|
139
155
|
| 'x'
|
|
140
156
|
| 'y'
|
|
141
157
|
| 'scaleX'
|
|
@@ -144,15 +160,21 @@ export type IMatrixDecompositionAttr =
|
|
|
144
160
|
| 'skewX'
|
|
145
161
|
| 'skewY'
|
|
146
162
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
163
|
+
|
|
164
|
+
export interface ILayoutBoundsData extends ILayoutData, IBoundsData {
|
|
165
|
+
}
|
|
166
|
+
export interface IMatrix extends IMatrixWithScaleData {
|
|
167
|
+
|
|
168
|
+
set(a: number | IMatrixData, b: number, c: number, d: number, e: number, f: number): IMatrix
|
|
169
|
+
setWith(dataWithScale: IMatrixWithScaleData): IMatrix // set scaleX scaleY
|
|
170
|
+
get(): IMatrixData
|
|
150
171
|
clone(): IMatrix
|
|
151
172
|
|
|
152
173
|
translate(x: number, y: number): IMatrix
|
|
153
174
|
translateInner(x: number, y: number): IMatrix
|
|
154
175
|
|
|
155
176
|
scale(x: number, y?: number): IMatrix
|
|
177
|
+
scaleWith(x: number, y?: number): IMatrix // change scaleX scaleY
|
|
156
178
|
scaleOfOuter(origin: IPointData, x: number, y?: number): IMatrix
|
|
157
179
|
scaleOfInner(origin: IPointData, x: number, y?: number): IMatrix
|
|
158
180
|
|
|
@@ -164,19 +186,34 @@ export interface IMatrix extends IMatrixData {
|
|
|
164
186
|
skewOfOuter(origin: IPointData, x: number, y?: number): IMatrix
|
|
165
187
|
skewOfInner(origin: IPointData, x: number, y?: number): IMatrix
|
|
166
188
|
|
|
167
|
-
multiply(
|
|
168
|
-
|
|
169
|
-
|
|
189
|
+
multiply(child: IMatrixData): IMatrix
|
|
190
|
+
multiplyParent(parent: IMatrixData): IMatrix
|
|
191
|
+
|
|
192
|
+
divide(child: IMatrixData): IMatrix
|
|
193
|
+
divideParent(parent: IMatrixData): IMatrix
|
|
170
194
|
invert(): IMatrix
|
|
195
|
+
invertWith(): IMatrix // change scaleX scaleY
|
|
171
196
|
|
|
172
197
|
toOuterPoint(inner: IPointData, to?: IPointData, distance?: boolean): void
|
|
173
198
|
toInnerPoint(outer: IPointData, to?: IPointData, distance?: boolean): void
|
|
174
199
|
|
|
175
|
-
|
|
200
|
+
setLayout(data: ILayoutData, origin?: IPointData): IMatrix
|
|
201
|
+
getLayout(origin?: IPointData, firstSkewY?: boolean): ILayoutData
|
|
202
|
+
|
|
203
|
+
withScale(scaleX?: number, scaleY?: number): IMatrixWithScaleData
|
|
176
204
|
|
|
177
205
|
reset(): void
|
|
178
206
|
}
|
|
179
207
|
|
|
180
208
|
export interface IMatrixWithBoundsData extends IMatrixData, IBoundsData { }
|
|
181
209
|
|
|
182
|
-
export interface
|
|
210
|
+
export interface IMatrixWithScaleData extends IMatrixData, IScaleData { }
|
|
211
|
+
|
|
212
|
+
export interface IMatrixWithOptionScaleData extends IMatrixData {
|
|
213
|
+
scaleX?: number
|
|
214
|
+
scaleY?: number
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export interface IMatrixWithBoundsScaleData extends IMatrixData, IBoundsData, IScaleData { }
|
|
218
|
+
|
|
219
|
+
export interface IMatrixWithLayoutData extends IMatrixData, ILayoutBoundsData { }
|
package/src/path/IPathDrawer.ts
CHANGED
|
@@ -16,8 +16,9 @@ export interface IPathDrawer {
|
|
|
16
16
|
roundRect(x: number, y: number, width: number, height: number, radius?: number | number[]): void
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export interface IPathCreator {
|
|
19
|
+
export interface IPathCreator extends IPathDrawer {
|
|
20
20
|
path: IPathCommandData
|
|
21
|
+
__path: IPathCommandData
|
|
21
22
|
|
|
22
23
|
beginPath(): IPathCreator
|
|
23
24
|
|
|
@@ -27,9 +28,9 @@ export interface IPathCreator {
|
|
|
27
28
|
quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): IPathCreator
|
|
28
29
|
closePath(): IPathCreator
|
|
29
30
|
|
|
30
|
-
arc(x: number, y: number, radius: number, startAngle
|
|
31
|
+
arc(x: number, y: number, radius: number, startAngle?: number, endAngle?: number, anticlockwise?: boolean): IPathCreator
|
|
31
32
|
arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): IPathCreator
|
|
32
|
-
ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation
|
|
33
|
+
ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation?: number, startAngle?: number, endAngle?: number, anticlockwise?: boolean): IPathCreator
|
|
33
34
|
|
|
34
35
|
rect(x: number, y: number, width: number, height: number): IPathCreator
|
|
35
36
|
roundRect(x: number, y: number, width: number, height: number, radius?: number | number[]): IPathCreator
|
|
@@ -38,4 +39,6 @@ export interface IPathCreator {
|
|
|
38
39
|
drawEllipse(x: number, y: number, radiusX: number, radiusY: number, rotation?: number, startAngle?: number, endAngle?: number, anticlockwise?: boolean): IPathCreator
|
|
39
40
|
drawArc(x: number, y: number, radius: number, startAngle?: number, endAngle?: number, anticlockwise?: boolean): IPathCreator
|
|
40
41
|
drawPoints(points: number[], curve?: boolean | number, close?: boolean): IPathCreator
|
|
42
|
+
|
|
43
|
+
clearPath(): IPathCreator
|
|
41
44
|
}
|
|
@@ -4,12 +4,14 @@ import { ILeaf } from '../display/ILeaf'
|
|
|
4
4
|
import { IExportFileType, IExportImageType } from '../file/IFileType'
|
|
5
5
|
import { IBoundsData, ISizeData } from '../math/IMath'
|
|
6
6
|
import { IObject } from '../data/IData'
|
|
7
|
+
import { ICanvasType } from '../canvas/ISkiaCanvas'
|
|
7
8
|
|
|
8
9
|
export interface IPlatform {
|
|
9
10
|
name?: 'web' | 'node' | 'miniapp'
|
|
10
11
|
os?: 'Mac' | 'Windows' | 'Linux'
|
|
11
12
|
requestRender?(render: IFunction): void
|
|
12
13
|
canvas?: ILeaferCanvas
|
|
14
|
+
canvasType?: ICanvasType
|
|
13
15
|
isWorker?: boolean
|
|
14
16
|
isMobile?: boolean
|
|
15
17
|
devicePixelRatio?: number
|
|
@@ -19,17 +21,30 @@ export interface IPlatform {
|
|
|
19
21
|
fullImageShadow?: boolean // safari need
|
|
20
22
|
syncDomFont?: boolean // firefox need
|
|
21
23
|
layout?(target: ILeaf): void
|
|
22
|
-
realtimeLayout?: boolean
|
|
23
24
|
origin?: {
|
|
24
25
|
createCanvas(width: number, height: number, format?: 'svg' | 'pdf'): any
|
|
25
26
|
canvasToDataURL(canvas: any, type?: IExportImageType, quality?: number): string | Promise<string>
|
|
26
27
|
canvasToBolb(canvas: any, type?: IExportFileType, quality?: number): Promise<any>
|
|
27
28
|
canvasSaveAs(canvas: any, filename: string, quality?: number): Promise<void>
|
|
29
|
+
download(url: string, filename: string): Promise<void>
|
|
28
30
|
loadImage(url: string): Promise<any>
|
|
29
31
|
noRepeat?: string // fix: 微信小程序 createPattern 直接使用 no-repeat 有bug,导致无法显示
|
|
30
32
|
},
|
|
33
|
+
roundRectPatch?: boolean // fix: skia-canvas roundRect
|
|
34
|
+
ellipseToCurve?: boolean, // fix: skia 绘制圆环和椭圆弧
|
|
35
|
+
event?: {
|
|
36
|
+
stopDefault(origin: IObject): void
|
|
37
|
+
stopNow(origin: IObject): void
|
|
38
|
+
stop(origin: IObject): void
|
|
39
|
+
},
|
|
31
40
|
miniapp?: IMiniapp
|
|
32
|
-
|
|
41
|
+
image: {
|
|
42
|
+
hitCanvasSize: number // 图片生成碰撞画布的最大尺寸(单边)
|
|
43
|
+
maxCacheSize: number // 最大等级缓存,一般取当前屏幕大小,默认2k: 2560 * 1600
|
|
44
|
+
maxPatternSize: number // 最大repeat pattern缓存, 默认4k: 4096 * 2160
|
|
45
|
+
suffix: string // 需要带上后缀区分dom中image标签的缓存,否则会导致浏览器缓存跨域问题
|
|
46
|
+
crossOrigin: string | false // 跨域设置
|
|
47
|
+
}
|
|
33
48
|
}
|
|
34
49
|
|
|
35
50
|
|
package/src/plugin/IPlugin.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ILeaferBase } from '../app/ILeafer'
|
|
2
2
|
import { IObject } from '../data/IData'
|
|
3
3
|
|
|
4
4
|
export interface IPlugin extends IObject {
|
|
@@ -6,5 +6,5 @@ export interface IPlugin extends IObject {
|
|
|
6
6
|
importVersion: string
|
|
7
7
|
import: string[]
|
|
8
8
|
run(LeaferUI: IObject, config: IObject): void
|
|
9
|
-
onLeafer?(leafer:
|
|
9
|
+
onLeafer?(leafer: ILeaferBase): void
|
|
10
10
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { ILeaferCanvas } from '../canvas/ILeaferCanvas'
|
|
2
2
|
import { ILeaf } from '../display/ILeaf'
|
|
3
|
-
import { IBounds,
|
|
3
|
+
import { IBounds, IMatrixWithScaleData } from '../math/IMath'
|
|
4
4
|
import { IFunction } from '../function/IFunction'
|
|
5
5
|
import { IControl } from '../control/IControl'
|
|
6
6
|
|
|
7
7
|
export interface IRenderOptions {
|
|
8
|
+
includes?: boolean,
|
|
8
9
|
bounds?: IBounds,
|
|
9
10
|
hideBounds?: IBounds,
|
|
10
|
-
matrix?:
|
|
11
|
+
matrix?: IMatrixWithScaleData,
|
|
11
12
|
inCamera?: boolean
|
|
12
13
|
}
|
|
13
14
|
|
|
@@ -31,6 +32,7 @@ export interface IRenderer extends IControl {
|
|
|
31
32
|
|
|
32
33
|
waitAgain: boolean
|
|
33
34
|
changed: boolean
|
|
35
|
+
ignore: boolean
|
|
34
36
|
|
|
35
37
|
config: IRendererConfig
|
|
36
38
|
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import { ILeaf } from '../display/ILeaf'
|
|
2
2
|
import { ILeafList } from '../data/IList'
|
|
3
3
|
import { IPointData } from '../math/IMath'
|
|
4
|
+
import { IBranch } from '../display/IBranch'
|
|
4
5
|
|
|
5
|
-
export interface
|
|
6
|
-
|
|
6
|
+
export interface IPickResult {
|
|
7
|
+
target: ILeaf
|
|
7
8
|
path: ILeafList
|
|
8
9
|
throughPath?: ILeafList
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
export interface
|
|
12
|
+
export interface IPickOptions {
|
|
12
13
|
name?: string
|
|
14
|
+
hitRadius?: number
|
|
13
15
|
through?: boolean
|
|
16
|
+
target?: IBranch
|
|
17
|
+
findList?: ILeaf[]
|
|
14
18
|
exclude?: ILeafList
|
|
15
19
|
ignoreHittable?: boolean
|
|
16
20
|
}
|
|
@@ -19,17 +23,30 @@ export interface ISelectorConfig {
|
|
|
19
23
|
|
|
20
24
|
}
|
|
21
25
|
|
|
26
|
+
export type IAnswer = 0 | 1 | 2 | 3
|
|
27
|
+
|
|
28
|
+
export interface IFindMethod {
|
|
29
|
+
(leaf: ILeaf, options?: any): IAnswer
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface ISelectorProxy {
|
|
33
|
+
list: ILeaf[]
|
|
34
|
+
}
|
|
35
|
+
|
|
22
36
|
export interface ISelector {
|
|
23
37
|
target: ILeaf
|
|
24
38
|
|
|
39
|
+
proxy?: ISelectorProxy
|
|
40
|
+
|
|
25
41
|
config: ISelectorConfig
|
|
26
42
|
|
|
27
|
-
getByPoint(hitPoint: IPointData, hitRadius: number, options?:
|
|
43
|
+
getByPoint(hitPoint: IPointData, hitRadius: number, options?: IPickOptions): IPickResult
|
|
28
44
|
|
|
29
|
-
|
|
30
|
-
getByInnerId(
|
|
31
|
-
getById(
|
|
32
|
-
getByClassName(
|
|
33
|
-
|
|
45
|
+
getBy(condition: number | string | IFindMethod, branch?: ILeaf, one?: boolean, options?: any): ILeaf | ILeaf[]
|
|
46
|
+
getByInnerId(innerId: number, branch?: ILeaf): ILeaf
|
|
47
|
+
getById(id: string, branch?: ILeaf): ILeaf
|
|
48
|
+
getByClassName(className: string, branch?: ILeaf): ILeaf[]
|
|
49
|
+
getByTag(tag: string, branch?: ILeaf): ILeaf[]
|
|
50
|
+
getByMethod(method: IFindMethod, branch?: ILeaf, one?: boolean, options?: any): ILeaf | ILeaf[]
|
|
34
51
|
destroy(): void
|
|
35
52
|
}
|