@leafer-ui/interface 1.0.0-alpha.21 → 1.0.0-alpha.30
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 +27 -11
- package/src/IUI.ts +163 -32
- package/src/index.ts +10 -4
- package/src/module/IPaint.ts +14 -1
- package/src/module/IUIRender.ts +14 -8
- package/src/type/IComputedType.ts +3 -3
- package/src/type/IType.ts +28 -37
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/interface",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.30",
|
|
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-alpha.
|
|
22
|
+
"@leafer/interface": "1.0.0-alpha.30"
|
|
23
23
|
}
|
|
24
24
|
}
|
package/src/ICommonAttr.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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
3
|
import { IPaintString, IDashPatternString, IPercent, IShadowString, IStringColor, IStrokeWidthString, ICornerRadiusString } from './type/IStringType'
|
|
4
4
|
|
|
@@ -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,7 @@
|
|
|
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, 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, IUnitData, IVectorPath } from './type/IType'
|
|
6
5
|
|
|
7
6
|
import {
|
|
8
7
|
IFillAttrData, IFillInputData, IFillComputedData,
|
|
@@ -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
|
|
@@ -78,6 +79,8 @@ export interface IPath extends IUI {
|
|
|
78
79
|
__: IPathData
|
|
79
80
|
path: IPathCommandData | IPathString
|
|
80
81
|
windingRule: IWindingRule
|
|
82
|
+
getCurvePath(): IPathCommandData
|
|
83
|
+
getStringPath(curve?: boolean): IPathString
|
|
81
84
|
}
|
|
82
85
|
export interface IPathData extends IUIData {
|
|
83
86
|
path?: IPathCommandData
|
|
@@ -88,6 +91,33 @@ export interface IPathInputData extends IUIInputData {
|
|
|
88
91
|
windingRule?: IWindingRule
|
|
89
92
|
}
|
|
90
93
|
|
|
94
|
+
// Pen
|
|
95
|
+
|
|
96
|
+
export interface IPen extends IGroup {
|
|
97
|
+
__: IPenData
|
|
98
|
+
path: IPath
|
|
99
|
+
pathStyle: IPathInputData
|
|
100
|
+
pathData: IPathCommandData
|
|
101
|
+
|
|
102
|
+
moveTo(x: number, y: number): IPen
|
|
103
|
+
lineTo(x: number, y: number): IPen
|
|
104
|
+
bezierCurveTo(x1: number, y1: number, x2: number, y2: number, x: number, y: number): IPen
|
|
105
|
+
quadraticCurveTo(x1: number, y1: number, x: number, y: number): IPen
|
|
106
|
+
|
|
107
|
+
rect(x: number, y: number, width: number, height: number): IPen
|
|
108
|
+
roundRect(x: number, y: number, width: number, height: number, cornerRadius: number | number[]): IPen
|
|
109
|
+
ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation?: number, startAngle?: number, endAngle?: number, anticlockwise?: boolean): IPen
|
|
110
|
+
arc(x: number, y: number, radius: number, startAngle?: number, endAngle?: number, anticlockwise?: boolean): IPen
|
|
111
|
+
arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): IPen
|
|
112
|
+
|
|
113
|
+
close(): IPen
|
|
114
|
+
clear(): IPen
|
|
115
|
+
|
|
116
|
+
paint(): void
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface IPenData extends IGroupData { }
|
|
120
|
+
export interface IPenInputData extends IGroupInputData { }
|
|
91
121
|
|
|
92
122
|
// Vector
|
|
93
123
|
export interface IVector extends IUI {
|
|
@@ -105,56 +135,130 @@ export interface IVectorInputData extends IUIInputData {
|
|
|
105
135
|
// Text
|
|
106
136
|
export interface IText extends ITextStyleAttrData, IUI {
|
|
107
137
|
__: ITextData
|
|
108
|
-
|
|
138
|
+
text: string
|
|
109
139
|
}
|
|
110
140
|
interface ITextAttrData {
|
|
111
|
-
|
|
141
|
+
text?: string
|
|
112
142
|
}
|
|
143
|
+
|
|
113
144
|
export interface ITextData extends ITextAttrData, ITextStyleComputedData, IUIData {
|
|
114
|
-
|
|
145
|
+
__baseLine?: number
|
|
146
|
+
__lineHeight?: number
|
|
147
|
+
__letterSpacing?: number
|
|
115
148
|
}
|
|
116
149
|
export interface ITextInputData extends ITextAttrData, ITextStyleInputData, IUIInputData {
|
|
117
150
|
|
|
118
151
|
}
|
|
119
152
|
|
|
153
|
+
export interface ITextRowData {
|
|
154
|
+
x?: number
|
|
155
|
+
y?: number
|
|
156
|
+
width?: number
|
|
157
|
+
height?: number
|
|
158
|
+
text?: string
|
|
159
|
+
data?: ITextCharData[]
|
|
160
|
+
words?: ITextWordData[]
|
|
161
|
+
|
|
162
|
+
paraStart?: boolean // paragraph start
|
|
163
|
+
paraEnd?: boolean // paragraph end
|
|
164
|
+
isOverflow?: boolean
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export interface ITextWordData {
|
|
168
|
+
x?: number
|
|
169
|
+
y?: number
|
|
170
|
+
width?: number
|
|
171
|
+
height?: number
|
|
172
|
+
data?: ITextCharData[]
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export interface ITextCharData {
|
|
176
|
+
x?: number
|
|
177
|
+
y?: number
|
|
178
|
+
width?: number
|
|
179
|
+
height?: number
|
|
180
|
+
char?: string
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export interface ITextDrawData {
|
|
184
|
+
bounds: IBoundsData
|
|
185
|
+
rows: ITextRowData[]
|
|
186
|
+
paraNumber: number
|
|
187
|
+
font: string
|
|
188
|
+
decorationY?: number
|
|
189
|
+
decorationHeight?: number
|
|
190
|
+
overflow?: number // overflowed row number, not index
|
|
191
|
+
}
|
|
120
192
|
|
|
121
193
|
// Image
|
|
122
194
|
export interface IImage extends IRect, ILeaferImageConfig {
|
|
123
195
|
__: IImageData
|
|
124
196
|
url: string
|
|
125
|
-
|
|
197
|
+
ready: boolean
|
|
198
|
+
image?: ILeaferImage
|
|
126
199
|
}
|
|
127
200
|
interface IImageAttrData {
|
|
128
201
|
url?: string
|
|
129
|
-
thumb?: string
|
|
130
202
|
}
|
|
131
203
|
export interface IImageData extends IImageAttrData, IRectData { }
|
|
132
204
|
export interface IImageInputData extends IImageAttrData, IUIInputData { }
|
|
133
205
|
|
|
206
|
+
export interface ICanvas extends IRect {
|
|
207
|
+
__: ICanvasData
|
|
208
|
+
pixelRatio: number
|
|
209
|
+
smooth: boolean
|
|
210
|
+
canvas: ILeaferCanvas
|
|
211
|
+
}
|
|
212
|
+
interface ICanvasAttrData {
|
|
213
|
+
pixelRatio?: number
|
|
214
|
+
smooth?: boolean
|
|
215
|
+
}
|
|
216
|
+
export interface ICanvasData extends ICanvasAttrData, IRectData { }
|
|
217
|
+
export interface ICanvasInputData extends ICanvasAttrData, IUIInputData { }
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
// Leafer
|
|
221
|
+
export interface ILeaferData extends IGroupData {
|
|
222
|
+
pixelRatio?: number
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export interface ILeaferInputData extends IGroupInputData {
|
|
226
|
+
pixelRatio?: number
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
|
|
134
230
|
// Frame
|
|
135
|
-
export interface IFrame extends
|
|
231
|
+
export interface IFrame extends IBox {
|
|
136
232
|
__: IFrameData
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
233
|
+
}
|
|
234
|
+
export interface IFrameData extends IBoxData {
|
|
235
|
+
|
|
236
|
+
}
|
|
237
|
+
export interface IFrameInputData extends IBoxInputData {
|
|
238
|
+
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
// Box
|
|
243
|
+
export interface IBox extends IGroup {
|
|
244
|
+
__: IBoxData
|
|
245
|
+
overflow: IOverflow
|
|
140
246
|
__updateRectRenderBounds(): void
|
|
141
|
-
__renderRect(canvas: ILeaferCanvas, options: IRenderOptions): void
|
|
142
247
|
__renderGroup(canvas: ILeaferCanvas, options: IRenderOptions): void
|
|
143
248
|
}
|
|
144
|
-
export interface
|
|
145
|
-
|
|
249
|
+
export interface IBoxData extends IGroupData {
|
|
250
|
+
overflow?: IOverflow
|
|
146
251
|
}
|
|
147
|
-
export interface
|
|
148
|
-
|
|
252
|
+
export interface IBoxInputData extends IGroupInputData {
|
|
253
|
+
overflow?: IOverflow
|
|
149
254
|
}
|
|
150
255
|
|
|
151
256
|
|
|
152
257
|
// Group
|
|
153
|
-
export interface IGroup extends
|
|
258
|
+
export interface IGroup extends IUI {
|
|
154
259
|
__: IGroupData
|
|
155
|
-
root?: IGroup
|
|
156
|
-
parent?: IGroup
|
|
157
260
|
children: IUI[]
|
|
261
|
+
mask?: IUI
|
|
158
262
|
add(child: IUI, index?: number): void
|
|
159
263
|
remove(child?: IUI): void
|
|
160
264
|
addAt(child: IUI, index: number): void
|
|
@@ -167,19 +271,25 @@ export interface IGroupInputData extends IUIInputData { }
|
|
|
167
271
|
// UI
|
|
168
272
|
export interface IUI extends IFillAttrData, IStrokeAttrData, ICornerRadiusAttrData, IEffectAttrData, ILeaf {
|
|
169
273
|
__: IUIData
|
|
170
|
-
root?: IGroup
|
|
171
274
|
parent?: IGroup
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
275
|
+
|
|
276
|
+
set(data: IUITagInputData): void
|
|
277
|
+
get(): IUITagInputData
|
|
278
|
+
|
|
176
279
|
__drawPathByData(drawer: IPathDrawer, data: IPathCommandData): void
|
|
280
|
+
__drawAfterFill?(canvas: ILeaferCanvas, options: IRenderOptions): void
|
|
177
281
|
}
|
|
178
282
|
|
|
179
283
|
export interface IUIData extends IUIComputedData, ILeafData {
|
|
284
|
+
|
|
285
|
+
padding?: number | number[]
|
|
286
|
+
locked?: boolean
|
|
287
|
+
|
|
180
288
|
// 非数据属性, 自动计算的缓存数据
|
|
181
289
|
__isFills?: boolean
|
|
182
290
|
__isStrokes?: boolean
|
|
291
|
+
__drawAfterFill?: boolean
|
|
292
|
+
__isOverflow?: boolean
|
|
183
293
|
|
|
184
294
|
__isTranslucentFill?: boolean // 半透明的
|
|
185
295
|
__isTranslucentStroke?: boolean
|
|
@@ -194,15 +304,36 @@ export interface IUIData extends IUIComputedData, ILeafData {
|
|
|
194
304
|
__path2DForRender?: IPath2D
|
|
195
305
|
|
|
196
306
|
__strokeOuterWidth?: number // boxBounds外面的笔触宽度
|
|
307
|
+
|
|
308
|
+
// text
|
|
309
|
+
__font?: string
|
|
310
|
+
__textDrawData?: ITextDrawData
|
|
311
|
+
|
|
197
312
|
}
|
|
198
|
-
export interface IUIComputedData extends IFillComputedData, IBorderComputedData, IStrokeComputedData, ICornerRadiusComputedData, IEffectComputedData, ILeafComputedData {
|
|
199
|
-
|
|
200
|
-
mask?: boolean
|
|
313
|
+
export interface IUIComputedData extends IFillComputedData, IBorderComputedData, IStrokeComputedData, ITextStyleComputedData, ICornerRadiusComputedData, IEffectComputedData, ILeafComputedData {
|
|
314
|
+
padding?: number | number[]
|
|
201
315
|
locked?: boolean
|
|
202
316
|
}
|
|
203
317
|
|
|
204
|
-
export interface IUIInputData extends IFillInputData, IStrokeInputData, ICornerRadiusInputData, IEffectInputData, ILeafInputData {
|
|
205
|
-
|
|
206
|
-
mask?: boolean
|
|
318
|
+
export interface IUIInputData extends IFillInputData, IStrokeInputData, ITextStyleInputData, ICornerRadiusInputData, IEffectInputData, ILeafInputData {
|
|
319
|
+
padding?: number | number[]
|
|
207
320
|
locked?: boolean
|
|
208
321
|
}
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
export type IUITag =
|
|
325
|
+
| 'Rect'
|
|
326
|
+
| 'Ellipse'
|
|
327
|
+
| 'Polygon'
|
|
328
|
+
| 'Star'
|
|
329
|
+
| 'Line'
|
|
330
|
+
| 'Path'
|
|
331
|
+
| 'Text'
|
|
332
|
+
| 'Image'
|
|
333
|
+
| 'Group'
|
|
334
|
+
| 'Frame'
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
export interface IUITagInputData extends IRectInputData, IEllipseInputData, IPolygonInputData, IStarInputData, ILineInputData, IPathInputData, ITextInputData, IImageInputData, IGroupInputData, IFrameInputData, IObject {
|
|
338
|
+
tagName?: IUITag
|
|
339
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ITextStyleComputedData } from './ICommonAttr'
|
|
1
2
|
export * from '@leafer/interface'
|
|
2
3
|
|
|
3
4
|
export {
|
|
@@ -7,18 +8,23 @@ export {
|
|
|
7
8
|
IPolygon, IPolygonInputData, IPolygonData,
|
|
8
9
|
IStar, IStarInputData, IStarData,
|
|
9
10
|
IPath, IPathInputData, IPathData,
|
|
11
|
+
IPen, IPenInputData, IPenData,
|
|
10
12
|
IVector, IVectorInputData, IVectorData,
|
|
11
|
-
IText, ITextInputData, ITextData,
|
|
13
|
+
IText, ITextInputData, ITextData, ITextRowData, ITextWordData, ITextCharData, ITextDrawData,
|
|
12
14
|
IImage, IImageInputData, IImageData,
|
|
15
|
+
ICanvas, ICanvasInputData, ICanvasData,
|
|
13
16
|
IFrame, IFrameInputData, IFrameData,
|
|
17
|
+
IBox, IBoxInputData, IBoxData,
|
|
14
18
|
IGroup, IGroupInputData, IGroupData,
|
|
15
|
-
|
|
19
|
+
ILeaferInputData, ILeaferData,
|
|
20
|
+
IUI, IUIInputData, IUIData,
|
|
21
|
+
IUITag, IUITagInputData
|
|
16
22
|
} from './IUI'
|
|
17
|
-
export {
|
|
23
|
+
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'
|
|
18
24
|
export { ICornerRadiusString, IStrokeWidthString, IPaintString, IShadowString, IPercent, IDashPatternString, IPathString, IVectorPathString, IStringColor } from './type/IStringType'
|
|
19
25
|
export { ILeafFill, ILeafPaint, ILeafPaintColor, ILeafStrokePaint, ILeafShadowEffect } from './type/IComputedType'
|
|
20
26
|
|
|
21
|
-
export { IUIRenderModule, IRectRenderModule, IImageRenderModule, IGroupRenderModule, IFrameRenderModule } from './module/IUIRender'
|
|
27
|
+
export { IUIRenderModule, IRectRenderModule, IImageRenderModule, ITextRenderModule, IGroupRenderModule, IFrameRenderModule } from './module/IUIRender'
|
|
22
28
|
export { IUIBoundsModule } from './module/IUIBounds'
|
|
23
29
|
export { IUIHitModule } from './module/IUIHit'
|
|
24
30
|
|
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,34 +1,40 @@
|
|
|
1
|
-
import { ILeafRender, ILeaferCanvas, IRenderOptions
|
|
1
|
+
import { ILeafRender, ILeaferCanvas, IRenderOptions } from '@leafer/interface'
|
|
2
2
|
|
|
3
|
-
import { IUI, IRect, IImage, 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
14
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export type IImageRenderModule = IImageRender & ThisType<IImage>
|
|
18
18
|
|
|
19
|
-
interface IImageRender extends IUIRender {
|
|
19
|
+
export interface IImageRender extends IUIRender {
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type ITextRenderModule = ITextRender & ThisType<IText>
|
|
24
|
+
|
|
25
|
+
export interface ITextRender extends IUIRender {
|
|
20
26
|
|
|
21
27
|
}
|
|
22
28
|
|
|
23
29
|
export type IGroupRenderModule = IGroupRender & ThisType<IGroup>
|
|
24
30
|
|
|
25
|
-
interface IGroupRender extends IUIRender {
|
|
31
|
+
export interface IGroupRender extends IUIRender {
|
|
26
32
|
|
|
27
33
|
}
|
|
28
34
|
|
|
29
35
|
export type IFrameRenderModule = IFrameRender & ThisType<IFrame>
|
|
30
36
|
|
|
31
|
-
interface IFrameRender extends IGroupRender {
|
|
37
|
+
export interface IFrameRender extends IGroupRender {
|
|
32
38
|
|
|
33
39
|
}
|
|
34
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
|
}
|
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' | 'small-caps-forced'
|
|
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' | 'delete' | 'underline'
|
|
115
104
|
|
|
116
105
|
// 路径
|
|
117
106
|
export interface IVectorPath {
|
|
@@ -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'
|