@leafer-ui/interface 1.0.0-alpha.10 → 1.0.0-alpha.23

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.10",
3
+ "version": "1.0.0-alpha.23",
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.10"
22
+ "@leafer/interface": "1.0.0-alpha.23"
23
23
  }
24
24
  }
@@ -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 } 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
 
@@ -79,8 +79,12 @@ export interface ITextStyleAttrData {
79
79
  textDecoration: ITextDecoration
80
80
  letterSpacing: number | IPercent
81
81
  lineHeight: number | IPercent
82
+
82
83
  paragraphIndent: number
83
84
  paragraphSpacing: number
85
+
86
+ textAlign: ITextAlign
87
+ verticalAlign: IVerticalAlign
84
88
  }
85
89
  export interface ITextStyleInputData {
86
90
  fontFamily?: string
@@ -91,8 +95,12 @@ export interface ITextStyleInputData {
91
95
  textDecoration?: ITextDecoration
92
96
  letterSpacing?: number | IPercent
93
97
  lineHeight?: number | IPercent
98
+
94
99
  paragraphIndent?: number
95
100
  paragraphSpacing?: number
101
+
102
+ textAlign?: ITextAlign
103
+ verticalAlign?: IVerticalAlign
96
104
  }
97
105
  export interface ITextStyleComputedData {
98
106
  fontFamily?: string
@@ -106,6 +114,9 @@ export interface ITextStyleComputedData {
106
114
 
107
115
  paragraphIndent?: number
108
116
  paragraphSpacing?: number
117
+
118
+ textAlign?: ITextAlign
119
+ verticalAlign?: IVerticalAlign
109
120
  }
110
121
 
111
122
  // effect---
package/src/IUI.ts CHANGED
@@ -1,7 +1,6 @@
1
- import { ILeaf, ILeafComputedData, ILeafData, ILeafInputData, ILeaferCanvas, IRenderOptions, IPathDrawer, IPointData, IPath2D, IPathCommandData, IWindingRule, IBranch, ILeaferImageConfig, IMatrixData, IBoundsData, __Number } from '@leafer/interface'
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 { IBlendMode } from './type/IType'
5
4
  import { IVectorPath } from './type/IType'
6
5
 
7
6
  import {
@@ -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
@@ -110,23 +111,39 @@ export interface IText extends ITextStyleAttrData, IUI {
110
111
  interface ITextAttrData {
111
112
  content?: string
112
113
  }
114
+
115
+ export interface ITextRowData {
116
+ x?: number
117
+ y?: number
118
+ width?: number
119
+ height?: number
120
+ text: string
121
+ }
122
+
123
+ export interface ITextDrawData extends IBoundsData {
124
+ list: ITextRowData[]
125
+ font: string
126
+ decorationY?: number
127
+ decorationHeight?: number
128
+ }
113
129
  export interface ITextData extends ITextAttrData, ITextStyleComputedData, IUIData {
114
- __font?: string
115
130
  }
116
131
  export interface ITextInputData extends ITextAttrData, ITextStyleInputData, IUIInputData {
117
132
 
118
133
  }
119
134
 
120
135
 
136
+
137
+
121
138
  // Image
122
139
  export interface IImage extends IRect, ILeaferImageConfig {
123
140
  __: IImageData
124
141
  url: string
125
- thumb: string
142
+ ready: boolean
143
+ image?: ILeaferImage
126
144
  }
127
145
  interface IImageAttrData {
128
146
  url?: string
129
- thumb?: string
130
147
  }
131
148
  export interface IImageData extends IImageAttrData, IRectData { }
132
149
  export interface IImageInputData extends IImageAttrData, IUIInputData { }
@@ -136,7 +153,7 @@ export interface IFrame extends IGroup {
136
153
  __: IFrameData
137
154
  clip: boolean
138
155
  __updateRectBoxBounds(): void
139
- __updateRectEventBounds(): void
156
+ __updateRectStrokeBounds(): void
140
157
  __updateRectRenderBounds(): void
141
158
  __renderRect(canvas: ILeaferCanvas, options: IRenderOptions): void
142
159
  __renderGroup(canvas: ILeaferCanvas, options: IRenderOptions): void
@@ -150,11 +167,10 @@ export interface IFrameInputData extends IGroupInputData {
150
167
 
151
168
 
152
169
  // Group
153
- export interface IGroup extends IBranch, IUI {
170
+ export interface IGroup extends IUI {
154
171
  __: IGroupData
155
- root?: IGroup
156
- parent?: IGroup
157
172
  children: IUI[]
173
+ mask?: IUI
158
174
  add(child: IUI, index?: number): void
159
175
  remove(child?: IUI): void
160
176
  addAt(child: IUI, index: number): void
@@ -167,12 +183,11 @@ export interface IGroupInputData extends IUIInputData { }
167
183
  // UI
168
184
  export interface IUI extends IFillAttrData, IStrokeAttrData, ICornerRadiusAttrData, IEffectAttrData, ILeaf {
169
185
  __: IUIData
170
- root?: IGroup
171
186
  parent?: IGroup
172
- readonly worldTransform: IMatrixData
173
- readonly relativeTransform: IMatrixData
174
- readonly worldBoxBounds: IBoundsData
175
- readonly worldRenderBounds: IBoundsData
187
+
188
+ set(data: IUITagInputData): void
189
+ get(): IUITagInputData
190
+
176
191
  __drawPathByData(drawer: IPathDrawer, data: IPathCommandData): void
177
192
  }
178
193
 
@@ -194,15 +209,32 @@ export interface IUIData extends IUIComputedData, ILeafData {
194
209
  __path2DForRender?: IPath2D
195
210
 
196
211
  __strokeOuterWidth?: number // boxBounds外面的笔触宽度
212
+
213
+ // text
214
+ __textDrawData?: ITextDrawData
197
215
  }
198
216
  export interface IUIComputedData extends IFillComputedData, IBorderComputedData, IStrokeComputedData, ICornerRadiusComputedData, IEffectComputedData, ILeafComputedData {
199
- blendMode?: IBlendMode
200
- mask?: boolean
201
217
  locked?: boolean
202
218
  }
203
219
 
204
220
  export interface IUIInputData extends IFillInputData, IStrokeInputData, ICornerRadiusInputData, IEffectInputData, ILeafInputData {
205
- blendMode?: IBlendMode
206
- mask?: boolean
207
221
  locked?: boolean
208
222
  }
223
+
224
+
225
+ export type IUITag =
226
+ | 'Rect'
227
+ | 'Ellipse'
228
+ | 'Polygon'
229
+ | 'Star'
230
+ | 'Line'
231
+ | 'Path'
232
+ | 'Text'
233
+ | 'Image'
234
+ | 'Group'
235
+ | 'Frame'
236
+
237
+
238
+ export interface IUITagInputData extends IRectInputData, IEllipseInputData, IPolygonInputData, IStarInputData, ILineInputData, IPathInputData, ITextInputData, IImageInputData, IGroupInputData, IFrameInputData, IObject {
239
+ tagName?: IUITag
240
+ }
package/src/index.ts CHANGED
@@ -8,17 +8,18 @@ export {
8
8
  IStar, IStarInputData, IStarData,
9
9
  IPath, IPathInputData, IPathData,
10
10
  IVector, IVectorInputData, IVectorData,
11
- IText, ITextInputData, ITextData,
11
+ IText, ITextInputData, ITextData, ITextRowData, ITextDrawData,
12
12
  IImage, IImageInputData, IImageData,
13
13
  IFrame, IFrameInputData, IFrameData,
14
14
  IGroup, IGroupInputData, IGroupData,
15
- IUI, IUIInputData, IUIData
15
+ IUI, IUIInputData, IUIData,
16
+ IUITag, IUITagInputData
16
17
  } from './IUI'
17
- export { IBlendMode, IVectorPath, IShadowEffect, IBlurEffect, IGrayscaleEffect, IStrokeAlign, IStrokeJoin, IStrokeCap, IColor, IPaint, IGradientPaint, IImagePaint, IImagePaintMode, IFontWeight, ITextCase, ITextDecoration } from './type/IType'
18
+ export { IVectorPath, IShadowEffect, IBlurEffect, IGrayscaleEffect, IStrokeAlign, IStrokeJoin, IStrokeCap, IColor, IColorStop, IPaint, IGradientPaint, IImagePaint, IImagePaintMode, IFontWeight, ITextCase, ITextDecoration, ITextAlign, IVerticalAlign } from './type/IType'
18
19
  export { ICornerRadiusString, IStrokeWidthString, IPaintString, IShadowString, IPercent, IDashPatternString, IPathString, IVectorPathString, IStringColor } from './type/IStringType'
19
20
  export { ILeafFill, ILeafPaint, ILeafPaintColor, ILeafStrokePaint, ILeafShadowEffect } from './type/IComputedType'
20
21
 
21
- export { IUIRenderModule, IRectRenderModule, IImageRenderModule, IGroupRenderModule, IFrameRenderModule } from './module/IUIRender'
22
+ export { IUIRenderModule, IRectRenderModule, IImageRenderModule, ITextRenderModule, IGroupRenderModule, IFrameRenderModule } from './module/IUIRender'
22
23
  export { IUIBoundsModule } from './module/IUIBounds'
23
24
  export { IUIHitModule } from './module/IUIHit'
24
25
 
@@ -1,12 +1,18 @@
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
 
10
14
  stroke?(ui: IUI, canvas: ILeaferCanvas, stroke: string | object): void
11
15
  strokes?(ui: IUI, canvas: ILeaferCanvas, strokes: ILeafPaint[]): void
16
+
17
+ shape?(ui: IUI, current: ILeaferCanvas, options: IRenderOptions): ICachedShape
12
18
  }
@@ -1,34 +1,39 @@
1
- import { ILeafRender, ILeaferCanvas, IRenderOptions, } from '@leafer/interface'
1
+ import { ILeafRender } 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
- __renderShape?(canvas: ILeaferCanvas, options: IRenderOptions): void
7
+ export interface IUIRender extends ILeafRender {
9
8
  }
10
9
 
11
10
  export type IRectRenderModule = IRectRender & ThisType<IRect>
12
11
 
13
- interface IRectRender extends IUIRender {
12
+ export interface IRectRender extends IUIRender {
14
13
 
15
14
  }
16
15
 
17
16
  export type IImageRenderModule = IImageRender & ThisType<IImage>
18
17
 
19
- interface IImageRender extends IUIRender {
18
+ export interface IImageRender extends IUIRender {
19
+
20
+ }
21
+
22
+ export type ITextRenderModule = ITextRender & ThisType<IText>
23
+
24
+ export interface ITextRender extends IUIRender {
20
25
 
21
26
  }
22
27
 
23
28
  export type IGroupRenderModule = IGroupRender & ThisType<IGroup>
24
29
 
25
- interface IGroupRender extends IUIRender {
30
+ export interface IGroupRender extends IUIRender {
26
31
 
27
32
  }
28
33
 
29
34
  export type IFrameRenderModule = IFrameRender & ThisType<IFrame>
30
35
 
31
- interface IFrameRender extends IGroupRender {
36
+ export interface IFrameRender extends IGroupRender {
32
37
 
33
38
  }
34
39
 
@@ -1,7 +1,7 @@
1
- import { IPointData } from '@leafer/interface'
1
+ import { IBlendMode, IMatrixData } from '@leafer/interface'
2
2
 
3
3
  import { IStringColor } from './IStringType'
4
- import { IBlendMode, IStrokeAlign, IStrokeJoin, IStrokeCap } from './IType'
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
- scale?: IPointData
12
+ transform?: IMatrixData
13
13
  blendMode?: IBlendMode
14
14
  opacity?: number
15
15
  }
package/src/type/IType.ts CHANGED
@@ -1,25 +1,6 @@
1
- import { IMatrixData, IPointData, IPathCommandData, IWindingRule } from '@leafer/interface'
1
+ import { IMatrixData, IPointData, IPathCommandData, IWindingRule, IBlendMode } from '@leafer/interface'
2
2
  import { IStringColor } from './IStringType'
3
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'
22
-
23
4
 
24
5
  export type IPaint = ISolidPaint | IGradientPaint | IImagePaint
25
6
 
@@ -37,10 +18,9 @@ export type IPaintType =
37
18
  | IGradientType
38
19
 
39
20
  export type IGradientType =
40
- | 'gradient-linear'
41
- | 'gradient-radial'
42
- | 'gradient-angular'
43
- | 'gradient-diamond'
21
+ | 'linear'
22
+ | 'radial'
23
+ | 'angular'
44
24
 
45
25
  // ---
46
26
  export interface ISolidPaint extends IPaintBase {
@@ -48,11 +28,12 @@ export interface ISolidPaint extends IPaintBase {
48
28
  color: IColor
49
29
  }
50
30
 
51
- export type IColor = IStringColor // | RGB | RGBA
31
+ export type IColor = IStringColor | IRGB | IRGBA
52
32
  export interface IRGB {
53
33
  r: number
54
34
  g: number
55
35
  b: number
36
+ a?: number
56
37
  }
57
38
  export interface IRGBA extends IRGB {
58
39
  a: number
@@ -61,8 +42,8 @@ export interface IRGBA extends IRGB {
61
42
  // ---
62
43
  export interface IGradientPaint extends IPaintBase {
63
44
  type: IGradientType
64
- from: IPointData
65
- to: IPointData
45
+ from?: IPointData
46
+ to?: IPointData
66
47
  stretch?: number
67
48
  stops: IColorStop[]
68
49
  }
@@ -75,11 +56,13 @@ export interface IColorStop {
75
56
  export interface IImagePaint extends IPaintBase {
76
57
  type: "image"
77
58
  url: string
78
- mode: IImagePaintMode
79
- transform?: IMatrixData
80
- scale?: number
81
- rotation?: number
59
+ mode?: IImagePaintMode
60
+
82
61
  filters?: IImageFilters
62
+
63
+ offset?: IPointData
64
+ scale?: number | IPointData
65
+ rotation?: number
83
66
  }
84
67
  export interface IImageFilters {
85
68
  exposure?: number // 曝光
@@ -90,7 +73,7 @@ export interface IImageFilters {
90
73
  highlights?: number // 高光
91
74
  shadows?: number // 阴影
92
75
  }
93
- export type IImagePaintMode = 'fill' | 'fit' | 'tile' | 'crop'
76
+ export type IImagePaintMode = 'cover' | 'fit' | 'strench' | 'clip' | 'repeat'
94
77
 
95
78
  // 描边
96
79
  export type IStrokeAlign = 'inside' | 'outside' | 'center'
@@ -98,7 +81,9 @@ export type IStrokeCap = 'none' | 'round' | 'square' | 'arrow-lines' | 'arrow-eq
98
81
  export type IStrokeJoin = 'bevel' | 'round' | 'miter'
99
82
 
100
83
  // 文本
101
- export type ITextCase = 'upper' | 'lower' | 'title' | 'original' | 'small-caps' | 'small-caps-forced'
84
+ export type ITextAlign = 'left' | 'center' | 'right' | 'justify'
85
+ export type IVerticalAlign = 'top' | 'middle' | 'bottom'
86
+ export type ITextCase = | 'upper' | 'lower' | 'title' | 'original' | 'small-caps' | 'small-caps-forced'
102
87
  export type IFontWeight = IFontWeightNumerical | IFontWeightString
103
88
  export type IFontWeightNumerical = 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
104
89
  export type IFontWeightString =