@leafer/interface 1.0.0-rc.9 → 1.0.1

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/src/math/IMath.ts CHANGED
@@ -1,15 +1,39 @@
1
- import { IObject } from '../data/IData'
1
+ import { IFourNumber, IObject } from '../data/IData'
2
2
 
3
3
  export interface IPointData {
4
4
  x: number
5
5
  y: number
6
6
  }
7
7
 
8
+ export interface IUnitPointData {
9
+ type?: 'percent' | 'px'
10
+ x: number
11
+ y: number
12
+ }
13
+
14
+ export interface IFromToData {
15
+ from: IPointData
16
+ to: IPointData
17
+ }
18
+
19
+ export interface IScrollPointData {
20
+ scrollX: number
21
+ scrollY: number
22
+ }
23
+
24
+ export interface IClientPointData {
25
+ clientX: number
26
+ clientY: number
27
+ }
28
+
8
29
  export interface IPoint extends IPointData {
9
30
  set(x?: number | IPointData, y?: number): IPoint
10
31
  get(): IPointData
11
32
  clone(): IPoint
12
33
 
34
+ move(x: number, y: number): IPoint
35
+ scale(scaleX: number, scaleY?: number): IPoint
36
+ scaleOf(origin: IPointData, scaleX: number, scaleY?: number): IPoint
13
37
  rotate(rotation: number, origin?: IPointData): IPoint
14
38
  rotateOf(origin: IPointData, rotation: number): IPoint
15
39
  getRotation(origin: IPointData, to: IPointData, toOrigin?: IPointData): number
@@ -19,7 +43,7 @@ export interface IPoint extends IPointData {
19
43
 
20
44
  getCenter(to: IPointData): IPoint
21
45
  getDistance(to: IPointData): number
22
- getDistancePoint(to: IPointData, distance: number): IPoint
46
+ getDistancePoint(to: IPointData, distance: number, changeTo?: boolean): IPoint
23
47
 
24
48
  getAngle(to: IPointData): number
25
49
  getAtan2(to: IPointData): number
@@ -60,14 +84,18 @@ export interface IBounds extends IBoundsData, ITwoPointBoundsData {
60
84
  get(): IBoundsData
61
85
  clone(): IBounds
62
86
 
87
+ move(x: number, y: number): IBounds
63
88
  scale(scaleX: number, scaleY?: number): IBounds
64
89
  scaleOf(origin: IPointData, scaleX: number, scaleY?: number): IBounds
65
90
  toOuterOf(matrix: IMatrixData, to?: IBoundsData): IBounds
66
- getFitMatrix(put: IBoundsData): IMatrix
91
+ toInnerOf(matrix: IMatrixData, to?: IBoundsData): IBounds
92
+ getFitMatrix(put: IBoundsData, baseScale?: number): IMatrix
67
93
 
68
- spread(spreadX: number, spreadY?: number): IBounds
94
+ spread(fourNumber: IFourNumber): IBounds
95
+ shrink(fourNumber: IFourNumber): IBounds
69
96
  ceil(): IBounds
70
97
  unsign(): IBounds
98
+ float(maxLength?: number): IBounds
71
99
 
72
100
  add(bounds: IBoundsData): IBounds
73
101
  addList(boundsList: IBoundsData[]): IBounds
@@ -75,7 +103,9 @@ export interface IBounds extends IBoundsData, ITwoPointBoundsData {
75
103
  addListWithFn(list: IObject[], boundsDataHandle: IBoundsDataFn): IBounds
76
104
  setListWithFn(list: IObject[], boundsDataHandle: IBoundsDataFn): IBounds
77
105
 
106
+ setPoint(point: IPointData): IBounds
78
107
  setPoints(points: IPointData[]): IBounds
108
+ addPoint(point: IPointData): IBounds
79
109
  getPoints(): IPointData[] // topLeft, topRight, bottomRight, bottomLeft
80
110
 
81
111
  hitPoint(point: IPointData, pointMatrix?: IMatrixData): boolean
@@ -98,13 +128,15 @@ export interface ITwoPointBoundsData {
98
128
  maxY: number
99
129
  }
100
130
 
101
-
102
- export interface IAutoBoundsData {
131
+ export interface IAutoBoxData {
103
132
  top?: number
104
133
  right?: number
105
134
  bottom?: number
106
135
  left?: number
136
+ }
107
137
 
138
+
139
+ export interface IAutoBoundsData extends IAutoBoxData {
108
140
  width?: number
109
141
  height?: number
110
142
  }
@@ -155,8 +187,10 @@ export type ILayoutAttr =
155
187
 
156
188
  export interface ILayoutBoundsData extends ILayoutData, IBoundsData {
157
189
  }
158
- export interface IMatrix extends IMatrixData {
190
+ export interface IMatrix extends IMatrixWithScaleData {
191
+
159
192
  set(a: number | IMatrixData, b: number, c: number, d: number, e: number, f: number): IMatrix
193
+ setWith(dataWithScale: IMatrixWithScaleData): IMatrix // set scaleX scaleY
160
194
  get(): IMatrixData
161
195
  clone(): IMatrix
162
196
 
@@ -164,6 +198,7 @@ export interface IMatrix extends IMatrixData {
164
198
  translateInner(x: number, y: number): IMatrix
165
199
 
166
200
  scale(x: number, y?: number): IMatrix
201
+ scaleWith(x: number, y?: number): IMatrix // change scaleX scaleY
167
202
  scaleOfOuter(origin: IPointData, x: number, y?: number): IMatrix
168
203
  scaleOfInner(origin: IPointData, x: number, y?: number): IMatrix
169
204
 
@@ -181,12 +216,15 @@ export interface IMatrix extends IMatrixData {
181
216
  divide(child: IMatrixData): IMatrix
182
217
  divideParent(parent: IMatrixData): IMatrix
183
218
  invert(): IMatrix
219
+ invertWith(): IMatrix // change scaleX scaleY
184
220
 
185
221
  toOuterPoint(inner: IPointData, to?: IPointData, distance?: boolean): void
186
222
  toInnerPoint(outer: IPointData, to?: IPointData, distance?: boolean): void
187
223
 
188
- setLayout(data: ILayoutData, origin?: IPointData): IMatrix
189
- getLayout(origin?: IPointData, firstSkewY?: boolean): ILayoutData
224
+ setLayout(data: ILayoutData, origin?: IPointData, around?: IPointData,): IMatrix
225
+ getLayout(origin?: IPointData, around?: IPointData, firstSkewY?: boolean): ILayoutData
226
+
227
+ withScale(scaleX?: number, scaleY?: number): IMatrixWithScaleData
190
228
 
191
229
  reset(): void
192
230
  }
@@ -195,4 +233,11 @@ export interface IMatrixWithBoundsData extends IMatrixData, IBoundsData { }
195
233
 
196
234
  export interface IMatrixWithScaleData extends IMatrixData, IScaleData { }
197
235
 
236
+ export interface IMatrixWithOptionScaleData extends IMatrixData {
237
+ scaleX?: number
238
+ scaleY?: number
239
+ }
240
+
241
+ export interface IMatrixWithBoundsScaleData extends IMatrixData, IBoundsData, IScaleData { }
242
+
198
243
  export interface IMatrixWithLayoutData extends IMatrixData, ILayoutBoundsData { }
@@ -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: number, endAngle: number, anticlockwise?: boolean): IPathCreator
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: number, startAngle: number, endAngle: number, anticlockwise?: boolean): IPathCreator
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
  }
@@ -1,4 +1,4 @@
1
- import { IFunction } from '../function/IFunction'
1
+ import { IFunction, IStringFunction } from '../function/IFunction'
2
2
  import { ILeaferCanvas } from '../canvas/ILeaferCanvas'
3
3
  import { ILeaf } from '../display/ILeaf'
4
4
  import { IExportFileType, IExportImageType } from '../file/IFileType'
@@ -9,16 +9,17 @@ import { ICanvasType } from '../canvas/ISkiaCanvas'
9
9
  export interface IPlatform {
10
10
  name?: 'web' | 'node' | 'miniapp'
11
11
  os?: 'Mac' | 'Windows' | 'Linux'
12
+ toURL(text: string, fileType?: 'text' | 'svg'): string
12
13
  requestRender?(render: IFunction): void
13
14
  canvas?: ILeaferCanvas
14
15
  canvasType?: ICanvasType
15
16
  isWorker?: boolean
16
17
  isMobile?: boolean
17
- devicePixelRatio?: number
18
+ readonly devicePixelRatio?: number
18
19
  intWheelDeltaY?: boolean // firefox / Windows need
19
20
  conicGradientSupport?: boolean
20
21
  conicGradientRotate90?: boolean // firefox need rotate
21
- fullImageShadow?: boolean // safari need
22
+ fullImageShadow?: boolean // safari need
22
23
  syncDomFont?: boolean // firefox need
23
24
  layout?(target: ILeaf): void
24
25
  origin?: {
@@ -26,6 +27,7 @@ export interface IPlatform {
26
27
  canvasToDataURL(canvas: any, type?: IExportImageType, quality?: number): string | Promise<string>
27
28
  canvasToBolb(canvas: any, type?: IExportFileType, quality?: number): Promise<any>
28
29
  canvasSaveAs(canvas: any, filename: string, quality?: number): Promise<void>
30
+ download(url: string, filename: string): Promise<void>
29
31
  loadImage(url: string): Promise<any>
30
32
  noRepeat?: string // fix: 微信小程序 createPattern 直接使用 no-repeat 有bug,导致无法显示
31
33
  },
@@ -38,9 +40,13 @@ export interface IPlatform {
38
40
  },
39
41
  miniapp?: IMiniapp
40
42
  image: {
43
+ hitCanvasSize: number // 图片生成碰撞画布的最大尺寸(单边)
41
44
  maxCacheSize: number // 最大等级缓存,一般取当前屏幕大小,默认2k: 2560 * 1600
42
45
  maxPatternSize: number // 最大repeat pattern缓存, 默认4k: 4096 * 2160
43
- suffix: string // 需要带上后缀区分dom中image标签的缓存,否则会导致浏览器缓存跨域问题
46
+ prefix?: string // url加前缀
47
+ suffix?: string // 需要带上后缀区分dom中image标签的缓存,否则会导致浏览器缓存跨域问题
48
+ crossOrigin: string | false // 跨域设置
49
+ getRealURL: IStringFunction // 处理前缀、后缀
44
50
  }
45
51
  }
46
52
 
@@ -1,6 +1,6 @@
1
1
  import { ILeaferCanvas } from '../canvas/ILeaferCanvas'
2
2
  import { ILeaf } from '../display/ILeaf'
3
- import { IBounds, IMatrix } from '../math/IMath'
3
+ import { IBounds, IMatrixWithScaleData } from '../math/IMath'
4
4
  import { IFunction } from '../function/IFunction'
5
5
  import { IControl } from '../control/IControl'
6
6
 
@@ -8,7 +8,7 @@ export interface IRenderOptions {
8
8
  includes?: boolean,
9
9
  bounds?: IBounds,
10
10
  hideBounds?: IBounds,
11
- matrix?: IMatrix,
11
+ matrix?: IMatrixWithScaleData,
12
12
  inCamera?: boolean
13
13
  }
14
14
 
@@ -32,6 +32,7 @@ export interface IRenderer extends IControl {
32
32
 
33
33
  waitAgain: boolean
34
34
  changed: boolean
35
+ ignore: boolean
35
36
 
36
37
  config: IRendererConfig
37
38
 
@@ -1,33 +1,44 @@
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 ISelectPathResult {
6
- leaf: ILeaf
6
+ export interface IPickResult {
7
+ target: ILeaf
7
8
  path: ILeafList
8
9
  throughPath?: ILeafList
9
10
  }
10
11
 
11
- export interface ISelectPathOptions {
12
+ export interface IPickOptions {
12
13
  name?: string
14
+ hitRadius?: number
13
15
  through?: boolean
16
+ target?: IBranch
17
+ findList?: ILeaf[]
18
+ bottomList?: IPickBottom[] // 底部可拾取的虚拟元素
14
19
  exclude?: ILeafList
15
20
  ignoreHittable?: boolean
16
21
  }
17
22
 
23
+ export interface IPickBottom {
24
+ target: ILeaf
25
+ proxy?: ILeaf
26
+ }
27
+
18
28
  export interface ISelectorConfig {
19
29
 
20
30
  }
21
31
 
22
- export enum AnswerType {
23
- No = 0,
24
- Yes = 1,
25
- NoAndSkip = 2,
26
- YesAndSkip = 3
32
+ export type IAnswer = 0 | 1 | 2 | 3
33
+
34
+ export interface IFindCondition {
35
+ id?: number | string,
36
+ className?: string,
37
+ tag?: string | string[]
27
38
  }
28
39
 
29
40
  export interface IFindMethod {
30
- (leaf: ILeaf, options?: any): AnswerType
41
+ (leaf: ILeaf, options?: any): IAnswer
31
42
  }
32
43
 
33
44
  export interface ISelectorProxy {
@@ -41,7 +52,7 @@ export interface ISelector {
41
52
 
42
53
  config: ISelectorConfig
43
54
 
44
- getByPoint(hitPoint: IPointData, hitRadius: number, options?: ISelectPathOptions): ISelectPathResult
55
+ getByPoint(hitPoint: IPointData, hitRadius: number, options?: IPickOptions): IPickResult
45
56
 
46
57
  getBy(condition: number | string | IFindMethod, branch?: ILeaf, one?: boolean, options?: any): ILeaf | ILeaf[]
47
58
  getByInnerId(innerId: number, branch?: ILeaf): ILeaf