@leafer-ui/interface 1.0.0-alpha.7 → 1.0.0-bate
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 +2 -2
- package/src/ICommonAttr.ts +32 -24
- package/src/IUI.ts +171 -39
- package/src/index.ts +10 -5
- package/src/module/IPaint.ts +14 -1
- package/src/module/IUIRender.ts +19 -7
- package/src/type/IComputedType.ts +4 -4
- package/src/type/IStringType.ts +2 -2
- package/src/type/IType.ts +29 -40
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/interface",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-bate",
|
|
4
4
|
"description": "@leafer-ui/interface",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,6 +19,6 @@
|
|
|
19
19
|
"leaferjs"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@leafer/interface": "1.0.0-
|
|
22
|
+
"@leafer/interface": "1.0.0-bate"
|
|
23
23
|
}
|
|
24
24
|
}
|
package/src/ICommonAttr.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { IPaint, IStrokeAlign, IStrokeCap, IStrokeJoin, IBlurEffect, IFontWeight, ITextCase, ITextDecoration, IShadowEffect, IGrayscaleEffect } from './type/IType'
|
|
1
|
+
import { IPaint, IStrokeAlign, IStrokeCap, IStrokeJoin, IBlurEffect, IFontWeight, ITextCase, ITextDecoration, IShadowEffect, IGrayscaleEffect, ITextAlign, IVerticalAlign, IOverflow, IUnitData } from './type/IType'
|
|
2
2
|
import { ILeafStrokePaint, ILeafShadowEffect, ILeafPaint } from './type/IComputedType'
|
|
3
|
-
import { IPaintString, IDashPatternString,
|
|
3
|
+
import { IPaintString, IDashPatternString, IShadowString, IStringColor, IStrokeWidthString, ICornerRadiusString } from './type/IStringType'
|
|
4
4
|
|
|
5
5
|
// corner---
|
|
6
6
|
export interface ICornerRadiusAttrData {
|
|
7
|
-
cornerRadius: number
|
|
7
|
+
cornerRadius: number | number[] | ICornerRadiusString
|
|
8
8
|
cornerSmoothing: number
|
|
9
9
|
}
|
|
10
10
|
export interface ICornerRadiusInputData {
|
|
11
|
-
cornerRadius?: number
|
|
11
|
+
cornerRadius?: number | number[] | ICornerRadiusString
|
|
12
12
|
cornerSmoothing?: number
|
|
13
13
|
}
|
|
14
14
|
export interface ICornerRadiusComputedData {
|
|
@@ -28,14 +28,6 @@ export interface IFillComputedData {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
// border
|
|
31
|
-
export interface IBorderAttrData {
|
|
32
|
-
borderWidth: number | number[] | IBorderWidthString
|
|
33
|
-
borderRadius: number | number[] | IBorderRadiusString
|
|
34
|
-
}
|
|
35
|
-
export interface IBorderInputData {
|
|
36
|
-
borderWidth?: number | number[]
|
|
37
|
-
borderRadius?: number | number[]
|
|
38
|
-
}
|
|
39
31
|
export interface IBorderComputedData {
|
|
40
32
|
borderWidth?: number | number[]
|
|
41
33
|
borderRadius?: number | number[]
|
|
@@ -46,7 +38,7 @@ export interface IStrokeAttrData {
|
|
|
46
38
|
stroke: IPaint | IPaint[] | IPaintString
|
|
47
39
|
|
|
48
40
|
strokeAlign: IStrokeAlign
|
|
49
|
-
strokeWidth: number
|
|
41
|
+
strokeWidth: number | number[] | IStrokeWidthString
|
|
50
42
|
strokeCap: IStrokeCap
|
|
51
43
|
strokeJoin: IStrokeJoin
|
|
52
44
|
dashPattern: number[] | IDashPatternString
|
|
@@ -57,7 +49,7 @@ export interface IStrokeInputData {
|
|
|
57
49
|
stroke?: IPaint | IPaint[] | IPaintString
|
|
58
50
|
|
|
59
51
|
strokeAlign?: IStrokeAlign
|
|
60
|
-
strokeWidth?: number
|
|
52
|
+
strokeWidth?: number | number[] | IStrokeWidthString
|
|
61
53
|
strokeCap?: IStrokeCap
|
|
62
54
|
strokeJoin?: IStrokeJoin
|
|
63
55
|
dashPattern?: number[] | IDashPatternString
|
|
@@ -85,10 +77,16 @@ export interface ITextStyleAttrData {
|
|
|
85
77
|
italic: boolean
|
|
86
78
|
textCase: ITextCase
|
|
87
79
|
textDecoration: ITextDecoration
|
|
88
|
-
letterSpacing: number |
|
|
89
|
-
lineHeight: number |
|
|
90
|
-
|
|
91
|
-
|
|
80
|
+
letterSpacing: number | IUnitData
|
|
81
|
+
lineHeight: number | IUnitData
|
|
82
|
+
|
|
83
|
+
paraIndent: number
|
|
84
|
+
paraSpacing: number
|
|
85
|
+
|
|
86
|
+
textAlign: ITextAlign
|
|
87
|
+
verticalAlign: IVerticalAlign
|
|
88
|
+
|
|
89
|
+
textOverflow: IOverflow | string
|
|
92
90
|
}
|
|
93
91
|
export interface ITextStyleInputData {
|
|
94
92
|
fontFamily?: string
|
|
@@ -97,10 +95,16 @@ export interface ITextStyleInputData {
|
|
|
97
95
|
italic?: boolean
|
|
98
96
|
textCase?: ITextCase
|
|
99
97
|
textDecoration?: ITextDecoration
|
|
100
|
-
letterSpacing?: number |
|
|
101
|
-
lineHeight?: number |
|
|
102
|
-
|
|
103
|
-
|
|
98
|
+
letterSpacing?: number | IUnitData
|
|
99
|
+
lineHeight?: number | IUnitData
|
|
100
|
+
|
|
101
|
+
paraIndent?: number
|
|
102
|
+
paraSpacing?: number
|
|
103
|
+
|
|
104
|
+
textAlign?: ITextAlign
|
|
105
|
+
verticalAlign?: IVerticalAlign
|
|
106
|
+
|
|
107
|
+
textOverflow?: IOverflow | string
|
|
104
108
|
}
|
|
105
109
|
export interface ITextStyleComputedData {
|
|
106
110
|
fontFamily?: string
|
|
@@ -112,8 +116,12 @@ export interface ITextStyleComputedData {
|
|
|
112
116
|
letterSpacing?: number
|
|
113
117
|
lineHeight?: number
|
|
114
118
|
|
|
115
|
-
|
|
116
|
-
|
|
119
|
+
paraIndent?: number
|
|
120
|
+
paraSpacing?: number
|
|
121
|
+
|
|
122
|
+
textAlign?: ITextAlign
|
|
123
|
+
verticalAlign?: IVerticalAlign
|
|
124
|
+
textOverflow?: IOverflow
|
|
117
125
|
}
|
|
118
126
|
|
|
119
127
|
// effect---
|
package/src/IUI.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { ILeaf, ILeafComputedData, ILeafData, ILeafInputData, ILeaferCanvas, IRenderOptions,
|
|
1
|
+
import { ILeaf, ILeafComputedData, ILeafData, ILeafInputData, ILeaferCanvas, IRenderOptions, IPathDrawer, IPointData, IPath2D, IPathCommandData, IWindingRule, ILeaferImageConfig, IBoundsData, IObject, __Number, ILeaferImage } from '@leafer/interface'
|
|
2
2
|
|
|
3
3
|
import { IPathString, IVectorPathString } from './type/IStringType'
|
|
4
|
-
import {
|
|
5
|
-
import { IVectorPath } from './type/IType'
|
|
4
|
+
import { IOverflow, IVectorPath } from './type/IType'
|
|
6
5
|
|
|
7
6
|
import {
|
|
8
7
|
IFillAttrData, IFillInputData, IFillComputedData,
|
|
9
|
-
IBorderComputedData,
|
|
8
|
+
IBorderComputedData,
|
|
10
9
|
ICornerRadiusAttrData, ICornerRadiusInputData, ICornerRadiusComputedData,
|
|
11
10
|
IStrokeAttrData, IStrokeComputedData, IStrokeInputData,
|
|
12
11
|
IEffectAttrData, IEffectInputData, IEffectComputedData,
|
|
13
|
-
ITextStyleAttrData, ITextStyleInputData, ITextStyleComputedData
|
|
12
|
+
ITextStyleAttrData, ITextStyleInputData, ITextStyleComputedData
|
|
14
13
|
} from './ICommonAttr'
|
|
15
14
|
|
|
16
15
|
|
|
@@ -20,7 +19,9 @@ export interface ILine extends IUI {
|
|
|
20
19
|
toPoint: IPointData
|
|
21
20
|
}
|
|
22
21
|
export interface ILineData extends IUIData { }
|
|
23
|
-
export interface ILineInputData extends IUIInputData {
|
|
22
|
+
export interface ILineInputData extends IUIInputData {
|
|
23
|
+
toPoint?: IPointData
|
|
24
|
+
}
|
|
24
25
|
|
|
25
26
|
|
|
26
27
|
// Rect
|
|
@@ -88,6 +89,33 @@ export interface IPathInputData extends IUIInputData {
|
|
|
88
89
|
windingRule?: IWindingRule
|
|
89
90
|
}
|
|
90
91
|
|
|
92
|
+
// Pen
|
|
93
|
+
|
|
94
|
+
export interface IPen extends IGroup {
|
|
95
|
+
__: IPenData
|
|
96
|
+
path: IPath
|
|
97
|
+
pathStyle: IPathInputData
|
|
98
|
+
pathData: IPathCommandData
|
|
99
|
+
|
|
100
|
+
moveTo(x: number, y: number): IPen
|
|
101
|
+
lineTo(x: number, y: number): IPen
|
|
102
|
+
bezierCurveTo(x1: number, y1: number, x2: number, y2: number, x: number, y: number): IPen
|
|
103
|
+
quadraticCurveTo(x1: number, y1: number, x: number, y: number): IPen
|
|
104
|
+
|
|
105
|
+
rect(x: number, y: number, width: number, height: number): IPen
|
|
106
|
+
roundRect(x: number, y: number, width: number, height: number, cornerRadius: number | number[]): IPen
|
|
107
|
+
ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation?: number, startAngle?: number, endAngle?: number, anticlockwise?: boolean): IPen
|
|
108
|
+
arc(x: number, y: number, radius: number, startAngle?: number, endAngle?: number, anticlockwise?: boolean): IPen
|
|
109
|
+
arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): IPen
|
|
110
|
+
|
|
111
|
+
close(): IPen
|
|
112
|
+
clear(): IPen
|
|
113
|
+
|
|
114
|
+
paint(): void
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface IPenData extends IGroupData { }
|
|
118
|
+
export interface IPenInputData extends IGroupInputData { }
|
|
91
119
|
|
|
92
120
|
// Vector
|
|
93
121
|
export interface IVector extends IUI {
|
|
@@ -105,56 +133,131 @@ export interface IVectorInputData extends IUIInputData {
|
|
|
105
133
|
// Text
|
|
106
134
|
export interface IText extends ITextStyleAttrData, IUI {
|
|
107
135
|
__: ITextData
|
|
108
|
-
|
|
136
|
+
text: string
|
|
109
137
|
}
|
|
110
138
|
interface ITextAttrData {
|
|
111
|
-
|
|
139
|
+
text?: string
|
|
112
140
|
}
|
|
141
|
+
|
|
113
142
|
export interface ITextData extends ITextAttrData, ITextStyleComputedData, IUIData {
|
|
114
|
-
|
|
143
|
+
__baseLine?: number
|
|
144
|
+
__lineHeight?: number
|
|
145
|
+
__letterSpacing?: number
|
|
115
146
|
}
|
|
116
147
|
export interface ITextInputData extends ITextAttrData, ITextStyleInputData, IUIInputData {
|
|
117
148
|
|
|
118
149
|
}
|
|
119
150
|
|
|
151
|
+
export interface ITextRowData {
|
|
152
|
+
x?: number
|
|
153
|
+
y?: number
|
|
154
|
+
width?: number
|
|
155
|
+
height?: number
|
|
156
|
+
text?: string
|
|
157
|
+
data?: ITextCharData[]
|
|
158
|
+
words?: ITextWordData[]
|
|
159
|
+
|
|
160
|
+
paraStart?: boolean // paragraph start
|
|
161
|
+
paraEnd?: boolean // paragraph end
|
|
162
|
+
isOverflow?: boolean
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export interface ITextWordData {
|
|
166
|
+
x?: number
|
|
167
|
+
y?: number
|
|
168
|
+
width?: number
|
|
169
|
+
height?: number
|
|
170
|
+
data?: ITextCharData[]
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export interface ITextCharData {
|
|
174
|
+
x?: number
|
|
175
|
+
y?: number
|
|
176
|
+
width?: number
|
|
177
|
+
height?: number
|
|
178
|
+
char?: string
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export interface ITextDrawData {
|
|
182
|
+
bounds: IBoundsData
|
|
183
|
+
rows: ITextRowData[]
|
|
184
|
+
paraNumber: number
|
|
185
|
+
font: string
|
|
186
|
+
decorationY?: number
|
|
187
|
+
decorationHeight?: number
|
|
188
|
+
overflow?: number // overflowed row number, not index
|
|
189
|
+
}
|
|
120
190
|
|
|
121
191
|
// Image
|
|
122
192
|
export interface IImage extends IRect, ILeaferImageConfig {
|
|
123
193
|
__: IImageData
|
|
124
194
|
url: string
|
|
125
|
-
|
|
195
|
+
ready: boolean
|
|
196
|
+
image?: ILeaferImage
|
|
126
197
|
}
|
|
127
198
|
interface IImageAttrData {
|
|
128
199
|
url?: string
|
|
129
|
-
thumb?: string
|
|
130
200
|
}
|
|
131
201
|
export interface IImageData extends IImageAttrData, IRectData { }
|
|
132
202
|
export interface IImageInputData extends IImageAttrData, IUIInputData { }
|
|
133
203
|
|
|
204
|
+
export interface ICanvas extends IRect {
|
|
205
|
+
__: ICanvasData
|
|
206
|
+
pixelRatio: number
|
|
207
|
+
smooth: boolean
|
|
208
|
+
canvas: ILeaferCanvas
|
|
209
|
+
__updateSize(): void
|
|
210
|
+
}
|
|
211
|
+
interface ICanvasAttrData {
|
|
212
|
+
pixelRatio?: number
|
|
213
|
+
smooth?: boolean
|
|
214
|
+
}
|
|
215
|
+
export interface ICanvasData extends ICanvasAttrData, IRectData { }
|
|
216
|
+
export interface ICanvasInputData extends ICanvasAttrData, IUIInputData { }
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
// Leafer
|
|
220
|
+
export interface ILeaferData extends IGroupData {
|
|
221
|
+
pixelRatio?: number
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export interface ILeaferInputData extends IGroupInputData {
|
|
225
|
+
pixelRatio?: number
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
|
|
134
229
|
// Frame
|
|
135
|
-
export interface IFrame extends
|
|
230
|
+
export interface IFrame extends IBox {
|
|
136
231
|
__: IFrameData
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
232
|
+
}
|
|
233
|
+
export interface IFrameData extends IBoxData {
|
|
234
|
+
|
|
235
|
+
}
|
|
236
|
+
export interface IFrameInputData extends IBoxInputData {
|
|
237
|
+
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
// Box
|
|
242
|
+
export interface IBox extends IGroup {
|
|
243
|
+
__: IBoxData
|
|
244
|
+
overflow: IOverflow
|
|
140
245
|
__updateRectRenderBounds(): void
|
|
141
|
-
__renderRect(canvas: ILeaferCanvas, options: IRenderOptions): void
|
|
142
246
|
__renderGroup(canvas: ILeaferCanvas, options: IRenderOptions): void
|
|
143
247
|
}
|
|
144
|
-
export interface
|
|
145
|
-
|
|
248
|
+
export interface IBoxData extends IGroupData {
|
|
249
|
+
overflow?: IOverflow
|
|
146
250
|
}
|
|
147
|
-
export interface
|
|
148
|
-
|
|
251
|
+
export interface IBoxInputData extends IGroupInputData {
|
|
252
|
+
overflow?: IOverflow
|
|
149
253
|
}
|
|
150
254
|
|
|
151
255
|
|
|
152
256
|
// Group
|
|
153
|
-
export interface IGroup extends
|
|
257
|
+
export interface IGroup extends IUI {
|
|
154
258
|
__: IGroupData
|
|
155
|
-
root?: IGroup
|
|
156
|
-
parent?: IGroup
|
|
157
259
|
children: IUI[]
|
|
260
|
+
mask?: IUI
|
|
158
261
|
add(child: IUI, index?: number): void
|
|
159
262
|
remove(child?: IUI): void
|
|
160
263
|
addAt(child: IUI, index: number): void
|
|
@@ -165,21 +268,31 @@ export interface IGroupData extends IUIData { }
|
|
|
165
268
|
export interface IGroupInputData extends IUIInputData { }
|
|
166
269
|
|
|
167
270
|
// UI
|
|
168
|
-
export interface IUI extends IFillAttrData,
|
|
271
|
+
export interface IUI extends IFillAttrData, IStrokeAttrData, ICornerRadiusAttrData, IEffectAttrData, ILeaf {
|
|
169
272
|
__: IUIData
|
|
170
|
-
root?: IGroup
|
|
171
273
|
parent?: IGroup
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
274
|
+
|
|
275
|
+
set(data: IUITagInputData): void
|
|
276
|
+
get(): IUITagInputData
|
|
277
|
+
|
|
278
|
+
getPath(curve?: boolean): IPathCommandData
|
|
279
|
+
getPathString(curve?: boolean): IPathString
|
|
280
|
+
|
|
281
|
+
__drawPathByData(drawer: IPathDrawer, data: IPathCommandData): void
|
|
282
|
+
__drawAfterFill?(canvas: ILeaferCanvas, options: IRenderOptions): void
|
|
177
283
|
}
|
|
178
284
|
|
|
179
285
|
export interface IUIData extends IUIComputedData, ILeafData {
|
|
286
|
+
|
|
287
|
+
padding?: number | number[]
|
|
288
|
+
locked?: boolean
|
|
289
|
+
|
|
180
290
|
// 非数据属性, 自动计算的缓存数据
|
|
181
291
|
__isFills?: boolean
|
|
182
292
|
__isStrokes?: boolean
|
|
293
|
+
__drawAfterFill?: boolean
|
|
294
|
+
__isOverflow?: boolean
|
|
295
|
+
__blendLayer?: boolean
|
|
183
296
|
|
|
184
297
|
__isTranslucentFill?: boolean // 半透明的
|
|
185
298
|
__isTranslucentStroke?: boolean
|
|
@@ -190,19 +303,38 @@ export interface IUIData extends IUIComputedData, ILeafData {
|
|
|
190
303
|
path?: IPathCommandData
|
|
191
304
|
windingRule?: IWindingRule
|
|
192
305
|
|
|
193
|
-
|
|
194
|
-
|
|
306
|
+
__pathForRender?: IPathCommandData
|
|
307
|
+
__path2DForRender?: IPath2D
|
|
308
|
+
|
|
309
|
+
// text
|
|
310
|
+
__font?: string
|
|
311
|
+
__textDrawData?: ITextDrawData
|
|
195
312
|
|
|
196
|
-
__strokeOuterWidth?: number // boxBounds外面的笔触宽度
|
|
197
313
|
}
|
|
198
|
-
export interface IUIComputedData extends IFillComputedData, IBorderComputedData, IStrokeComputedData, ICornerRadiusComputedData, IEffectComputedData, ILeafComputedData {
|
|
199
|
-
|
|
200
|
-
mask?: boolean
|
|
314
|
+
export interface IUIComputedData extends IFillComputedData, IBorderComputedData, IStrokeComputedData, ITextStyleComputedData, ICornerRadiusComputedData, IEffectComputedData, ILeafComputedData {
|
|
315
|
+
padding?: number | number[]
|
|
201
316
|
locked?: boolean
|
|
202
317
|
}
|
|
203
318
|
|
|
204
|
-
export interface IUIInputData extends IFillInputData,
|
|
205
|
-
|
|
206
|
-
mask?: boolean
|
|
319
|
+
export interface IUIInputData extends IFillInputData, IStrokeInputData, ITextStyleInputData, ICornerRadiusInputData, IEffectInputData, ILeafInputData {
|
|
320
|
+
padding?: number | number[]
|
|
207
321
|
locked?: boolean
|
|
208
322
|
}
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
export type IUITag =
|
|
326
|
+
| 'Rect'
|
|
327
|
+
| 'Ellipse'
|
|
328
|
+
| 'Polygon'
|
|
329
|
+
| 'Star'
|
|
330
|
+
| 'Line'
|
|
331
|
+
| 'Path'
|
|
332
|
+
| 'Text'
|
|
333
|
+
| 'Image'
|
|
334
|
+
| 'Group'
|
|
335
|
+
| 'Frame'
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
export interface IUITagInputData extends IRectInputData, IEllipseInputData, IPolygonInputData, IStarInputData, ILineInputData, IPathInputData, ITextInputData, IImageInputData, IGroupInputData, IFrameInputData, IObject {
|
|
339
|
+
tagName?: IUITag
|
|
340
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -7,18 +7,23 @@ export {
|
|
|
7
7
|
IPolygon, IPolygonInputData, IPolygonData,
|
|
8
8
|
IStar, IStarInputData, IStarData,
|
|
9
9
|
IPath, IPathInputData, IPathData,
|
|
10
|
+
IPen, IPenInputData, IPenData,
|
|
10
11
|
IVector, IVectorInputData, IVectorData,
|
|
11
|
-
IText, ITextInputData, ITextData,
|
|
12
|
+
IText, ITextInputData, ITextData, ITextRowData, ITextWordData, ITextCharData, ITextDrawData,
|
|
12
13
|
IImage, IImageInputData, IImageData,
|
|
14
|
+
ICanvas, ICanvasInputData, ICanvasData,
|
|
13
15
|
IFrame, IFrameInputData, IFrameData,
|
|
16
|
+
IBox, IBoxInputData, IBoxData,
|
|
14
17
|
IGroup, IGroupInputData, IGroupData,
|
|
15
|
-
|
|
18
|
+
ILeaferInputData, ILeaferData,
|
|
19
|
+
IUI, IUIInputData, IUIData,
|
|
20
|
+
IUITag, IUITagInputData
|
|
16
21
|
} from './IUI'
|
|
17
|
-
export {
|
|
18
|
-
export {
|
|
22
|
+
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'
|
|
23
|
+
export { ICornerRadiusString, IStrokeWidthString, IPaintString, IShadowString, IPercent, IDashPatternString, IPathString, IVectorPathString, IStringColor } from './type/IStringType'
|
|
19
24
|
export { ILeafFill, ILeafPaint, ILeafPaintColor, ILeafStrokePaint, ILeafShadowEffect } from './type/IComputedType'
|
|
20
25
|
|
|
21
|
-
export { IUIRenderModule, IRectRenderModule, IGroupRenderModule, IFrameRenderModule } from './module/IUIRender'
|
|
26
|
+
export { IUIRenderModule, IRectRenderModule, IImageRenderModule, ITextRenderModule, IGroupRenderModule, IFrameRenderModule } from './module/IUIRender'
|
|
22
27
|
export { IUIBoundsModule } from './module/IUIBounds'
|
|
23
28
|
export { IUIHitModule } from './module/IUIHit'
|
|
24
29
|
|
package/src/module/IPaint.ts
CHANGED
|
@@ -1,12 +1,25 @@
|
|
|
1
|
-
import { ILeaferCanvas } from '@leafer/interface'
|
|
1
|
+
import { ILeaferCanvas, IRenderOptions } from '@leafer/interface'
|
|
2
2
|
|
|
3
3
|
import { ILeafPaint } from '../type/IComputedType'
|
|
4
4
|
import { IUI } from '../IUI'
|
|
5
|
+
import { ICachedShape } from '../ICachedShape'
|
|
5
6
|
|
|
6
7
|
export interface IPaintModule {
|
|
8
|
+
computeFill?(ui: IUI): void
|
|
9
|
+
computeStroke?(ui: IUI): void
|
|
10
|
+
|
|
7
11
|
fill?(ui: IUI, canvas: ILeaferCanvas, fill: string | object): void
|
|
8
12
|
fills?(ui: IUI, canvas: ILeaferCanvas, fills: ILeafPaint[]): void
|
|
9
13
|
|
|
14
|
+
drawText?(ui: IUI, canvas: ILeaferCanvas): void
|
|
15
|
+
|
|
10
16
|
stroke?(ui: IUI, canvas: ILeaferCanvas, stroke: string | object): void
|
|
11
17
|
strokes?(ui: IUI, canvas: ILeaferCanvas, strokes: ILeafPaint[]): void
|
|
18
|
+
|
|
19
|
+
strokeText?(ui: IUI, canvas: ILeaferCanvas, stroke: string | object): void
|
|
20
|
+
strokesText?(ui: IUI, canvas: ILeaferCanvas, strokes: ILeafPaint[]): void
|
|
21
|
+
|
|
22
|
+
drawTextStroke?(ui: IUI, canvas: ILeaferCanvas): void
|
|
23
|
+
|
|
24
|
+
shape?(ui: IUI, current: ILeaferCanvas, options: IRenderOptions): ICachedShape
|
|
12
25
|
}
|
package/src/module/IUIRender.ts
CHANGED
|
@@ -1,28 +1,40 @@
|
|
|
1
|
-
import { ILeafRender, ILeaferCanvas, IRenderOptions
|
|
1
|
+
import { ILeafRender, ILeaferCanvas, IRenderOptions } from '@leafer/interface'
|
|
2
2
|
|
|
3
|
-
import { IUI, IRect, IFrame, IGroup } from '../IUI'
|
|
3
|
+
import { IUI, IRect, IImage, IText, IFrame, IGroup } from '../IUI'
|
|
4
4
|
|
|
5
5
|
export type IUIRenderModule = IUIRender & ThisType<IUI>
|
|
6
6
|
|
|
7
|
-
interface IUIRender extends ILeafRender {
|
|
8
|
-
|
|
7
|
+
export interface IUIRender extends ILeafRender {
|
|
8
|
+
__drawAfterFill?(canvas: ILeaferCanvas, options: IRenderOptions): void
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export type IRectRenderModule = IRectRender & ThisType<IRect>
|
|
12
12
|
|
|
13
|
-
interface IRectRender extends IUIRender {
|
|
13
|
+
export interface IRectRender extends IUIRender {
|
|
14
|
+
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type IImageRenderModule = IImageRender & ThisType<IImage>
|
|
18
|
+
|
|
19
|
+
export interface IImageRender extends IUIRender {
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type ITextRenderModule = ITextRender & ThisType<IText>
|
|
24
|
+
|
|
25
|
+
export interface ITextRender extends IUIRender {
|
|
14
26
|
|
|
15
27
|
}
|
|
16
28
|
|
|
17
29
|
export type IGroupRenderModule = IGroupRender & ThisType<IGroup>
|
|
18
30
|
|
|
19
|
-
interface IGroupRender extends IUIRender {
|
|
31
|
+
export interface IGroupRender extends IUIRender {
|
|
20
32
|
|
|
21
33
|
}
|
|
22
34
|
|
|
23
35
|
export type IFrameRenderModule = IFrameRender & ThisType<IFrame>
|
|
24
36
|
|
|
25
|
-
interface IFrameRender extends IGroupRender {
|
|
37
|
+
export interface IFrameRender extends IGroupRender {
|
|
26
38
|
|
|
27
39
|
}
|
|
28
40
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IBlendMode, IMatrixData } from '@leafer/interface'
|
|
2
2
|
|
|
3
3
|
import { IStringColor } from './IStringType'
|
|
4
|
-
import {
|
|
4
|
+
import { IStrokeAlign, IStrokeJoin, IStrokeCap } from './IType'
|
|
5
5
|
import { IPaintType } from './IType'
|
|
6
6
|
|
|
7
7
|
export type ILeafPaintColor = IStringColor | CanvasGradient | CanvasPattern
|
|
@@ -9,7 +9,7 @@ export type ILeafPaintColor = IStringColor | CanvasGradient | CanvasPattern
|
|
|
9
9
|
export interface ILeafPaint {
|
|
10
10
|
type: IPaintType
|
|
11
11
|
style: ILeafPaintColor
|
|
12
|
-
|
|
12
|
+
transform?: IMatrixData
|
|
13
13
|
blendMode?: IBlendMode
|
|
14
14
|
opacity?: number
|
|
15
15
|
}
|
|
@@ -32,5 +32,5 @@ export interface ILeafShadowEffect {
|
|
|
32
32
|
spread?: number
|
|
33
33
|
color: IStringColor
|
|
34
34
|
blendMode?: IBlendMode
|
|
35
|
-
|
|
35
|
+
box?: boolean
|
|
36
36
|
}
|
package/src/type/IStringType.ts
CHANGED
|
@@ -2,8 +2,8 @@ export type IPercent = string
|
|
|
2
2
|
|
|
3
3
|
export type IStringColor = string
|
|
4
4
|
|
|
5
|
-
export type
|
|
6
|
-
export type
|
|
5
|
+
export type ICornerRadiusString = string
|
|
6
|
+
export type IStrokeWidthString = string
|
|
7
7
|
export type IDashPatternString = string
|
|
8
8
|
export type IVectorPathString = string
|
|
9
9
|
export type IPathString = string
|
package/src/type/IType.ts
CHANGED
|
@@ -1,25 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IPointData, IPathCommandData, IWindingRule, IBlendMode } from '@leafer/interface'
|
|
2
2
|
import { IStringColor } from './IStringType'
|
|
3
3
|
|
|
4
|
-
export
|
|
5
|
-
| '
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
| 'screen'
|
|
9
|
-
| 'overlay'
|
|
10
|
-
| 'darken'
|
|
11
|
-
| 'lighten'
|
|
12
|
-
| 'color-dodge'
|
|
13
|
-
| 'color-burn'
|
|
14
|
-
| 'hard-light'
|
|
15
|
-
| 'soft-light'
|
|
16
|
-
| 'difference'
|
|
17
|
-
| 'exclusion'
|
|
18
|
-
| 'hue'
|
|
19
|
-
| 'saturation'
|
|
20
|
-
| 'color'
|
|
21
|
-
| 'luminosity'
|
|
22
|
-
|
|
4
|
+
export interface IUnitData {
|
|
5
|
+
type: 'percent' | 'px'
|
|
6
|
+
value: number
|
|
7
|
+
}
|
|
23
8
|
|
|
24
9
|
export type IPaint = ISolidPaint | IGradientPaint | IImagePaint
|
|
25
10
|
|
|
@@ -37,10 +22,9 @@ export type IPaintType =
|
|
|
37
22
|
| IGradientType
|
|
38
23
|
|
|
39
24
|
export type IGradientType =
|
|
40
|
-
| '
|
|
41
|
-
| '
|
|
42
|
-
| '
|
|
43
|
-
| 'gradient-diamond'
|
|
25
|
+
| 'linear'
|
|
26
|
+
| 'radial'
|
|
27
|
+
| 'angular'
|
|
44
28
|
|
|
45
29
|
// ---
|
|
46
30
|
export interface ISolidPaint extends IPaintBase {
|
|
@@ -48,11 +32,12 @@ export interface ISolidPaint extends IPaintBase {
|
|
|
48
32
|
color: IColor
|
|
49
33
|
}
|
|
50
34
|
|
|
51
|
-
export type IColor = IStringColor
|
|
35
|
+
export type IColor = IStringColor | IRGB | IRGBA
|
|
52
36
|
export interface IRGB {
|
|
53
37
|
r: number
|
|
54
38
|
g: number
|
|
55
39
|
b: number
|
|
40
|
+
a?: number
|
|
56
41
|
}
|
|
57
42
|
export interface IRGBA extends IRGB {
|
|
58
43
|
a: number
|
|
@@ -61,8 +46,8 @@ export interface IRGBA extends IRGB {
|
|
|
61
46
|
// ---
|
|
62
47
|
export interface IGradientPaint extends IPaintBase {
|
|
63
48
|
type: IGradientType
|
|
64
|
-
from
|
|
65
|
-
to
|
|
49
|
+
from?: IPointData
|
|
50
|
+
to?: IPointData
|
|
66
51
|
stretch?: number
|
|
67
52
|
stops: IColorStop[]
|
|
68
53
|
}
|
|
@@ -75,11 +60,13 @@ export interface IColorStop {
|
|
|
75
60
|
export interface IImagePaint extends IPaintBase {
|
|
76
61
|
type: "image"
|
|
77
62
|
url: string
|
|
78
|
-
mode
|
|
79
|
-
|
|
80
|
-
scale?: number
|
|
81
|
-
rotation?: number
|
|
63
|
+
mode?: IImagePaintMode
|
|
64
|
+
|
|
82
65
|
filters?: IImageFilters
|
|
66
|
+
|
|
67
|
+
offset?: IPointData
|
|
68
|
+
scale?: number | IPointData
|
|
69
|
+
rotation?: number
|
|
83
70
|
}
|
|
84
71
|
export interface IImageFilters {
|
|
85
72
|
exposure?: number // 曝光
|
|
@@ -90,7 +77,7 @@ export interface IImageFilters {
|
|
|
90
77
|
highlights?: number // 高光
|
|
91
78
|
shadows?: number // 阴影
|
|
92
79
|
}
|
|
93
|
-
export type IImagePaintMode = '
|
|
80
|
+
export type IImagePaintMode = 'cover' | 'fit' | 'strench' | 'clip' | 'repeat'
|
|
94
81
|
|
|
95
82
|
// 描边
|
|
96
83
|
export type IStrokeAlign = 'inside' | 'outside' | 'center'
|
|
@@ -98,9 +85,11 @@ export type IStrokeCap = 'none' | 'round' | 'square' | 'arrow-lines' | 'arrow-eq
|
|
|
98
85
|
export type IStrokeJoin = 'bevel' | 'round' | 'miter'
|
|
99
86
|
|
|
100
87
|
// 文本
|
|
101
|
-
export type
|
|
102
|
-
export type
|
|
103
|
-
export type
|
|
88
|
+
export type ITextAlign = 'left' | 'center' | 'right' | 'justify'
|
|
89
|
+
export type IVerticalAlign = 'top' | 'middle' | 'bottom'
|
|
90
|
+
export type ITextCase = | 'upper' | 'lower' | 'title' | 'none' | 'small-caps'
|
|
91
|
+
export type IFontWeight = IFontWeightNumer | IFontWeightString
|
|
92
|
+
export type IFontWeightNumer = 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
|
|
104
93
|
export type IFontWeightString =
|
|
105
94
|
| 'thin'
|
|
106
95
|
| 'extra-light'
|
|
@@ -111,15 +100,13 @@ export type IFontWeightString =
|
|
|
111
100
|
| 'bold'
|
|
112
101
|
| 'extra-bold'
|
|
113
102
|
| 'black'
|
|
114
|
-
export type ITextDecoration = 'none' | '
|
|
103
|
+
export type ITextDecoration = 'none' | 'under' | 'delete'
|
|
115
104
|
|
|
116
105
|
// 路径
|
|
117
106
|
export interface IVectorPath {
|
|
118
107
|
rule?: IWindingRule,
|
|
119
108
|
data: string | IPathCommandData
|
|
120
109
|
}
|
|
121
|
-
export type IWindingRule = 'nonzero' | 'evenodd'
|
|
122
|
-
|
|
123
110
|
|
|
124
111
|
// 特效
|
|
125
112
|
export interface IShadowEffect {
|
|
@@ -130,7 +117,7 @@ export interface IShadowEffect {
|
|
|
130
117
|
color: IStringColor | IColor
|
|
131
118
|
blendMode?: IBlendMode
|
|
132
119
|
visible?: boolean
|
|
133
|
-
|
|
120
|
+
box?: boolean
|
|
134
121
|
}
|
|
135
122
|
|
|
136
123
|
export interface IBlurEffect {
|
|
@@ -141,4 +128,6 @@ export interface IBlurEffect {
|
|
|
141
128
|
export interface IGrayscaleEffect {
|
|
142
129
|
grayscale: number
|
|
143
130
|
visible?: boolean
|
|
144
|
-
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export type IOverflow = 'show' | 'hide'
|