@leafer-ui/interface 1.0.0-alpha.9 → 1.0.0-beta
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 +30 -14
- package/src/IUI.ts +168 -44
- package/src/index.ts +10 -6
- package/src/module/IPaint.ts +14 -1
- package/src/module/IUIRender.ts +19 -7
- package/src/type/IComputedType.ts +7 -7
- package/src/type/IStringType.ts +1 -4
- package/src/type/IType.ts +31 -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-beta",
|
|
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-beta"
|
|
23
23
|
}
|
|
24
24
|
}
|
package/src/ICommonAttr.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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, IColorString, IStrokeWidthString, ICornerRadiusString } from './type/IStringType'
|
|
4
4
|
|
|
5
5
|
// corner---
|
|
6
6
|
export interface ICornerRadiusAttrData {
|
|
@@ -24,7 +24,7 @@ export interface IFillInputData {
|
|
|
24
24
|
fill?: IPaint | IPaint[] | IPaintString
|
|
25
25
|
}
|
|
26
26
|
export interface IFillComputedData {
|
|
27
|
-
fill?:
|
|
27
|
+
fill?: IColorString | ILeafPaint[]
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
// border
|
|
@@ -57,7 +57,7 @@ export interface IStrokeInputData {
|
|
|
57
57
|
miterLimit?: number
|
|
58
58
|
}
|
|
59
59
|
export interface IStrokeComputedData {
|
|
60
|
-
stroke?:
|
|
60
|
+
stroke?: IColorString | ILeafStrokePaint[]
|
|
61
61
|
|
|
62
62
|
strokeAlign?: IStrokeAlign
|
|
63
63
|
strokeWidth?: number
|
|
@@ -77,10 +77,16 @@ export interface ITextStyleAttrData {
|
|
|
77
77
|
italic: boolean
|
|
78
78
|
textCase: ITextCase
|
|
79
79
|
textDecoration: ITextDecoration
|
|
80
|
-
letterSpacing: number |
|
|
81
|
-
lineHeight: number |
|
|
82
|
-
|
|
83
|
-
|
|
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
|
|
84
90
|
}
|
|
85
91
|
export interface ITextStyleInputData {
|
|
86
92
|
fontFamily?: string
|
|
@@ -89,10 +95,16 @@ export interface ITextStyleInputData {
|
|
|
89
95
|
italic?: boolean
|
|
90
96
|
textCase?: ITextCase
|
|
91
97
|
textDecoration?: ITextDecoration
|
|
92
|
-
letterSpacing?: number |
|
|
93
|
-
lineHeight?: number |
|
|
94
|
-
|
|
95
|
-
|
|
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
|
|
96
108
|
}
|
|
97
109
|
export interface ITextStyleComputedData {
|
|
98
110
|
fontFamily?: string
|
|
@@ -104,8 +116,12 @@ export interface ITextStyleComputedData {
|
|
|
104
116
|
letterSpacing?: number
|
|
105
117
|
lineHeight?: number
|
|
106
118
|
|
|
107
|
-
|
|
108
|
-
|
|
119
|
+
paraIndent?: number
|
|
120
|
+
paraSpacing?: number
|
|
121
|
+
|
|
122
|
+
textAlign?: ITextAlign
|
|
123
|
+
verticalAlign?: IVerticalAlign
|
|
124
|
+
textOverflow?: IOverflow
|
|
109
125
|
}
|
|
110
126
|
|
|
111
127
|
// effect---
|
package/src/IUI.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { ILeaf, ILeafComputedData, ILeafData, ILeafInputData, ILeaferCanvas, IRenderOptions, IPathDrawer, IPointData, IPath2D, IPathCommandData, IWindingRule,
|
|
1
|
+
import { ILeaf, ILeafComputedData, ILeafData, ILeafInputData, ILeaferCanvas, IRenderOptions, IPathDrawer, IPointData, IPath2D, IPathCommandData, IWindingRule, ILeaferImageConfig, IBoundsData, IObject, __Number, IPathString, ILeaferImage } from '@leafer/interface'
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import { IBlendMode } from './type/IType'
|
|
5
|
-
import { IVectorPath } from './type/IType'
|
|
3
|
+
import { IOverflow } from './type/IType'
|
|
6
4
|
|
|
7
5
|
import {
|
|
8
6
|
IFillAttrData, IFillInputData, IFillComputedData,
|
|
@@ -20,7 +18,9 @@ export interface ILine extends IUI {
|
|
|
20
18
|
toPoint: IPointData
|
|
21
19
|
}
|
|
22
20
|
export interface ILineData extends IUIData { }
|
|
23
|
-
export interface ILineInputData extends IUIInputData {
|
|
21
|
+
export interface ILineInputData extends IUIInputData {
|
|
22
|
+
toPoint?: IPointData
|
|
23
|
+
}
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
// Rect
|
|
@@ -88,73 +88,163 @@ export interface IPathInputData extends IUIInputData {
|
|
|
88
88
|
windingRule?: IWindingRule
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
// Pen
|
|
91
92
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
93
|
+
export interface IPen extends IGroup {
|
|
94
|
+
__: IPenData
|
|
95
|
+
path: IPath
|
|
96
|
+
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
|
+
|
|
113
|
+
paint(): void
|
|
102
114
|
}
|
|
103
115
|
|
|
116
|
+
export interface IPenData extends IGroupData { }
|
|
117
|
+
export interface IPenInputData extends IGroupInputData { }
|
|
118
|
+
|
|
104
119
|
|
|
105
120
|
// Text
|
|
106
121
|
export interface IText extends ITextStyleAttrData, IUI {
|
|
107
122
|
__: ITextData
|
|
108
|
-
|
|
123
|
+
text: string
|
|
109
124
|
}
|
|
110
125
|
interface ITextAttrData {
|
|
111
|
-
|
|
126
|
+
text?: string
|
|
112
127
|
}
|
|
128
|
+
|
|
113
129
|
export interface ITextData extends ITextAttrData, ITextStyleComputedData, IUIData {
|
|
114
|
-
|
|
130
|
+
__baseLine?: number
|
|
131
|
+
__lineHeight?: number
|
|
132
|
+
__letterSpacing?: number
|
|
115
133
|
}
|
|
116
134
|
export interface ITextInputData extends ITextAttrData, ITextStyleInputData, IUIInputData {
|
|
117
135
|
|
|
118
136
|
}
|
|
119
137
|
|
|
138
|
+
export interface ITextRowData {
|
|
139
|
+
x?: number
|
|
140
|
+
y?: number
|
|
141
|
+
width?: number
|
|
142
|
+
height?: number
|
|
143
|
+
text?: string
|
|
144
|
+
data?: ITextCharData[]
|
|
145
|
+
words?: ITextWordData[]
|
|
146
|
+
|
|
147
|
+
paraStart?: boolean // paragraph start
|
|
148
|
+
paraEnd?: boolean // paragraph end
|
|
149
|
+
isOverflow?: boolean
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export interface ITextWordData {
|
|
153
|
+
x?: number
|
|
154
|
+
y?: number
|
|
155
|
+
width?: number
|
|
156
|
+
height?: number
|
|
157
|
+
data?: ITextCharData[]
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export interface ITextCharData {
|
|
161
|
+
x?: number
|
|
162
|
+
y?: number
|
|
163
|
+
width?: number
|
|
164
|
+
height?: number
|
|
165
|
+
char?: string
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface ITextDrawData {
|
|
169
|
+
bounds: IBoundsData
|
|
170
|
+
rows: ITextRowData[]
|
|
171
|
+
paraNumber: number
|
|
172
|
+
font: string
|
|
173
|
+
decorationY?: number
|
|
174
|
+
decorationHeight?: number
|
|
175
|
+
overflow?: number // overflowed row number, not index
|
|
176
|
+
}
|
|
120
177
|
|
|
121
178
|
// Image
|
|
122
179
|
export interface IImage extends IRect, ILeaferImageConfig {
|
|
123
180
|
__: IImageData
|
|
124
181
|
url: string
|
|
125
|
-
|
|
182
|
+
ready: boolean
|
|
183
|
+
image?: ILeaferImage
|
|
126
184
|
}
|
|
127
185
|
interface IImageAttrData {
|
|
128
186
|
url?: string
|
|
129
|
-
thumb?: string
|
|
130
187
|
}
|
|
131
188
|
export interface IImageData extends IImageAttrData, IRectData { }
|
|
132
189
|
export interface IImageInputData extends IImageAttrData, IUIInputData { }
|
|
133
190
|
|
|
191
|
+
export interface ICanvas extends IRect {
|
|
192
|
+
__: ICanvasData
|
|
193
|
+
pixelRatio: number
|
|
194
|
+
smooth: boolean
|
|
195
|
+
canvas: ILeaferCanvas
|
|
196
|
+
__updateSize(): void
|
|
197
|
+
}
|
|
198
|
+
interface ICanvasAttrData {
|
|
199
|
+
pixelRatio?: number
|
|
200
|
+
smooth?: boolean
|
|
201
|
+
}
|
|
202
|
+
export interface ICanvasData extends ICanvasAttrData, IRectData { }
|
|
203
|
+
export interface ICanvasInputData extends ICanvasAttrData, IUIInputData { }
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
// Leafer
|
|
207
|
+
export interface ILeaferData extends IGroupData {
|
|
208
|
+
pixelRatio?: number
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export interface ILeaferInputData extends IGroupInputData {
|
|
212
|
+
pixelRatio?: number
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
|
|
134
216
|
// Frame
|
|
135
|
-
export interface IFrame extends
|
|
217
|
+
export interface IFrame extends IBox {
|
|
136
218
|
__: IFrameData
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
219
|
+
}
|
|
220
|
+
export interface IFrameData extends IBoxData {
|
|
221
|
+
|
|
222
|
+
}
|
|
223
|
+
export interface IFrameInputData extends IBoxInputData {
|
|
224
|
+
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
// Box
|
|
229
|
+
export interface IBox extends IGroup {
|
|
230
|
+
__: IBoxData
|
|
231
|
+
overflow: IOverflow
|
|
140
232
|
__updateRectRenderBounds(): void
|
|
141
|
-
__renderRect(canvas: ILeaferCanvas, options: IRenderOptions): void
|
|
142
233
|
__renderGroup(canvas: ILeaferCanvas, options: IRenderOptions): void
|
|
143
234
|
}
|
|
144
|
-
export interface
|
|
145
|
-
|
|
235
|
+
export interface IBoxData extends IGroupData {
|
|
236
|
+
overflow?: IOverflow
|
|
146
237
|
}
|
|
147
|
-
export interface
|
|
148
|
-
|
|
238
|
+
export interface IBoxInputData extends IGroupInputData {
|
|
239
|
+
overflow?: IOverflow
|
|
149
240
|
}
|
|
150
241
|
|
|
151
242
|
|
|
152
243
|
// Group
|
|
153
|
-
export interface IGroup extends
|
|
244
|
+
export interface IGroup extends IUI {
|
|
154
245
|
__: IGroupData
|
|
155
|
-
root?: IGroup
|
|
156
|
-
parent?: IGroup
|
|
157
246
|
children: IUI[]
|
|
247
|
+
mask?: IUI
|
|
158
248
|
add(child: IUI, index?: number): void
|
|
159
249
|
remove(child?: IUI): void
|
|
160
250
|
addAt(child: IUI, index: number): void
|
|
@@ -167,19 +257,29 @@ export interface IGroupInputData extends IUIInputData { }
|
|
|
167
257
|
// UI
|
|
168
258
|
export interface IUI extends IFillAttrData, IStrokeAttrData, ICornerRadiusAttrData, IEffectAttrData, ILeaf {
|
|
169
259
|
__: IUIData
|
|
170
|
-
root?: IGroup
|
|
171
260
|
parent?: IGroup
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
261
|
+
|
|
262
|
+
set(data: IUITagInputData): void
|
|
263
|
+
get(): IUITagInputData
|
|
264
|
+
|
|
265
|
+
getPath(curve?: boolean): IPathCommandData
|
|
266
|
+
getPathString(curve?: boolean): IPathString
|
|
267
|
+
|
|
176
268
|
__drawPathByData(drawer: IPathDrawer, data: IPathCommandData): void
|
|
269
|
+
__drawAfterFill?(canvas: ILeaferCanvas, options: IRenderOptions): void
|
|
177
270
|
}
|
|
178
271
|
|
|
179
272
|
export interface IUIData extends IUIComputedData, ILeafData {
|
|
273
|
+
|
|
274
|
+
padding?: number | number[]
|
|
275
|
+
locked?: boolean
|
|
276
|
+
|
|
180
277
|
// 非数据属性, 自动计算的缓存数据
|
|
181
278
|
__isFills?: boolean
|
|
182
279
|
__isStrokes?: boolean
|
|
280
|
+
__drawAfterFill?: boolean
|
|
281
|
+
__isOverflow?: boolean
|
|
282
|
+
__blendLayer?: boolean
|
|
183
283
|
|
|
184
284
|
__isTranslucentFill?: boolean // 半透明的
|
|
185
285
|
__isTranslucentStroke?: boolean
|
|
@@ -193,16 +293,40 @@ export interface IUIData extends IUIComputedData, ILeafData {
|
|
|
193
293
|
__pathForRender?: IPathCommandData
|
|
194
294
|
__path2DForRender?: IPath2D
|
|
195
295
|
|
|
196
|
-
|
|
296
|
+
__boxStroke?: boolean
|
|
297
|
+
|
|
298
|
+
// text
|
|
299
|
+
__font?: string
|
|
300
|
+
__textDrawData?: ITextDrawData
|
|
301
|
+
|
|
197
302
|
}
|
|
198
|
-
export interface IUIComputedData extends IFillComputedData, IBorderComputedData, IStrokeComputedData, ICornerRadiusComputedData, IEffectComputedData, ILeafComputedData {
|
|
199
|
-
|
|
200
|
-
mask?: boolean
|
|
303
|
+
export interface IUIComputedData extends IFillComputedData, IBorderComputedData, IStrokeComputedData, ITextStyleComputedData, ICornerRadiusComputedData, IEffectComputedData, ILeafComputedData {
|
|
304
|
+
padding?: number | number[]
|
|
201
305
|
locked?: boolean
|
|
202
306
|
}
|
|
203
307
|
|
|
204
|
-
export interface IUIInputData extends IFillInputData, IStrokeInputData, ICornerRadiusInputData, IEffectInputData, ILeafInputData {
|
|
205
|
-
|
|
206
|
-
mask?: boolean
|
|
308
|
+
export interface IUIInputData extends IFillInputData, IStrokeInputData, ITextStyleInputData, ICornerRadiusInputData, IEffectInputData, ILeafInputData {
|
|
309
|
+
padding?: number | number[]
|
|
207
310
|
locked?: boolean
|
|
208
311
|
}
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
export type IUITag =
|
|
315
|
+
| 'Rect'
|
|
316
|
+
| 'Ellipse'
|
|
317
|
+
| 'Polygon'
|
|
318
|
+
| 'Star'
|
|
319
|
+
| 'Line'
|
|
320
|
+
| 'Path'
|
|
321
|
+
| 'Pen'
|
|
322
|
+
| 'Text'
|
|
323
|
+
| 'Image'
|
|
324
|
+
| 'Canvas'
|
|
325
|
+
| 'Group'
|
|
326
|
+
| 'Frame'
|
|
327
|
+
| 'Box'
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
export interface IUITagInputData extends IRectInputData, IEllipseInputData, IPolygonInputData, IStarInputData, ILineInputData, IPathInputData, ITextInputData, IImageInputData, IGroupInputData, IFrameInputData, IObject {
|
|
331
|
+
tagName?: IUITag
|
|
332
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -7,18 +7,22 @@ export {
|
|
|
7
7
|
IPolygon, IPolygonInputData, IPolygonData,
|
|
8
8
|
IStar, IStarInputData, IStarData,
|
|
9
9
|
IPath, IPathInputData, IPathData,
|
|
10
|
-
|
|
11
|
-
IText, ITextInputData, ITextData,
|
|
10
|
+
IPen, IPenInputData, IPenData,
|
|
11
|
+
IText, ITextInputData, ITextData, ITextRowData, ITextWordData, ITextCharData, ITextDrawData,
|
|
12
12
|
IImage, IImageInputData, IImageData,
|
|
13
|
+
ICanvas, ICanvasInputData, ICanvasData,
|
|
13
14
|
IFrame, IFrameInputData, IFrameData,
|
|
15
|
+
IBox, IBoxInputData, IBoxData,
|
|
14
16
|
IGroup, IGroupInputData, IGroupData,
|
|
15
|
-
|
|
17
|
+
ILeaferInputData, ILeaferData,
|
|
18
|
+
IUI, IUIInputData, IUIData,
|
|
19
|
+
IUITag, IUITagInputData
|
|
16
20
|
} from './IUI'
|
|
17
|
-
export {
|
|
18
|
-
export { ICornerRadiusString, IStrokeWidthString, IPaintString, IShadowString, IPercent, IDashPatternString,
|
|
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
|
+
export { ICornerRadiusString, IStrokeWidthString, IPaintString, IShadowString, IPercent, IDashPatternString, IColorString as IStringColor } from './type/IStringType'
|
|
19
23
|
export { ILeafFill, ILeafPaint, ILeafPaintColor, ILeafStrokePaint, ILeafShadowEffect } from './type/IComputedType'
|
|
20
24
|
|
|
21
|
-
export { IUIRenderModule, IRectRenderModule, IGroupRenderModule, IFrameRenderModule } from './module/IUIRender'
|
|
25
|
+
export { IUIRenderModule, IRectRenderModule, IImageRenderModule, ITextRenderModule, IGroupRenderModule, IFrameRenderModule } from './module/IUIRender'
|
|
22
26
|
export { IUIBoundsModule } from './module/IUIBounds'
|
|
23
27
|
export { IUIHitModule } from './module/IUIHit'
|
|
24
28
|
|
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,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IBlendMode, IMatrixData } from '@leafer/interface'
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { IColorString } from './IStringType'
|
|
4
|
+
import { IStrokeAlign, IStrokeJoin, IStrokeCap } from './IType'
|
|
5
5
|
import { IPaintType } from './IType'
|
|
6
6
|
|
|
7
|
-
export type ILeafPaintColor =
|
|
7
|
+
export type ILeafPaintColor = IColorString | CanvasGradient | CanvasPattern
|
|
8
8
|
|
|
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
|
}
|
|
@@ -30,7 +30,7 @@ export interface ILeafShadowEffect {
|
|
|
30
30
|
y: number
|
|
31
31
|
blur: number
|
|
32
32
|
spread?: number
|
|
33
|
-
color:
|
|
33
|
+
color: IColorString
|
|
34
34
|
blendMode?: IBlendMode
|
|
35
|
-
|
|
35
|
+
box?: boolean
|
|
36
36
|
}
|
package/src/type/IStringType.ts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
export type IPercent = string
|
|
2
|
-
|
|
3
|
-
export type IStringColor = string
|
|
2
|
+
export type IColorString = string
|
|
4
3
|
|
|
5
4
|
export type ICornerRadiusString = string
|
|
6
5
|
export type IStrokeWidthString = string
|
|
7
6
|
export type IDashPatternString = string
|
|
8
|
-
export type IVectorPathString = string
|
|
9
|
-
export type IPathString = string
|
|
10
7
|
|
|
11
8
|
export type IPaintString = ISolidPaintString | IGradientPaintString | IImagePaintString
|
|
12
9
|
export type ISolidPaintString = string
|
package/src/type/IType.ts
CHANGED
|
@@ -1,25 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export type IBlendMode =
|
|
5
|
-
| 'pass-through'
|
|
6
|
-
| 'normal'
|
|
7
|
-
| 'multiply'
|
|
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'
|
|
1
|
+
import { IPointData, IPathCommandData, IWindingRule, IBlendMode } from '@leafer/interface'
|
|
2
|
+
import { IColorString } from './IStringType'
|
|
22
3
|
|
|
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 =
|
|
35
|
+
export type IColor = IColorString | 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,7 +100,7 @@ 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 {
|
|
@@ -125,10 +114,10 @@ export interface IShadowEffect {
|
|
|
125
114
|
y: number
|
|
126
115
|
blur: number
|
|
127
116
|
spread?: number
|
|
128
|
-
color:
|
|
117
|
+
color: IColorString | IColor
|
|
129
118
|
blendMode?: IBlendMode
|
|
130
119
|
visible?: boolean
|
|
131
|
-
|
|
120
|
+
box?: boolean
|
|
132
121
|
}
|
|
133
122
|
|
|
134
123
|
export interface IBlurEffect {
|
|
@@ -139,4 +128,6 @@ export interface IBlurEffect {
|
|
|
139
128
|
export interface IGrayscaleEffect {
|
|
140
129
|
grayscale: number
|
|
141
130
|
visible?: boolean
|
|
142
|
-
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export type IOverflow = 'show' | 'hide'
|