@leafer-ui/interface 1.0.0-alpha.23 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-ui/interface",
3
- "version": "1.0.0-alpha.23",
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.23"
22
+ "@leafer/interface": "1.0.0-alpha.30"
23
23
  }
24
24
  }
@@ -1,4 +1,4 @@
1
- import { IPaint, IStrokeAlign, IStrokeCap, IStrokeJoin, IBlurEffect, IFontWeight, ITextCase, ITextDecoration, IShadowEffect, IGrayscaleEffect, ITextAlign, IVerticalAlign } 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,14 +77,16 @@ export interface ITextStyleAttrData {
77
77
  italic: boolean
78
78
  textCase: ITextCase
79
79
  textDecoration: ITextDecoration
80
- letterSpacing: number | IPercent
81
- lineHeight: number | IPercent
80
+ letterSpacing: number | IUnitData
81
+ lineHeight: number | IUnitData
82
82
 
83
- paragraphIndent: number
84
- paragraphSpacing: number
83
+ paraIndent: number
84
+ paraSpacing: number
85
85
 
86
86
  textAlign: ITextAlign
87
87
  verticalAlign: IVerticalAlign
88
+
89
+ textOverflow: IOverflow | string
88
90
  }
89
91
  export interface ITextStyleInputData {
90
92
  fontFamily?: string
@@ -93,14 +95,16 @@ export interface ITextStyleInputData {
93
95
  italic?: boolean
94
96
  textCase?: ITextCase
95
97
  textDecoration?: ITextDecoration
96
- letterSpacing?: number | IPercent
97
- lineHeight?: number | IPercent
98
+ letterSpacing?: number | IUnitData
99
+ lineHeight?: number | IUnitData
98
100
 
99
- paragraphIndent?: number
100
- paragraphSpacing?: number
101
+ paraIndent?: number
102
+ paraSpacing?: number
101
103
 
102
104
  textAlign?: ITextAlign
103
105
  verticalAlign?: IVerticalAlign
106
+
107
+ textOverflow?: IOverflow | string
104
108
  }
105
109
  export interface ITextStyleComputedData {
106
110
  fontFamily?: string
@@ -112,11 +116,12 @@ export interface ITextStyleComputedData {
112
116
  letterSpacing?: number
113
117
  lineHeight?: number
114
118
 
115
- paragraphIndent?: number
116
- paragraphSpacing?: number
119
+ paraIndent?: number
120
+ paraSpacing?: number
117
121
 
118
122
  textAlign?: ITextAlign
119
123
  verticalAlign?: IVerticalAlign
124
+ textOverflow?: IOverflow
120
125
  }
121
126
 
122
127
  // effect---
package/src/IUI.ts CHANGED
@@ -1,7 +1,7 @@
1
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 { IVectorPath } from './type/IType'
4
+ import { IOverflow, IUnitData, IVectorPath } from './type/IType'
5
5
 
6
6
  import {
7
7
  IFillAttrData, IFillInputData, IFillComputedData,
@@ -79,6 +79,8 @@ export interface IPath extends IUI {
79
79
  __: IPathData
80
80
  path: IPathCommandData | IPathString
81
81
  windingRule: IWindingRule
82
+ getCurvePath(): IPathCommandData
83
+ getStringPath(curve?: boolean): IPathString
82
84
  }
83
85
  export interface IPathData extends IUIData {
84
86
  path?: IPathCommandData
@@ -89,6 +91,33 @@ export interface IPathInputData extends IUIInputData {
89
91
  windingRule?: IWindingRule
90
92
  }
91
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 { }
92
121
 
93
122
  // Vector
94
123
  export interface IVector extends IUI {
@@ -106,10 +135,19 @@ export interface IVectorInputData extends IUIInputData {
106
135
  // Text
107
136
  export interface IText extends ITextStyleAttrData, IUI {
108
137
  __: ITextData
109
- content: string
138
+ text: string
110
139
  }
111
140
  interface ITextAttrData {
112
- content?: string
141
+ text?: string
142
+ }
143
+
144
+ export interface ITextData extends ITextAttrData, ITextStyleComputedData, IUIData {
145
+ __baseLine?: number
146
+ __lineHeight?: number
147
+ __letterSpacing?: number
148
+ }
149
+ export interface ITextInputData extends ITextAttrData, ITextStyleInputData, IUIInputData {
150
+
113
151
  }
114
152
 
115
153
  export interface ITextRowData {
@@ -117,23 +155,40 @@ export interface ITextRowData {
117
155
  y?: number
118
156
  width?: number
119
157
  height?: number
120
- text: string
121
- }
158
+ text?: string
159
+ data?: ITextCharData[]
160
+ words?: ITextWordData[]
122
161
 
123
- export interface ITextDrawData extends IBoundsData {
124
- list: ITextRowData[]
125
- font: string
126
- decorationY?: number
127
- decorationHeight?: number
128
- }
129
- export interface ITextData extends ITextAttrData, ITextStyleComputedData, IUIData {
162
+ paraStart?: boolean // paragraph start
163
+ paraEnd?: boolean // paragraph end
164
+ isOverflow?: boolean
130
165
  }
131
- export interface ITextInputData extends ITextAttrData, ITextStyleInputData, IUIInputData {
132
166
 
167
+ export interface ITextWordData {
168
+ x?: number
169
+ y?: number
170
+ width?: number
171
+ height?: number
172
+ data?: ITextCharData[]
133
173
  }
134
174
 
175
+ export interface ITextCharData {
176
+ x?: number
177
+ y?: number
178
+ width?: number
179
+ height?: number
180
+ char?: string
181
+ }
135
182
 
136
-
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
+ }
137
192
 
138
193
  // Image
139
194
  export interface IImage extends IRect, ILeaferImageConfig {
@@ -148,21 +203,54 @@ interface IImageAttrData {
148
203
  export interface IImageData extends IImageAttrData, IRectData { }
149
204
  export interface IImageInputData extends IImageAttrData, IUIInputData { }
150
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
+
151
230
  // Frame
152
- export interface IFrame extends IGroup {
231
+ export interface IFrame extends IBox {
153
232
  __: IFrameData
154
- clip: boolean
155
- __updateRectBoxBounds(): void
156
- __updateRectStrokeBounds(): void
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
157
246
  __updateRectRenderBounds(): void
158
- __renderRect(canvas: ILeaferCanvas, options: IRenderOptions): void
159
247
  __renderGroup(canvas: ILeaferCanvas, options: IRenderOptions): void
160
248
  }
161
- export interface IFrameData extends IGroupData {
162
- clip?: boolean
249
+ export interface IBoxData extends IGroupData {
250
+ overflow?: IOverflow
163
251
  }
164
- export interface IFrameInputData extends IGroupInputData {
165
- clip?: boolean
252
+ export interface IBoxInputData extends IGroupInputData {
253
+ overflow?: IOverflow
166
254
  }
167
255
 
168
256
 
@@ -189,12 +277,19 @@ export interface IUI extends IFillAttrData, IStrokeAttrData, ICornerRadiusAttrDa
189
277
  get(): IUITagInputData
190
278
 
191
279
  __drawPathByData(drawer: IPathDrawer, data: IPathCommandData): void
280
+ __drawAfterFill?(canvas: ILeaferCanvas, options: IRenderOptions): void
192
281
  }
193
282
 
194
283
  export interface IUIData extends IUIComputedData, ILeafData {
284
+
285
+ padding?: number | number[]
286
+ locked?: boolean
287
+
195
288
  // 非数据属性, 自动计算的缓存数据
196
289
  __isFills?: boolean
197
290
  __isStrokes?: boolean
291
+ __drawAfterFill?: boolean
292
+ __isOverflow?: boolean
198
293
 
199
294
  __isTranslucentFill?: boolean // 半透明的
200
295
  __isTranslucentStroke?: boolean
@@ -211,13 +306,17 @@ export interface IUIData extends IUIComputedData, ILeafData {
211
306
  __strokeOuterWidth?: number // boxBounds外面的笔触宽度
212
307
 
213
308
  // text
309
+ __font?: string
214
310
  __textDrawData?: ITextDrawData
311
+
215
312
  }
216
- export interface IUIComputedData extends IFillComputedData, IBorderComputedData, IStrokeComputedData, ICornerRadiusComputedData, IEffectComputedData, ILeafComputedData {
313
+ export interface IUIComputedData extends IFillComputedData, IBorderComputedData, IStrokeComputedData, ITextStyleComputedData, ICornerRadiusComputedData, IEffectComputedData, ILeafComputedData {
314
+ padding?: number | number[]
217
315
  locked?: boolean
218
316
  }
219
317
 
220
- export interface IUIInputData extends IFillInputData, IStrokeInputData, ICornerRadiusInputData, IEffectInputData, ILeafInputData {
318
+ export interface IUIInputData extends IFillInputData, IStrokeInputData, ITextStyleInputData, ICornerRadiusInputData, IEffectInputData, ILeafInputData {
319
+ padding?: number | number[]
221
320
  locked?: boolean
222
321
  }
223
322
 
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,15 +8,19 @@ 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, ITextRowData, ITextDrawData,
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,
19
+ ILeaferInputData, ILeaferData,
15
20
  IUI, IUIInputData, IUIData,
16
21
  IUITag, IUITagInputData
17
22
  } from './IUI'
18
- export { IVectorPath, IShadowEffect, IBlurEffect, IGrayscaleEffect, IStrokeAlign, IStrokeJoin, IStrokeCap, IColor, IColorStop, IPaint, IGradientPaint, IImagePaint, IImagePaintMode, IFontWeight, ITextCase, ITextDecoration, ITextAlign, IVerticalAlign } from './type/IType'
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'
19
24
  export { ICornerRadiusString, IStrokeWidthString, IPaintString, IShadowString, IPercent, IDashPatternString, IPathString, IVectorPathString, IStringColor } from './type/IStringType'
20
25
  export { ILeafFill, ILeafPaint, ILeafPaintColor, ILeafStrokePaint, ILeafShadowEffect } from './type/IComputedType'
21
26
 
@@ -11,8 +11,15 @@ export interface IPaintModule {
11
11
  fill?(ui: IUI, canvas: ILeaferCanvas, fill: string | object): void
12
12
  fills?(ui: IUI, canvas: ILeaferCanvas, fills: ILeafPaint[]): void
13
13
 
14
+ drawText?(ui: IUI, canvas: ILeaferCanvas): void
15
+
14
16
  stroke?(ui: IUI, canvas: ILeaferCanvas, stroke: string | object): void
15
17
  strokes?(ui: IUI, canvas: ILeaferCanvas, strokes: ILeafPaint[]): void
16
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
+
17
24
  shape?(ui: IUI, current: ILeaferCanvas, options: IRenderOptions): ICachedShape
18
25
  }
@@ -1,10 +1,11 @@
1
- import { ILeafRender } from '@leafer/interface'
1
+ import { ILeafRender, ILeaferCanvas, IRenderOptions } from '@leafer/interface'
2
2
 
3
3
  import { IUI, IRect, IImage, IText, IFrame, IGroup } from '../IUI'
4
4
 
5
5
  export type IUIRenderModule = IUIRender & ThisType<IUI>
6
6
 
7
7
  export interface IUIRender extends ILeafRender {
8
+ __drawAfterFill?(canvas: ILeaferCanvas, options: IRenderOptions): void
8
9
  }
9
10
 
10
11
  export type IRectRenderModule = IRectRender & ThisType<IRect>
package/src/type/IType.ts CHANGED
@@ -1,6 +1,10 @@
1
- import { IMatrixData, IPointData, IPathCommandData, IWindingRule, IBlendMode } from '@leafer/interface'
1
+ import { IPointData, IPathCommandData, IWindingRule, IBlendMode } from '@leafer/interface'
2
2
  import { IStringColor } from './IStringType'
3
3
 
4
+ export interface IUnitData {
5
+ type: 'percent' | 'px'
6
+ value: number
7
+ }
4
8
 
5
9
  export type IPaint = ISolidPaint | IGradientPaint | IImagePaint
6
10
 
@@ -83,9 +87,9 @@ export type IStrokeJoin = 'bevel' | 'round' | 'miter'
83
87
  // 文本
84
88
  export type ITextAlign = 'left' | 'center' | 'right' | 'justify'
85
89
  export type IVerticalAlign = 'top' | 'middle' | 'bottom'
86
- export type ITextCase = | 'upper' | 'lower' | 'title' | 'original' | 'small-caps' | 'small-caps-forced'
87
- export type IFontWeight = IFontWeightNumerical | IFontWeightString
88
- export type IFontWeightNumerical = 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
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
89
93
  export type IFontWeightString =
90
94
  | 'thin'
91
95
  | 'extra-light'
@@ -96,7 +100,7 @@ export type IFontWeightString =
96
100
  | 'bold'
97
101
  | 'extra-bold'
98
102
  | 'black'
99
- export type ITextDecoration = 'none' | 'strikethrough' | 'underline'
103
+ export type ITextDecoration = 'none' | 'delete' | 'underline'
100
104
 
101
105
  // 路径
102
106
  export interface IVectorPath {
@@ -124,4 +128,6 @@ export interface IBlurEffect {
124
128
  export interface IGrayscaleEffect {
125
129
  grayscale: number
126
130
  visible?: boolean
127
- }
131
+ }
132
+
133
+ export type IOverflow = 'show' | 'hide'