@leafer-ui/interface 1.0.0-beta.12 → 1.0.0-beta.16

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,12 +1,15 @@
1
1
  {
2
2
  "name": "@leafer-ui/interface",
3
- "version": "1.0.0-beta.12",
3
+ "version": "1.0.0-beta.16",
4
4
  "description": "@leafer-ui/interface",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
7
7
  "main": "src/index.ts",
8
+ "types": "types/index.d.ts",
8
9
  "files": [
9
- "src"
10
+ "src",
11
+ "types",
12
+ "dist"
10
13
  ],
11
14
  "repository": {
12
15
  "type": "git",
@@ -19,6 +22,6 @@
19
22
  "leaferjs"
20
23
  ],
21
24
  "dependencies": {
22
- "@leafer/interface": "1.0.0-beta.12"
25
+ "@leafer/interface": "1.0.0-beta.16"
23
26
  }
24
27
  }
package/src/IUI.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ILeaf, ILeafComputedData, ILeafData, ILeafInputData, ILeaferCanvas, IRenderOptions, IPathDrawer, IPointData, IPath2D, IPathCommandData, IWindingRule, ILeaferImageConfig, IBoundsData, IObject, __Number, IPathString, ILeaferImage, IBlob } from '@leafer/interface'
1
+ import { ILeaf, ILeafComputedData, ILeafData, ILeafInputData, ILeaferCanvas, IRenderOptions, IPathDrawer, IPointData, IPath2D, IPathCommandData, IWindingRule, ILeaferImageConfig, IBoundsData, IObject, __Number, IPathString, ILeaferImage, IBlob, IPathCreator } from '@leafer/interface'
2
2
 
3
3
  import {
4
4
  IFillAttrData, IFillInputData, IFillComputedData,
@@ -16,10 +16,14 @@ import { IExportOptions } from './module/IExport'
16
16
  export interface ILine extends IUI {
17
17
  __: ILineData
18
18
  toPoint: IPointData
19
+ points: number[]
20
+ curve: boolean | number
19
21
  }
20
22
  export interface ILineData extends IUIData { }
21
- export interface ILineInputData extends IUIInputData {
23
+ export interface ILineInputData extends IUIBaseInputData {
22
24
  toPoint?: IPointData
25
+ points?: number[]
26
+ curve?: boolean | number
23
27
  }
24
28
 
25
29
 
@@ -28,7 +32,7 @@ export interface IRect extends IUI {
28
32
  __: IRectData
29
33
  }
30
34
  export interface IRectData extends IUIData { }
31
- export interface IRectInputData extends IUIInputData { }
35
+ export interface IRectInputData extends IUIBaseInputData { }
32
36
 
33
37
 
34
38
  // Ellipse
@@ -44,34 +48,38 @@ interface IEllipseAttrData {
44
48
  innerRadius?: number
45
49
  }
46
50
  export interface IEllipseData extends IEllipseAttrData, IUIData { }
47
- export interface IEllipseInputData extends IEllipseAttrData, IUIInputData { }
51
+ export interface IEllipseInputData extends IEllipseAttrData, IUIBaseInputData { }
48
52
 
49
53
 
50
54
  // Polygon
51
55
  export interface IPolygon extends IUI {
52
56
  __: IPolygonData
53
57
  sides: number
58
+ points: number[]
59
+ curve: boolean | number
54
60
  }
55
61
  interface IPolygonAttrData {
56
62
  sides?: number
63
+ points?: number[]
64
+ curve?: boolean | number
57
65
  }
58
66
  export interface IPolygonData extends IPolygonAttrData, IUIData { }
59
- export interface IPolygonInputData extends IPolygonAttrData, IUIInputData { }
67
+ export interface IPolygonInputData extends IPolygonAttrData, IUIBaseInputData { }
60
68
 
61
69
 
62
70
  // Star
63
71
  export interface IStar extends IUI {
64
72
  __: IStarData
65
- points: number
73
+ corners: number
66
74
  innerRadius: number
67
75
  }
68
76
  interface IStarAttrData {
69
- points?: number
77
+ corners?: number
70
78
  innerRadius?: number
71
79
  }
72
80
 
73
81
  export interface IStarData extends IStarAttrData, IUIData { }
74
- export interface IStarInputData extends IStarAttrData, IUIInputData { }
82
+ export interface IStarInputData extends IStarAttrData, IUIBaseInputData { }
75
83
 
76
84
  // Path
77
85
  export interface IPath extends IUI {
@@ -83,34 +91,20 @@ export interface IPathData extends IUIData {
83
91
  path?: IPathCommandData
84
92
  windingRule?: IWindingRule
85
93
  }
86
- export interface IPathInputData extends IUIInputData {
94
+ export interface IPathInputData extends IUIBaseInputData {
87
95
  path?: IPathCommandData | IPathString
88
96
  windingRule?: IWindingRule
89
97
  }
90
98
 
91
99
  // Pen
92
100
 
93
- export interface IPen extends IGroup {
101
+ export interface IPen extends IGroup, IPathCreator {
94
102
  __: IPenData
95
- path: IPath
103
+ pathElement: IPath
96
104
  pathStyle: IPathInputData
97
- pathData: IPathCommandData
98
-
99
- moveTo(x: number, y: number): IPen
100
- lineTo(x: number, y: number): IPen
101
- bezierCurveTo(x1: number, y1: number, x2: number, y2: number, x: number, y: number): IPen
102
- quadraticCurveTo(x1: number, y1: number, x: number, y: number): IPen
103
-
104
- rect(x: number, y: number, width: number, height: number): IPen
105
- roundRect(x: number, y: number, width: number, height: number, cornerRadius: number | number[]): IPen
106
- ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation?: number, startAngle?: number, endAngle?: number, anticlockwise?: boolean): IPen
107
- arc(x: number, y: number, radius: number, startAngle?: number, endAngle?: number, anticlockwise?: boolean): IPen
108
- arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): IPen
109
-
110
- close(): IPen
111
- clear(): IPen
112
-
105
+ path: IPathCommandData
113
106
  paint(): void
107
+ clear(): void
114
108
  }
115
109
 
116
110
  export interface IPenData extends IGroupData { }
@@ -131,7 +125,7 @@ export interface ITextData extends ITextAttrData, ITextStyleComputedData, IUIDat
131
125
  __lineHeight?: number
132
126
  __letterSpacing?: number
133
127
  }
134
- export interface ITextInputData extends ITextAttrData, ITextStyleInputData, IUIInputData {
128
+ export interface ITextInputData extends ITextAttrData, ITextStyleInputData, IUIBaseInputData {
135
129
 
136
130
  }
137
131
 
@@ -186,7 +180,7 @@ interface IImageAttrData {
186
180
  url?: string
187
181
  }
188
182
  export interface IImageData extends IImageAttrData, IRectData { }
189
- export interface IImageInputData extends IImageAttrData, IUIInputData { }
183
+ export interface IImageInputData extends IImageAttrData, IUIBaseInputData { }
190
184
 
191
185
  export interface ICanvas extends IRect {
192
186
  __: ICanvasData
@@ -200,7 +194,7 @@ interface ICanvasAttrData {
200
194
  smooth?: boolean
201
195
  }
202
196
  export interface ICanvasData extends ICanvasAttrData, IRectData { }
203
- export interface ICanvasInputData extends ICanvasAttrData, IUIInputData { }
197
+ export interface ICanvasInputData extends ICanvasAttrData, IUIBaseInputData { }
204
198
 
205
199
 
206
200
  // Leafer
@@ -253,15 +247,15 @@ export interface IGroup extends IUI {
253
247
  removeAll(): void
254
248
  }
255
249
  export interface IGroupData extends IUIData { }
256
- export interface IGroupInputData extends IUIInputData { }
250
+ export interface IGroupInputData extends IUIBaseInputData { }
257
251
 
258
252
  // UI
259
253
  export interface IUI extends IFillAttrData, IStrokeAttrData, ICornerRadiusAttrData, IEffectAttrData, ILeaf {
260
254
  __: IUIData
261
255
  parent?: IGroup
262
256
 
263
- set(data: IUITagInputData): void
264
- get(): IUITagInputData
257
+ set(data: IUIInputData): void
258
+ toJSON(): IUIInputData
265
259
 
266
260
  getPath(curve?: boolean): IPathCommandData
267
261
  getPathString(curve?: boolean): IPathString
@@ -270,6 +264,8 @@ export interface IUI extends IFillAttrData, IStrokeAttrData, ICornerRadiusAttrDa
270
264
  __drawAfterFill?(canvas: ILeaferCanvas, options: IRenderOptions): void
271
265
 
272
266
  export(filename: string, options?: IExportOptions | number): Promise<IBlob | string | boolean>
267
+ clone(): IUI
268
+
273
269
  }
274
270
 
275
271
  export interface IUIData extends IUIComputedData, ILeafData {
@@ -305,16 +301,20 @@ export interface IUIData extends IUIComputedData, ILeafData {
305
301
  }
306
302
  export interface IUIComputedData extends IFillComputedData, IBorderComputedData, IStrokeComputedData, ITextStyleComputedData, ICornerRadiusComputedData, IEffectComputedData, ILeafComputedData {
307
303
  padding?: number | number[]
304
+
308
305
  locked?: boolean
309
306
  }
310
307
 
311
- export interface IUIInputData extends IFillInputData, IStrokeInputData, ITextStyleInputData, ICornerRadiusInputData, IEffectInputData, ILeafInputData {
308
+ export interface IUIBaseInputData extends IFillInputData, IStrokeInputData, ITextStyleInputData, ICornerRadiusInputData, IEffectInputData, ILeafInputData {
312
309
  padding?: number | number[]
313
310
  locked?: boolean
311
+ children?: IUIBaseInputData[]
314
312
  }
315
313
 
316
314
 
317
315
  export type IUITag =
316
+ | 'App'
317
+ | 'Leafer'
318
318
  | 'Rect'
319
319
  | 'Ellipse'
320
320
  | 'Polygon'
@@ -330,6 +330,6 @@ export type IUITag =
330
330
  | 'Box'
331
331
 
332
332
 
333
- export interface IUITagInputData extends IRectInputData, IEllipseInputData, IPolygonInputData, IStarInputData, ILineInputData, IPathInputData, ITextInputData, IImageInputData, IGroupInputData, IFrameInputData, IObject {
334
- tagName?: IUITag
333
+ export interface IUIInputData extends IRectInputData, IEllipseInputData, IPolygonInputData, IStarInputData, ILineInputData, IPathInputData, ITextInputData, IImageInputData, IGroupInputData, IFrameInputData, IUIBaseInputData, IObject {
334
+
335
335
  }
package/src/index.ts CHANGED
@@ -15,8 +15,8 @@ export {
15
15
  IBox, IBoxInputData, IBoxData,
16
16
  IGroup, IGroupInputData, IGroupData,
17
17
  ILeaferInputData, ILeaferData,
18
- IUI, IUIInputData, IUIData,
19
- IUITag, IUITagInputData
18
+ IUI, IUIBaseInputData, IUIData,
19
+ IUITag, IUIInputData
20
20
  } from './IUI'
21
21
  export { IUnitData, IVectorPath, IShadowEffect, IBlurEffect, IGrayscaleEffect, IStrokeAlign, IStrokeJoin, IStrokeCap, IRGB, IRGBA, IColor, IColorStop, IPaint, IGradientPaint, IImagePaint, IImagePaintMode, IFontWeight, ITextCase, ITextDecoration, ITextAlign, IVerticalAlign, IOverflow } from './type/IType'
22
22
  export { ICornerRadiusString, IStrokeWidthString, IPaintString, IShadowString, IPercent, IDashPatternString, IColorString as IStringColor } from './type/IStringType'
@@ -25,9 +25,11 @@ export { ILeafFill, ILeafPaint, ILeafPaintPatternData, ILeafPaintColor, ILeafStr
25
25
  export { IUIRenderModule, IRectRenderModule, IImageRenderModule, ITextRenderModule, IGroupRenderModule, IFrameRenderModule } from './module/IUIRender'
26
26
  export { IUIBoundsModule } from './module/IUIBounds'
27
27
  export { IUIHitModule } from './module/IUIHit'
28
+ export { ITextConvertModule } from './module/ITextConvert'
29
+ export { IColorConvertModule } from './module/IColorConvert'
28
30
  export { IExportModule, IExportOptions, IExportResult, IExportResultFunction } from './module/IExport'
29
31
 
32
+
30
33
  export { IPaintModule } from './module/IPaint'
31
34
  export { IEffectModule } from './module/IEffect'
32
- export { ICachedShape } from './ICachedShape'
33
-
35
+ export { ICachedShape } from './ICachedShape'
@@ -0,0 +1,5 @@
1
+ import { IColor } from '../type/IType'
2
+
3
+ export interface IColorConvertModule {
4
+ string?(color: IColor, opacity?: number): string
5
+ }
@@ -15,5 +15,5 @@ export interface IExportResultFunction {
15
15
 
16
16
 
17
17
  export interface IExportModule {
18
- export(leaf: ILeaf, filename: IExportFileType | string, options?: IExportOptions | number | boolean): Promise<IExportResult>
18
+ export?(leaf: ILeaf, filename: IExportFileType | string, options?: IExportOptions | number | boolean): Promise<IExportResult>
19
19
  }
@@ -0,0 +1,5 @@
1
+ import { ITextData, ITextDrawData } from '../IUI'
2
+
3
+ export interface ITextConvertModule {
4
+ getDrawData?(content: string, style: ITextData): ITextDrawData
5
+ }
@@ -14,7 +14,7 @@ export interface ILeafPaint {
14
14
  opacity?: number
15
15
  image?: ILeaferImage
16
16
  loadId?: number
17
- patternId?: number
17
+ patternId?: string
18
18
  data?: ILeafPaintPatternData
19
19
  }
20
20
 
package/src/type/IType.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { IPointData, IPathCommandData, IWindingRule, IBlendMode } from '@leafer/interface'
1
+ import { IPointData, IPathCommandData, IWindingRule, IBlendMode, IExportFileType } from '@leafer/interface'
2
2
  import { IColorString } from './IStringType'
3
3
 
4
4
  export interface IUnitData {
@@ -61,6 +61,7 @@ export interface IImagePaint extends IPaintBase {
61
61
  type: "image"
62
62
  url: string
63
63
  mode?: IImagePaintMode
64
+ format?: IExportFileType
64
65
 
65
66
  filters?: IImageFilters
66
67
 
@@ -0,0 +1,595 @@
1
+ import { IPointData, IExportFileType, IWindingRule, IPathCommandData, IBlendMode, IMatrixData, ILeaferImage, IBlob, ILeaf, IPathString, IPathCreator, IBoundsData, ILeaferImageConfig, ILeaferCanvas, IRenderOptions, IPathDrawer, ILeafData, IPath2D, ILeafComputedData, ILeafInputData, IObject, ILeafRender, ILeafBounds, ILeafHit, ICachedLeaf, IBooleanMap } from '@leafer/interface';
2
+ export * from '@leafer/interface';
3
+
4
+ type IPercent = string;
5
+ type IColorString = string;
6
+ type ICornerRadiusString = string;
7
+ type IStrokeWidthString = string;
8
+ type IDashPatternString = string;
9
+ type IPaintString = ISolidPaintString | IGradientPaintString | IImagePaintString;
10
+ type ISolidPaintString = string;
11
+ type IGradientPaintString = string;
12
+ type IImagePaintString = string;
13
+ type IShadowString = string;
14
+
15
+ interface IUnitData {
16
+ type: 'percent' | 'px';
17
+ value: number;
18
+ }
19
+ type IPaint = ISolidPaint | IGradientPaint | IImagePaint;
20
+ interface IPaintBase {
21
+ type: IPaintType;
22
+ blendMode?: IBlendMode;
23
+ visible?: boolean;
24
+ opacity?: number;
25
+ }
26
+ type IPaintType = 'image' | 'solid' | IGradientType;
27
+ type IGradientType = 'linear' | 'radial' | 'angular';
28
+ interface ISolidPaint extends IPaintBase {
29
+ type: 'solid';
30
+ color: IColor;
31
+ }
32
+ type IColor = IColorString | IRGB | IRGBA;
33
+ interface IRGB {
34
+ r: number;
35
+ g: number;
36
+ b: number;
37
+ a?: number;
38
+ }
39
+ interface IRGBA extends IRGB {
40
+ a: number;
41
+ }
42
+ interface IGradientPaint extends IPaintBase {
43
+ type: IGradientType;
44
+ from?: IPointData;
45
+ to?: IPointData;
46
+ stretch?: number;
47
+ stops: IColorStop[];
48
+ }
49
+ interface IColorStop {
50
+ offset: number;
51
+ color: IColor;
52
+ }
53
+ interface IImagePaint extends IPaintBase {
54
+ type: "image";
55
+ url: string;
56
+ mode?: IImagePaintMode;
57
+ format?: IExportFileType;
58
+ filters?: IImageFilters;
59
+ offset?: IPointData;
60
+ scale?: number | IPointData;
61
+ rotation?: number;
62
+ }
63
+ interface IImageFilters {
64
+ exposure?: number;
65
+ contrast?: number;
66
+ saturation?: number;
67
+ temperature?: number;
68
+ tint?: number;
69
+ highlights?: number;
70
+ shadows?: number;
71
+ }
72
+ type IImagePaintMode = 'cover' | 'fit' | 'strench' | 'clip' | 'repeat';
73
+ type IStrokeAlign = 'inside' | 'outside' | 'center';
74
+ type IStrokeCap = 'none' | 'round' | 'square' | 'arrow-lines' | 'arrow-equilateral';
75
+ type IStrokeJoin = 'bevel' | 'round' | 'miter';
76
+ type ITextAlign = 'left' | 'center' | 'right' | 'justify';
77
+ type IVerticalAlign = 'top' | 'middle' | 'bottom';
78
+ type ITextCase = 'upper' | 'lower' | 'title' | 'none' | 'small-caps';
79
+ type IFontWeight = IFontWeightNumer | IFontWeightString;
80
+ type IFontWeightNumer = 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;
81
+ type IFontWeightString = 'thin' | 'extra-light' | 'light' | 'normal' | 'medium' | 'semi-bold' | 'bold' | 'extra-bold' | 'black';
82
+ type ITextDecoration = 'none' | 'under' | 'delete';
83
+ interface IVectorPath {
84
+ rule?: IWindingRule;
85
+ data: string | IPathCommandData;
86
+ }
87
+ interface IShadowEffect {
88
+ x: number;
89
+ y: number;
90
+ blur: number;
91
+ spread?: number;
92
+ color: IColorString | IColor;
93
+ blendMode?: IBlendMode;
94
+ visible?: boolean;
95
+ box?: boolean;
96
+ }
97
+ interface IBlurEffect {
98
+ blur: number;
99
+ visible?: boolean;
100
+ }
101
+ interface IGrayscaleEffect {
102
+ grayscale: number;
103
+ visible?: boolean;
104
+ }
105
+ type IOverflow = 'show' | 'hide';
106
+
107
+ type ILeafPaintColor = IColorString | CanvasGradient | CanvasPattern;
108
+ interface ILeafPaint {
109
+ type?: IPaintType;
110
+ style?: ILeafPaintColor;
111
+ transform?: IMatrixData;
112
+ blendMode?: IBlendMode;
113
+ opacity?: number;
114
+ image?: ILeaferImage;
115
+ loadId?: number;
116
+ patternId?: string;
117
+ data?: ILeafPaintPatternData;
118
+ }
119
+ interface ILeafPaintPatternData {
120
+ width?: number;
121
+ height?: number;
122
+ scaleX?: number;
123
+ scaleY?: number;
124
+ opacity?: number;
125
+ transform?: IMatrixData;
126
+ mode?: IImagePaintMode;
127
+ }
128
+ type ILeafFill = ILeafPaint;
129
+ interface ILeafStrokePaint extends ILeafPaint {
130
+ strokeAlign?: IStrokeAlign;
131
+ strokeWidth?: number;
132
+ strokeCap?: IStrokeCap;
133
+ strokeJoin?: IStrokeJoin;
134
+ dashPattern?: number[];
135
+ miterLimit?: number;
136
+ }
137
+ interface ILeafShadowEffect {
138
+ x: number;
139
+ y: number;
140
+ blur: number;
141
+ spread?: number;
142
+ color: IColorString;
143
+ blendMode?: IBlendMode;
144
+ box?: boolean;
145
+ }
146
+
147
+ interface ICornerRadiusAttrData {
148
+ cornerRadius: number | number[] | ICornerRadiusString;
149
+ cornerSmoothing: number;
150
+ }
151
+ interface ICornerRadiusInputData {
152
+ cornerRadius?: number | number[] | ICornerRadiusString;
153
+ cornerSmoothing?: number;
154
+ }
155
+ interface ICornerRadiusComputedData {
156
+ cornerRadius?: number;
157
+ cornerSmoothing?: number;
158
+ }
159
+ interface IFillAttrData {
160
+ fill: IPaint | IPaint[] | IPaintString;
161
+ }
162
+ interface IFillInputData {
163
+ fill?: IPaint | IPaint[] | IPaintString;
164
+ }
165
+ interface IFillComputedData {
166
+ fill?: IColorString | ILeafPaint[];
167
+ }
168
+ interface IBorderComputedData {
169
+ borderWidth?: number | number[];
170
+ borderRadius?: number | number[];
171
+ }
172
+ interface IStrokeAttrData {
173
+ stroke: IPaint | IPaint[] | IPaintString;
174
+ strokeAlign: IStrokeAlign;
175
+ strokeWidth: number | number[] | IStrokeWidthString;
176
+ strokeCap: IStrokeCap;
177
+ strokeJoin: IStrokeJoin;
178
+ dashPattern: number[] | IDashPatternString;
179
+ dashOffset: number;
180
+ miterLimit: number;
181
+ }
182
+ interface IStrokeInputData {
183
+ stroke?: IPaint | IPaint[] | IPaintString;
184
+ strokeAlign?: IStrokeAlign;
185
+ strokeWidth?: number | number[] | IStrokeWidthString;
186
+ strokeCap?: IStrokeCap;
187
+ strokeJoin?: IStrokeJoin;
188
+ dashPattern?: number[] | IDashPatternString;
189
+ dashOffset?: number;
190
+ miterLimit?: number;
191
+ }
192
+ interface IStrokeComputedData {
193
+ stroke?: IColorString | ILeafStrokePaint[];
194
+ strokeAlign?: IStrokeAlign;
195
+ strokeWidth?: number;
196
+ strokeWidths?: number[];
197
+ strokeCap?: IStrokeCap;
198
+ strokeJoin?: IStrokeJoin;
199
+ dashPattern?: number[];
200
+ dashOffset?: number;
201
+ miterLimit?: number;
202
+ }
203
+ interface ITextStyleAttrData {
204
+ fontFamily: string;
205
+ fontSize: number;
206
+ fontWeight: IFontWeight;
207
+ italic: boolean;
208
+ textCase: ITextCase;
209
+ textDecoration: ITextDecoration;
210
+ letterSpacing: number | IUnitData;
211
+ lineHeight: number | IUnitData;
212
+ paraIndent: number;
213
+ paraSpacing: number;
214
+ textAlign: ITextAlign;
215
+ verticalAlign: IVerticalAlign;
216
+ textOverflow: IOverflow | string;
217
+ }
218
+ interface ITextStyleInputData {
219
+ fontFamily?: string;
220
+ fontSize?: number;
221
+ fontWeight?: IFontWeight;
222
+ italic?: boolean;
223
+ textCase?: ITextCase;
224
+ textDecoration?: ITextDecoration;
225
+ letterSpacing?: number | IUnitData;
226
+ lineHeight?: number | IUnitData;
227
+ paraIndent?: number;
228
+ paraSpacing?: number;
229
+ textAlign?: ITextAlign;
230
+ verticalAlign?: IVerticalAlign;
231
+ textOverflow?: IOverflow | string;
232
+ }
233
+ interface ITextStyleComputedData {
234
+ fontFamily?: string;
235
+ fontSize?: number;
236
+ fontWeight?: IFontWeight;
237
+ italic?: boolean;
238
+ textCase?: ITextCase;
239
+ textDecoration?: ITextDecoration;
240
+ letterSpacing?: number;
241
+ lineHeight?: number;
242
+ paraIndent?: number;
243
+ paraSpacing?: number;
244
+ textAlign?: ITextAlign;
245
+ verticalAlign?: IVerticalAlign;
246
+ textOverflow?: IOverflow;
247
+ }
248
+ interface IEffectAttrData {
249
+ shadow: IShadowEffect | IShadowEffect[] | IShadowString;
250
+ innerShadow: IShadowEffect | IShadowEffect[] | IShadowString;
251
+ blur: number | IBlurEffect;
252
+ backgroundBlur: number | IBlurEffect;
253
+ grayscale: number | IGrayscaleEffect;
254
+ }
255
+ interface IEffectInputData {
256
+ shadow?: IShadowEffect | IShadowEffect[] | IShadowString;
257
+ innerShadow?: IShadowEffect | IShadowEffect[] | IShadowString;
258
+ blur?: number | IBlurEffect;
259
+ backgroundBlur?: number | IBlurEffect;
260
+ grayscale?: number | IGrayscaleEffect;
261
+ }
262
+ interface IEffectComputedData {
263
+ shadow?: ILeafShadowEffect[];
264
+ innerShadow?: ILeafShadowEffect[];
265
+ blur?: number;
266
+ backgroundBlur?: number;
267
+ grayscale?: number;
268
+ }
269
+
270
+ interface IExportOptions {
271
+ quality?: number;
272
+ blob?: boolean;
273
+ }
274
+ interface IExportResult {
275
+ data: IBlob | string | boolean;
276
+ }
277
+ interface IExportResultFunction {
278
+ (data: IExportResult): void;
279
+ }
280
+ interface IExportModule {
281
+ export?(leaf: ILeaf, filename: IExportFileType | string, options?: IExportOptions | number | boolean): Promise<IExportResult>;
282
+ }
283
+
284
+ interface ILine extends IUI {
285
+ __: ILineData;
286
+ toPoint: IPointData;
287
+ points: number[];
288
+ curve: boolean | number;
289
+ }
290
+ interface ILineData extends IUIData {
291
+ }
292
+ interface ILineInputData extends IUIBaseInputData {
293
+ toPoint?: IPointData;
294
+ points?: number[];
295
+ curve?: boolean | number;
296
+ }
297
+ interface IRect extends IUI {
298
+ __: IRectData;
299
+ }
300
+ interface IRectData extends IUIData {
301
+ }
302
+ interface IRectInputData extends IUIBaseInputData {
303
+ }
304
+ interface IEllipse extends IUI {
305
+ __: IEllipseData;
306
+ startAngle: number;
307
+ endAngle: number;
308
+ innerRadius: number;
309
+ }
310
+ interface IEllipseAttrData {
311
+ startAngle?: number;
312
+ endAngle?: number;
313
+ innerRadius?: number;
314
+ }
315
+ interface IEllipseData extends IEllipseAttrData, IUIData {
316
+ }
317
+ interface IEllipseInputData extends IEllipseAttrData, IUIBaseInputData {
318
+ }
319
+ interface IPolygon extends IUI {
320
+ __: IPolygonData;
321
+ sides: number;
322
+ points: number[];
323
+ curve: boolean | number;
324
+ }
325
+ interface IPolygonAttrData {
326
+ sides?: number;
327
+ points?: number[];
328
+ curve?: boolean | number;
329
+ }
330
+ interface IPolygonData extends IPolygonAttrData, IUIData {
331
+ }
332
+ interface IPolygonInputData extends IPolygonAttrData, IUIBaseInputData {
333
+ }
334
+ interface IStar extends IUI {
335
+ __: IStarData;
336
+ corners: number;
337
+ innerRadius: number;
338
+ }
339
+ interface IStarAttrData {
340
+ corners?: number;
341
+ innerRadius?: number;
342
+ }
343
+ interface IStarData extends IStarAttrData, IUIData {
344
+ }
345
+ interface IStarInputData extends IStarAttrData, IUIBaseInputData {
346
+ }
347
+ interface IPath extends IUI {
348
+ __: IPathData;
349
+ path: IPathCommandData | IPathString;
350
+ windingRule: IWindingRule;
351
+ }
352
+ interface IPathData extends IUIData {
353
+ path?: IPathCommandData;
354
+ windingRule?: IWindingRule;
355
+ }
356
+ interface IPathInputData extends IUIBaseInputData {
357
+ path?: IPathCommandData | IPathString;
358
+ windingRule?: IWindingRule;
359
+ }
360
+ interface IPen extends IGroup, IPathCreator {
361
+ __: IPenData;
362
+ pathElement: IPath;
363
+ pathStyle: IPathInputData;
364
+ path: IPathCommandData;
365
+ paint(): void;
366
+ clear(): void;
367
+ }
368
+ interface IPenData extends IGroupData {
369
+ }
370
+ interface IPenInputData extends IGroupInputData {
371
+ }
372
+ interface IText extends ITextStyleAttrData, IUI {
373
+ __: ITextData;
374
+ text: string;
375
+ }
376
+ interface ITextAttrData {
377
+ text?: string;
378
+ }
379
+ interface ITextData extends ITextAttrData, ITextStyleComputedData, IUIData {
380
+ __baseLine?: number;
381
+ __lineHeight?: number;
382
+ __letterSpacing?: number;
383
+ }
384
+ interface ITextInputData extends ITextAttrData, ITextStyleInputData, IUIBaseInputData {
385
+ }
386
+ interface ITextRowData {
387
+ x?: number;
388
+ y?: number;
389
+ width?: number;
390
+ height?: number;
391
+ text?: string;
392
+ data?: ITextCharData[];
393
+ words?: ITextWordData[];
394
+ paraStart?: boolean;
395
+ paraEnd?: boolean;
396
+ isOverflow?: boolean;
397
+ }
398
+ interface ITextWordData {
399
+ x?: number;
400
+ y?: number;
401
+ width?: number;
402
+ height?: number;
403
+ data?: ITextCharData[];
404
+ }
405
+ interface ITextCharData {
406
+ x?: number;
407
+ y?: number;
408
+ width?: number;
409
+ height?: number;
410
+ char?: string;
411
+ }
412
+ interface ITextDrawData {
413
+ bounds: IBoundsData;
414
+ rows: ITextRowData[];
415
+ paraNumber: number;
416
+ font: string;
417
+ decorationY?: number;
418
+ decorationHeight?: number;
419
+ overflow?: number;
420
+ }
421
+ interface IImage extends IRect, ILeaferImageConfig {
422
+ __: IImageData;
423
+ url: string;
424
+ ready: boolean;
425
+ image?: ILeaferImage;
426
+ }
427
+ interface IImageAttrData {
428
+ url?: string;
429
+ }
430
+ interface IImageData extends IImageAttrData, IRectData {
431
+ }
432
+ interface IImageInputData extends IImageAttrData, IUIBaseInputData {
433
+ }
434
+ interface ICanvas extends IRect {
435
+ __: ICanvasData;
436
+ pixelRatio: number;
437
+ smooth: boolean;
438
+ canvas: ILeaferCanvas;
439
+ __updateSize(): void;
440
+ }
441
+ interface ICanvasAttrData {
442
+ pixelRatio?: number;
443
+ smooth?: boolean;
444
+ }
445
+ interface ICanvasData extends ICanvasAttrData, IRectData {
446
+ }
447
+ interface ICanvasInputData extends ICanvasAttrData, IUIBaseInputData {
448
+ }
449
+ interface ILeaferData extends IGroupData {
450
+ pixelRatio?: number;
451
+ }
452
+ interface ILeaferInputData extends IGroupInputData {
453
+ pixelRatio?: number;
454
+ }
455
+ interface IFrame extends IBox {
456
+ __: IFrameData;
457
+ }
458
+ interface IFrameData extends IBoxData {
459
+ }
460
+ interface IFrameInputData extends IBoxInputData {
461
+ }
462
+ interface IBox extends IGroup {
463
+ __: IBoxData;
464
+ overflow: IOverflow;
465
+ __updateRectRenderBounds(): void;
466
+ __renderGroup(canvas: ILeaferCanvas, options: IRenderOptions): void;
467
+ }
468
+ interface IBoxData extends IGroupData {
469
+ overflow?: IOverflow;
470
+ }
471
+ interface IBoxInputData extends IGroupInputData {
472
+ overflow?: IOverflow;
473
+ }
474
+ interface IGroup extends IUI {
475
+ __: IGroupData;
476
+ children: IUI[];
477
+ mask?: IUI;
478
+ add(child: IUI, index?: number): void;
479
+ addAt(child: IUI, index: number): void;
480
+ addAfter(child: IUI, after: IUI): void;
481
+ addBefore(child: IUI, before: IUI): void;
482
+ remove(child?: IUI): void;
483
+ removeAll(): void;
484
+ }
485
+ interface IGroupData extends IUIData {
486
+ }
487
+ interface IGroupInputData extends IUIBaseInputData {
488
+ }
489
+ interface IUI extends IFillAttrData, IStrokeAttrData, ICornerRadiusAttrData, IEffectAttrData, ILeaf {
490
+ __: IUIData;
491
+ parent?: IGroup;
492
+ set(data: IUIInputData): void;
493
+ toJSON(): IUIInputData;
494
+ getPath(curve?: boolean): IPathCommandData;
495
+ getPathString(curve?: boolean): IPathString;
496
+ __drawPathByData(drawer: IPathDrawer, data: IPathCommandData): void;
497
+ __drawAfterFill?(canvas: ILeaferCanvas, options: IRenderOptions): void;
498
+ export(filename: string, options?: IExportOptions | number): Promise<IBlob | string | boolean>;
499
+ clone(): IUI;
500
+ }
501
+ interface IUIData extends IUIComputedData, ILeafData {
502
+ padding?: number | number[];
503
+ locked?: boolean;
504
+ __isFills?: boolean;
505
+ __isStrokes?: boolean;
506
+ __drawAfterFill?: boolean;
507
+ __isOverflow?: boolean;
508
+ __blendLayer?: boolean;
509
+ __isTranslucentFill?: boolean;
510
+ __isTranslucentStroke?: boolean;
511
+ __useEffect?: boolean;
512
+ path?: IPathCommandData;
513
+ windingRule?: IWindingRule;
514
+ __pathForRender?: IPathCommandData;
515
+ __path2DForRender?: IPath2D;
516
+ __boxStroke?: boolean;
517
+ __font?: string;
518
+ __textDrawData?: ITextDrawData;
519
+ }
520
+ interface IUIComputedData extends IFillComputedData, IBorderComputedData, IStrokeComputedData, ITextStyleComputedData, ICornerRadiusComputedData, IEffectComputedData, ILeafComputedData {
521
+ padding?: number | number[];
522
+ locked?: boolean;
523
+ }
524
+ interface IUIBaseInputData extends IFillInputData, IStrokeInputData, ITextStyleInputData, ICornerRadiusInputData, IEffectInputData, ILeafInputData {
525
+ padding?: number | number[];
526
+ locked?: boolean;
527
+ children?: IUIBaseInputData[];
528
+ }
529
+ type IUITag = 'App' | 'Leafer' | 'Rect' | 'Ellipse' | 'Polygon' | 'Star' | 'Line' | 'Path' | 'Pen' | 'Text' | 'Image' | 'Canvas' | 'Group' | 'Frame' | 'Box';
530
+ interface IUIInputData extends IRectInputData, IEllipseInputData, IPolygonInputData, IStarInputData, ILineInputData, IPathInputData, ITextInputData, IImageInputData, IGroupInputData, IFrameInputData, IUIBaseInputData, IObject {
531
+ }
532
+
533
+ type IUIRenderModule = IUIRender & ThisType<IUI>;
534
+ interface IUIRender extends ILeafRender {
535
+ __drawAfterFill?(canvas: ILeaferCanvas, options: IRenderOptions): void;
536
+ }
537
+ type IRectRenderModule = IRectRender & ThisType<IRect>;
538
+ interface IRectRender extends IUIRender {
539
+ }
540
+ type IImageRenderModule = IImageRender & ThisType<IImage>;
541
+ interface IImageRender extends IUIRender {
542
+ }
543
+ type ITextRenderModule = ITextRender & ThisType<IText>;
544
+ interface ITextRender extends IUIRender {
545
+ }
546
+ type IGroupRenderModule = IGroupRender & ThisType<IGroup>;
547
+ interface IGroupRender extends IUIRender {
548
+ }
549
+ type IFrameRenderModule = IFrameRender & ThisType<IFrame>;
550
+ interface IFrameRender extends IGroupRender {
551
+ }
552
+
553
+ type IUIBoundsModule = IUIBounds & ThisType<IUI>;
554
+ interface IUIBounds extends ILeafBounds {
555
+ }
556
+
557
+ type IUIHitModule = ILeafHit & ThisType<IUI>;
558
+
559
+ interface ITextConvertModule {
560
+ getDrawData?(content: string, style: ITextData): ITextDrawData;
561
+ }
562
+
563
+ interface IColorConvertModule {
564
+ string?(color: IColor, opacity?: number): string;
565
+ }
566
+
567
+ interface ICachedShape extends ICachedLeaf {
568
+ worldCanvas?: ILeaferCanvas;
569
+ shapeBounds: IBoundsData;
570
+ scaleX: number;
571
+ scaleY: number;
572
+ }
573
+
574
+ interface IPaintModule {
575
+ compute?(ui: IUI, attrName: 'fill' | 'stroke'): void;
576
+ fill?(ui: IUI, canvas: ILeaferCanvas, fill: string): void;
577
+ fills?(ui: IUI, canvas: ILeaferCanvas, fills: ILeafPaint[]): void;
578
+ fillText?(ui: IUI, canvas: ILeaferCanvas): void;
579
+ stroke?(ui: IUI, canvas: ILeaferCanvas, stroke: string): void;
580
+ strokes?(ui: IUI, canvas: ILeaferCanvas, strokes: ILeafPaint[]): void;
581
+ strokeText?(ui: IUI, canvas: ILeaferCanvas, stroke: string): void;
582
+ strokesText?(ui: IUI, canvas: ILeaferCanvas, strokes: ILeafPaint[]): void;
583
+ drawTextStroke?(ui: IUI, canvas: ILeaferCanvas): void;
584
+ shape?(ui: IUI, current: ILeaferCanvas, options: IRenderOptions): ICachedShape;
585
+ recycleImage?(data: IUIData, attrName: string): IBooleanMap;
586
+ }
587
+
588
+ interface IEffectModule {
589
+ shadow?(ui: IUI, current: ILeaferCanvas, shape: ICachedShape, options: IRenderOptions): void;
590
+ innerShadow?(ui: IUI, current: ILeaferCanvas, shape: ICachedShape, options: IRenderOptions): void;
591
+ blur?(ui: IUI, current: ILeaferCanvas, origin: ILeaferCanvas, options: IRenderOptions): void;
592
+ backgroundBlur?(ui: IUI, current: ILeaferCanvas, shape: ICachedShape, options: IRenderOptions): void;
593
+ }
594
+
595
+ export type { IBlurEffect, IBox, IBoxData, IBoxInputData, ICachedShape, ICanvas, ICanvasData, ICanvasInputData, IColor, IColorConvertModule, IColorStop, ICornerRadiusString, IDashPatternString, IEffectModule, IEllipse, IEllipseData, IEllipseInputData, IExportModule, IExportOptions, IExportResult, IExportResultFunction, IFontWeight, IFrame, IFrameData, IFrameInputData, IFrameRenderModule, IGradientPaint, IGrayscaleEffect, IGroup, IGroupData, IGroupInputData, IGroupRenderModule, IImage, IImageData, IImageInputData, IImagePaint, IImagePaintMode, IImageRenderModule, ILeafFill, ILeafPaint, ILeafPaintColor, ILeafPaintPatternData, ILeafShadowEffect, ILeafStrokePaint, ILeaferData, ILeaferInputData, ILine, ILineData, ILineInputData, IOverflow, IPaint, IPaintModule, IPaintString, IPath, IPathData, IPathInputData, IPen, IPenData, IPenInputData, IPercent, IPolygon, IPolygonData, IPolygonInputData, IRGB, IRGBA, IRect, IRectData, IRectInputData, IRectRenderModule, IShadowEffect, IShadowString, IStar, IStarData, IStarInputData, IColorString as IStringColor, IStrokeAlign, IStrokeCap, IStrokeJoin, IStrokeWidthString, IText, ITextAlign, ITextCase, ITextCharData, ITextConvertModule, ITextData, ITextDecoration, ITextDrawData, ITextInputData, ITextRenderModule, ITextRowData, ITextWordData, IUI, IUIBaseInputData, IUIBoundsModule, IUIData, IUIHitModule, IUIInputData, IUIRenderModule, IUITag, IUnitData, IVectorPath, IVerticalAlign };