@leafer-ui/interface 1.0.0-alpha.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023-present, Chao (Leafer) Wan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # @leafer-ui/interface
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@leafer-ui/interface",
3
+ "version": "1.0.0-alpha.1",
4
+ "description": "@leafer-ui/interface",
5
+ "author": "Chao (Leafer) Wan",
6
+ "license": "MIT",
7
+ "main": "src/index.ts",
8
+ "files": ["src"],
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/leaferjs/ui.git"
12
+ },
13
+ "homepage": "https://github.com/leaferjs/ui/tree/main/packages/interface",
14
+ "bugs": "https://github.com/leaferjs/ui/issues",
15
+ "keywords": [
16
+ "leaferui",
17
+ "leafer-ui",
18
+ "leaferjs"
19
+ ],
20
+ "dependencies": {
21
+ "@leafer/interface": "1.0.0-alpha.1"
22
+ }
23
+ }
@@ -0,0 +1,8 @@
1
+ import { ILeaferCanvas, IBoundsData, ICachedLeaf } from '@leafer/interface'
2
+
3
+ export interface ICachedShape extends ICachedLeaf {
4
+ worldCanvas?: ILeaferCanvas
5
+ shapeBounds: IBoundsData
6
+ scaleX: number
7
+ scaleY: number
8
+ }
@@ -0,0 +1,140 @@
1
+ import { IPaint, IStrokeAlign, IStrokeCap, IStrokeJoin, IBlurEffect, IFontWeight, ITextCase, ITextDecoration, IShadowEffect, IGrayscaleEffect } from './type/IType'
2
+ import { ILeafStrokePaint, ILeafShadowEffect, ILeafPaint } from './type/IComputedType'
3
+ import { IPaintString, IDashPatternString, IPercent, IShadowString, IStringColor, IBorderWidthString, IBorderRadiusString } from './type/IStringType'
4
+
5
+ // corner---
6
+ export interface ICornerRadiusAttrData {
7
+ cornerRadius: number
8
+ cornerSmoothing: number
9
+ }
10
+ export interface ICornerRadiusInputData {
11
+ cornerRadius?: number
12
+ cornerSmoothing?: number
13
+ }
14
+ export interface ICornerRadiusComputedData {
15
+ cornerRadius?: number
16
+ cornerSmoothing?: number
17
+ }
18
+
19
+ // fill---
20
+ export interface IFillAttrData {
21
+ fill: IPaint | IPaint[] | IPaintString
22
+ }
23
+ export interface IFillInputData {
24
+ fill?: IPaint | IPaint[] | IPaintString
25
+ }
26
+ export interface IFillComputedData {
27
+ fill?: IStringColor | ILeafPaint[]
28
+ }
29
+
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
+ export interface IBorderComputedData {
40
+ borderWidth?: number | number[]
41
+ borderRadius?: number | number[]
42
+ }
43
+
44
+ // stroke---
45
+ export interface IStrokeAttrData {
46
+ stroke: IPaint | IPaint[] | IPaintString
47
+
48
+ strokeAlign: IStrokeAlign
49
+ strokeWidth: number
50
+ strokeCap: IStrokeCap
51
+ strokeJoin: IStrokeJoin
52
+ dashPattern: number[] | IDashPatternString
53
+ dashOffset: number
54
+ miterLimit: number
55
+ }
56
+ export interface IStrokeInputData {
57
+ stroke?: IPaint | IPaint[] | IPaintString
58
+
59
+ strokeAlign?: IStrokeAlign
60
+ strokeWidth?: number
61
+ strokeCap?: IStrokeCap
62
+ strokeJoin?: IStrokeJoin
63
+ dashPattern?: number[] | IDashPatternString
64
+ dashOffset?: number
65
+ miterLimit?: number
66
+ }
67
+ export interface IStrokeComputedData {
68
+ stroke?: IStringColor | ILeafStrokePaint[]
69
+
70
+ strokeAlign?: IStrokeAlign
71
+ strokeWidth?: number
72
+ strokeWidths?: number[]
73
+ strokeCap?: IStrokeCap
74
+ strokeJoin?: IStrokeJoin
75
+ dashPattern?: number[]
76
+ dashOffset?: number
77
+ miterLimit?: number
78
+ }
79
+
80
+ // text---
81
+ export interface ITextStyleAttrData {
82
+ fontFamily: string
83
+ fontSize: number
84
+ fontWeight: IFontWeight
85
+ italic: boolean
86
+ textCase: ITextCase
87
+ textDecoration: ITextDecoration
88
+ letterSpacing: number | IPercent
89
+ lineHeight: number | IPercent
90
+ paragraphIndent: number
91
+ paragraphSpacing: number
92
+ }
93
+ export interface ITextStyleInputData {
94
+ fontFamily?: string
95
+ fontSize?: number
96
+ fontWeight?: IFontWeight
97
+ italic?: boolean
98
+ textCase?: ITextCase
99
+ textDecoration?: ITextDecoration
100
+ letterSpacing?: number | IPercent
101
+ lineHeight?: number | IPercent
102
+ paragraphIndent?: number
103
+ paragraphSpacing?: number
104
+ }
105
+ export interface ITextStyleComputedData {
106
+ fontFamily?: string
107
+ fontSize?: number
108
+ fontWeight?: IFontWeight
109
+ italic?: boolean
110
+ textCase?: ITextCase
111
+ textDecoration?: ITextDecoration
112
+ letterSpacing?: number
113
+ lineHeight?: number
114
+
115
+ paragraphIndent?: number
116
+ paragraphSpacing?: number
117
+ }
118
+
119
+ // effect---
120
+ export interface IEffectAttrData {
121
+ shadow: IShadowEffect | IShadowEffect[] | IShadowString
122
+ innerShadow: IShadowEffect | IShadowEffect[] | IShadowString
123
+ blur: number | IBlurEffect
124
+ backgroundBlur: number | IBlurEffect
125
+ grayscale: number | IGrayscaleEffect
126
+ }
127
+ export interface IEffectInputData {
128
+ shadow?: IShadowEffect | IShadowEffect[] | IShadowString
129
+ innerShadow?: IShadowEffect | IShadowEffect[] | IShadowString
130
+ blur?: number | IBlurEffect
131
+ backgroundBlur?: number | IBlurEffect
132
+ grayscale?: number | IGrayscaleEffect
133
+ }
134
+ export interface IEffectComputedData {
135
+ shadow?: ILeafShadowEffect[]
136
+ innerShadow?: ILeafShadowEffect[]
137
+ blur?: number
138
+ backgroundBlur?: number
139
+ grayscale?: number
140
+ }
package/src/IUI.ts ADDED
@@ -0,0 +1,208 @@
1
+ import { ILeaf, ILeafComputedData, ILeafData, ILeafInputData, ILeaferCanvas, IRenderOptions, ICanvasDrawPath, IPointData, Path2D, IPathCommandData, IBranch, ILeaferImageConfig, IMatrixData, IBoundsData } from '@leafer/interface'
2
+
3
+ import { IPathString, IVectorPathString } from './type/IStringType'
4
+ import { IBlendMode, IWindingRule } from './type/IType'
5
+ import { IVectorPath } from './type/IType'
6
+
7
+ import {
8
+ IFillAttrData, IFillInputData, IFillComputedData,
9
+ IBorderComputedData, IBorderInputData,
10
+ ICornerRadiusAttrData, ICornerRadiusInputData, ICornerRadiusComputedData,
11
+ IStrokeAttrData, IStrokeComputedData, IStrokeInputData,
12
+ IEffectAttrData, IEffectInputData, IEffectComputedData,
13
+ ITextStyleAttrData, ITextStyleInputData, ITextStyleComputedData, IBorderAttrData
14
+ } from './ICommonAttr'
15
+
16
+
17
+ // Line
18
+ export interface ILine extends IUI {
19
+ __: ILineData
20
+ toPoint: IPointData
21
+ }
22
+ export interface ILineData extends IUIData { }
23
+ export interface ILineInputData extends IUIInputData { }
24
+
25
+
26
+ // Rect
27
+ export interface IRect extends IUI {
28
+ __: IRectData
29
+ }
30
+ export interface IRectData extends IUIData { }
31
+ export interface IRectInputData extends IUIInputData { }
32
+
33
+
34
+ // Ellipse
35
+ export interface IEllipse extends IUI {
36
+ __: IEllipseData
37
+ startAngle: number
38
+ endAngle: number
39
+ innerRadius: number
40
+ }
41
+ interface IEllipseAttrData {
42
+ startAngle?: number
43
+ endAngle?: number
44
+ innerRadius?: number
45
+ }
46
+ export interface IEllipseData extends IEllipseAttrData, IUIData { }
47
+ export interface IEllipseInputData extends IEllipseAttrData, IUIInputData { }
48
+
49
+
50
+ // Polygon
51
+ export interface IPolygon extends IUI {
52
+ __: IPolygonData
53
+ sides: number
54
+ }
55
+ interface IPolygonAttrData {
56
+ sides?: number
57
+ }
58
+ export interface IPolygonData extends IPolygonAttrData, IUIData { }
59
+ export interface IPolygonInputData extends IPolygonAttrData, IUIInputData { }
60
+
61
+
62
+ // Star
63
+ export interface IStar extends IUI {
64
+ __: IStarData
65
+ points: number
66
+ innerRadius: number
67
+ }
68
+ interface IStarAttrData {
69
+ points?: number
70
+ innerRadius?: number
71
+ }
72
+
73
+ export interface IStarData extends IStarAttrData, IUIData { }
74
+ export interface IStarInputData extends IStarAttrData, IUIInputData { }
75
+
76
+ // Path
77
+ export interface IPath extends IUI {
78
+ __: IPathData
79
+ path: IPathCommandData | IPathString
80
+ windingRule: IWindingRule
81
+ }
82
+ export interface IPathData extends IUIData {
83
+ path?: IPathCommandData
84
+ windingRule?: IWindingRule
85
+ }
86
+ export interface IPathInputData extends IUIInputData {
87
+ path?: IPathCommandData | IPathString
88
+ windingRule?: IWindingRule
89
+ }
90
+
91
+
92
+ // Vector
93
+ export interface IVector extends IUI {
94
+ __: IVectorData
95
+ paths: IVectorPath[] | IVectorPathString
96
+ }
97
+ export interface IVectorData extends IUIData {
98
+ paths?: IVectorPath[]
99
+ }
100
+ export interface IVectorInputData extends IUIInputData {
101
+ paths?: IVectorPath[] | IVectorPathString
102
+ }
103
+
104
+
105
+ // Text
106
+ export interface IText extends ITextStyleAttrData, IUI {
107
+ __: ITextData
108
+ content: string
109
+ }
110
+ interface ITextAttrData {
111
+ content?: string
112
+ }
113
+ export interface ITextData extends ITextAttrData, ITextStyleComputedData, IUIData {
114
+ __font?: string
115
+ }
116
+ export interface ITextInputData extends ITextAttrData, ITextStyleInputData, IUIInputData {
117
+
118
+ }
119
+
120
+
121
+ // Image
122
+ export interface IImage extends IRect, ILeaferImageConfig {
123
+ __: IImageData
124
+ url: string
125
+ thumb: string
126
+ }
127
+ interface IImageAttrData {
128
+ url?: string
129
+ thumb?: string
130
+ }
131
+ export interface IImageData extends IImageAttrData, IRectData { }
132
+ export interface IImageInputData extends IImageAttrData, IUIInputData { }
133
+
134
+ // Frame
135
+ export interface IFrame extends IGroup {
136
+ __: IFrameData
137
+ clip: boolean
138
+ __updateRectBoxBounds(): void
139
+ __updateRectEventBounds(): void
140
+ __updateRectRenderBounds(): void
141
+ __renderRect(canvas: ILeaferCanvas, options: IRenderOptions): void
142
+ __renderGroup(canvas: ILeaferCanvas, options: IRenderOptions): void
143
+ }
144
+ export interface IFrameData extends IGroupData {
145
+ clip?: boolean
146
+ }
147
+ export interface IFrameInputData extends IGroupInputData {
148
+ clip?: boolean
149
+ }
150
+
151
+
152
+ // Group
153
+ export interface IGroup extends IBranch, IUI {
154
+ __: IGroupData
155
+ root?: IGroup
156
+ parent?: IGroup
157
+ children: IUI[]
158
+ add(child: IUI, index?: number): void
159
+ remove(child?: IUI): void
160
+ addAt(child: IUI, index: number): void
161
+ addAfter(child: IUI, after: IUI): void
162
+ addBefore(child: IUI, before: IUI): void
163
+ }
164
+ export interface IGroupData extends IUIData { }
165
+ export interface IGroupInputData extends IUIInputData { }
166
+
167
+ // UI
168
+ export interface IUI extends IFillAttrData, IBorderAttrData, IStrokeAttrData, ICornerRadiusAttrData, IEffectAttrData, ILeaf {
169
+ __: IUIData
170
+ root?: IGroup
171
+ parent?: IGroup
172
+ readonly worldTransform: IMatrixData
173
+ readonly relativeTransform: IMatrixData
174
+ readonly worldBoxBounds: IBoundsData
175
+ readonly worldRenderBounds: IBoundsData
176
+ __drawPathByData(drawer: ICanvasDrawPath, data: IPathCommandData): void
177
+ }
178
+
179
+ export interface IUIData extends IUIComputedData, ILeafData {
180
+ // 非数据属性, 自动计算的缓存数据
181
+ __isFills?: boolean
182
+ __isStrokes?: boolean
183
+
184
+ __isTranslucentFill?: boolean // 半透明的
185
+ __isTranslucentStroke?: boolean
186
+
187
+ __useEffect?: boolean
188
+
189
+ // path
190
+ path?: IPathCommandData
191
+ windingRule?: IWindingRule
192
+
193
+ __renderPath?: IPathCommandData
194
+ __renderPath2D?: Path2D
195
+
196
+ __strokeOuterWidth?: number // boxBounds外面的笔触宽度
197
+ }
198
+ export interface IUIComputedData extends IFillComputedData, IBorderComputedData, IStrokeComputedData, ICornerRadiusComputedData, IEffectComputedData, ILeafComputedData {
199
+ blendMode?: IBlendMode
200
+ mask?: boolean
201
+ locked?: boolean
202
+ }
203
+
204
+ export interface IUIInputData extends IFillInputData, IBorderInputData, IStrokeInputData, ICornerRadiusInputData, IEffectInputData, ILeafInputData {
205
+ blendMode?: IBlendMode
206
+ mask?: boolean
207
+ locked?: boolean
208
+ }
package/src/index.ts ADDED
@@ -0,0 +1,28 @@
1
+ export * from '@leafer/interface'
2
+
3
+ export {
4
+ ILine, ILineInputData, ILineData,
5
+ IRect, IRectInputData, IRectData,
6
+ IEllipse, IEllipseInputData, IEllipseData,
7
+ IPolygon, IPolygonInputData, IPolygonData,
8
+ IStar, IStarInputData, IStarData,
9
+ IPath, IPathInputData, IPathData,
10
+ IVector, IVectorInputData, IVectorData,
11
+ IText, ITextInputData, ITextData,
12
+ IImage, IImageInputData, IImageData,
13
+ IFrame, IFrameInputData, IFrameData,
14
+ IGroup, IGroupInputData, IGroupData,
15
+ IUI, IUIInputData, IUIData
16
+ } from './IUI'
17
+ export { IBlendMode, IVectorPath, IWindingRule, IShadowEffect, IBlurEffect, IGrayscaleEffect, IStrokeAlign, IStrokeJoin, IStrokeCap, IColor, IPaint, IGradientPaint, IImagePaint, IImagePaintMode, IFontWeight, ITextCase, ITextDecoration } from './type/IType'
18
+ export { IBorderRadiusString, IBorderWidthString, IPaintString, IShadowString, IPercent, IDashPatternString, IPathString, IVectorPathString, IStringColor } from './type/IStringType'
19
+ export { ILeafFill, ILeafPaint, ILeafPaintColor, ILeafStrokePaint, ILeafShadowEffect } from './type/IComputedType'
20
+
21
+ export { IUIRenderModule, IRectRenderModule, IGroupRenderModule, IFrameRenderModule } from './module/IUIRender'
22
+ export { IUIBoundsModule } from './module/IUIBounds'
23
+ export { IUIHitModule } from './module/IUIHit'
24
+
25
+ export { IPaintModule } from './module/IPaint'
26
+ export { IEffectModule } from './module/IEffect'
27
+ export { ICachedShape } from './ICachedShape'
28
+
@@ -0,0 +1,12 @@
1
+ import { ILeaferCanvas } from '@leafer/interface'
2
+
3
+ import { IUI } from '../IUI'
4
+ import { ICachedShape } from '../ICachedShape'
5
+
6
+
7
+ export interface IEffectModule {
8
+ shadow?(ui: IUI, current: ILeaferCanvas, shape: ICachedShape): void
9
+ innerShadow?(ui: IUI, current: ILeaferCanvas, shape: ICachedShape): void
10
+ blur?(ui: IUI, current: ILeaferCanvas, origin: ILeaferCanvas): void
11
+ backgroundBlur?(ui: IUI, current: ILeaferCanvas, shape: ICachedShape): void
12
+ }
@@ -0,0 +1,12 @@
1
+ import { ILeaferCanvas } from '@leafer/interface'
2
+
3
+ import { ILeafPaint } from '../type/IComputedType'
4
+ import { IUI } from '../IUI'
5
+
6
+ export interface IPaintModule {
7
+ fill?(ui: IUI, canvas: ILeaferCanvas, fill: string | object): void
8
+ fills?(ui: IUI, canvas: ILeaferCanvas, fills: ILeafPaint[]): void
9
+
10
+ stroke?(ui: IUI, canvas: ILeaferCanvas, stroke: string | object): void
11
+ strokes?(ui: IUI, canvas: ILeaferCanvas, strokes: ILeafPaint[]): void
12
+ }
@@ -0,0 +1,8 @@
1
+ import { ILeafBounds } from '@leafer/interface'
2
+
3
+ import { IUI } from '../IUI'
4
+
5
+ export type IUIBoundsModule = IUIBounds & ThisType<IUI>
6
+
7
+ interface IUIBounds extends ILeafBounds {
8
+ }
@@ -0,0 +1,5 @@
1
+ import { ILeafHit } from '@leafer/interface'
2
+
3
+ import { IUI } from '../IUI'
4
+
5
+ export type IUIHitModule = ILeafHit & ThisType<IUI>
@@ -0,0 +1,28 @@
1
+ import { ILeafRender, ILeaferCanvas, IRenderOptions, } from '@leafer/interface'
2
+
3
+ import { IUI, IRect, IFrame, IGroup } from '../IUI'
4
+
5
+ export type IUIRenderModule = IUIRender & ThisType<IUI>
6
+
7
+ interface IUIRender extends ILeafRender {
8
+ __renderShape?(canvas: ILeaferCanvas, options: IRenderOptions): void
9
+ }
10
+
11
+ export type IRectRenderModule = IRectRender & ThisType<IRect>
12
+
13
+ interface IRectRender extends IUIRender {
14
+
15
+ }
16
+
17
+ export type IGroupRenderModule = IGroupRender & ThisType<IGroup>
18
+
19
+ interface IGroupRender extends IUIRender {
20
+
21
+ }
22
+
23
+ export type IFrameRenderModule = IFrameRender & ThisType<IFrame>
24
+
25
+ interface IFrameRender extends IGroupRender {
26
+
27
+ }
28
+
@@ -0,0 +1,36 @@
1
+ import { IPointData } from '@leafer/interface'
2
+
3
+ import { IStringColor } from './IStringType'
4
+ import { IBlendMode, IStrokeAlign, IStrokeJoin, IStrokeCap } from './IType'
5
+ import { IPaintType } from './IType'
6
+
7
+ export type ILeafPaintColor = IStringColor | CanvasGradient | CanvasPattern
8
+
9
+ export interface ILeafPaint {
10
+ type: IPaintType
11
+ style: ILeafPaintColor
12
+ scale?: IPointData
13
+ blendMode?: IBlendMode
14
+ opacity?: number
15
+ }
16
+
17
+ export type ILeafFill = ILeafPaint
18
+
19
+ export interface ILeafStrokePaint extends ILeafPaint {
20
+ strokeAlign?: IStrokeAlign
21
+ strokeWidth?: number
22
+ strokeCap?: IStrokeCap
23
+ strokeJoin?: IStrokeJoin
24
+ dashPattern?: number[]
25
+ miterLimit?: number
26
+ }
27
+
28
+ export interface ILeafShadowEffect {
29
+ x: number
30
+ y: number
31
+ blur: number
32
+ spread?: number
33
+ color: IStringColor
34
+ blendMode?: IBlendMode
35
+ showBehind?: boolean // 仅用于 DropShadow
36
+ }
@@ -0,0 +1,16 @@
1
+ export type IPercent = string
2
+
3
+ export type IStringColor = string
4
+
5
+ export type IBorderRadiusString = string
6
+ export type IBorderWidthString = string
7
+ export type IDashPatternString = string
8
+ export type IVectorPathString = string
9
+ export type IPathString = string
10
+
11
+ export type IPaintString = ISolidPaintString | IGradientPaintString | IImagePaintString
12
+ export type ISolidPaintString = string
13
+ export type IGradientPaintString = string
14
+ export type IImagePaintString = string
15
+
16
+ export type IShadowString = string
@@ -0,0 +1,144 @@
1
+ import { IMatrixData, IPointData, IPathCommandData } from '@leafer/interface'
2
+ import { IStringColor } from './IStringType'
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
+
24
+ export type IPaint = ISolidPaint | IGradientPaint | IImagePaint
25
+
26
+ export interface IPaintBase {
27
+ type: IPaintType
28
+ blendMode?: IBlendMode
29
+ visible?: boolean
30
+ opacity?: number
31
+
32
+ }
33
+
34
+ export type IPaintType =
35
+ | 'image'
36
+ | 'solid'
37
+ | IGradientType
38
+
39
+ export type IGradientType =
40
+ | 'gradient-linear'
41
+ | 'gradient-radial'
42
+ | 'gradient-angular'
43
+ | 'gradient-diamond'
44
+
45
+ // ---
46
+ export interface ISolidPaint extends IPaintBase {
47
+ type: 'solid'
48
+ color: IColor
49
+ }
50
+
51
+ export type IColor = IStringColor // | RGB | RGBA
52
+ export interface IRGB {
53
+ r: number
54
+ g: number
55
+ b: number
56
+ }
57
+ export interface IRGBA extends IRGB {
58
+ a: number
59
+ }
60
+
61
+ // ---
62
+ export interface IGradientPaint extends IPaintBase {
63
+ type: IGradientType
64
+ from: IPointData
65
+ to: IPointData
66
+ stretch?: number
67
+ stops: IColorStop[]
68
+ }
69
+ export interface IColorStop {
70
+ offset: number
71
+ color: IColor
72
+ }
73
+
74
+ // ---
75
+ export interface IImagePaint extends IPaintBase {
76
+ type: "image"
77
+ url: string
78
+ mode: IImagePaintMode
79
+ transform?: IMatrixData
80
+ scale?: number
81
+ rotation?: number
82
+ filters?: IImageFilters
83
+ }
84
+ export interface IImageFilters {
85
+ exposure?: number // 曝光
86
+ contrast?: number // 对比度
87
+ saturation?: number // 饱和度
88
+ temperature?: number // 色温
89
+ tint?: number // 色调
90
+ highlights?: number // 高光
91
+ shadows?: number // 阴影
92
+ }
93
+ export type IImagePaintMode = 'fill' | 'fit' | 'tile' | 'crop'
94
+
95
+ // 描边
96
+ export type IStrokeAlign = 'inside' | 'outside' | 'center'
97
+ export type IStrokeCap = 'none' | 'round' | 'square' | 'arrow-lines' | 'arrow-equilateral'
98
+ export type IStrokeJoin = 'bevel' | 'round' | 'miter'
99
+
100
+ // 文本
101
+ export type ITextCase = 'upper' | 'lower' | 'title' | 'original' | 'small-caps' | 'small-caps-forced'
102
+ export type IFontWeight = IFontWeightNumerical | IFontWeightString
103
+ export type IFontWeightNumerical = 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
104
+ export type IFontWeightString =
105
+ | 'thin'
106
+ | 'extra-light'
107
+ | 'light'
108
+ | 'normal'
109
+ | 'medium'
110
+ | 'semi-bold'
111
+ | 'bold'
112
+ | 'extra-bold'
113
+ | 'black'
114
+ export type ITextDecoration = 'none' | 'strikethrough' | 'underline'
115
+
116
+ // 路径
117
+ export interface IVectorPath {
118
+ rule?: IWindingRule,
119
+ data: string | IPathCommandData
120
+ }
121
+ export type IWindingRule = 'nonzero' | 'evenodd'
122
+
123
+
124
+ // 特效
125
+ export interface IShadowEffect {
126
+ x: number
127
+ y: number
128
+ blur: number
129
+ spread?: number
130
+ color: IStringColor | IColor
131
+ blendMode?: IBlendMode
132
+ visible?: boolean
133
+ showBehind?: boolean // 仅用于 DropShadow
134
+ }
135
+
136
+ export interface IBlurEffect {
137
+ blur: number
138
+ visible?: boolean
139
+ }
140
+
141
+ export interface IGrayscaleEffect {
142
+ grayscale: number
143
+ visible?: boolean
144
+ }