@leafer/interface 1.0.0-alpha.9 → 1.0.0-bate
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 +1 -1
- package/src/app/IApp.ts +6 -0
- package/src/app/ILeafer.ts +40 -23
- package/src/canvas/ICanvas.ts +2 -16
- package/src/canvas/ILeaferCanvas.ts +46 -20
- package/src/control/IControl.ts +5 -0
- package/src/data/IData.ts +1 -2
- package/src/data/ILeafData.ts +5 -0
- package/src/display/IBranch.ts +3 -3
- package/src/display/ILeaf.ts +125 -34
- package/src/display/IView.ts +1 -0
- package/src/display/module/ILeafBounds.ts +6 -6
- package/src/display/module/ILeafDataProxy.ts +2 -3
- package/src/display/module/ILeafEventer.ts +2 -2
- package/src/display/module/ILeafHit.ts +2 -0
- package/src/display/module/ILeafMask.ts +11 -0
- package/src/display/module/ILeafMatrix.ts +1 -1
- package/src/display/module/ILeafRender.ts +2 -3
- package/src/event/IEvent.ts +6 -1
- package/src/event/IEventer.ts +2 -2
- package/src/event/IUIEvent.ts +10 -0
- package/src/image/IImageManager.ts +4 -0
- package/src/image/ILeaferImage.ts +18 -1
- package/src/index.ts +13 -11
- package/src/interaction/IInteraction.ts +42 -10
- package/src/layout/ILeafLayout.ts +32 -28
- package/src/layouter/ILayouter.ts +16 -8
- package/src/math/IMath.ts +60 -21
- package/src/path/IPathCommand.ts +3 -3
- package/src/path/IPathDrawer.ts +22 -2
- package/src/platform/IPlatform.ts +8 -0
- package/src/renderer/IRenderer.ts +27 -11
- package/src/selector/ISelector.ts +9 -2
- package/src/watcher/IWatcher.ts +8 -5
- package/src/app/ISupperLeafer.ts +0 -5
package/package.json
CHANGED
package/src/app/IApp.ts
ADDED
package/src/app/ILeafer.ts
CHANGED
|
@@ -2,36 +2,40 @@ import { ILeaf } from '../display/ILeaf'
|
|
|
2
2
|
import { IRenderer, IRendererConfig } from '../renderer/IRenderer'
|
|
3
3
|
import { IHitCanvas, ILeaferCanvas, ILeaferCanvasConfig, IHitCanvasConfig } from '../canvas/ILeaferCanvas'
|
|
4
4
|
import { ILayouter, ILayouterConfig } from '../layouter/ILayouter'
|
|
5
|
-
import { ISelector } from '../selector/ISelector'
|
|
6
|
-
import { IInteraction, IInteractionConfig } from '../interaction/IInteraction'
|
|
7
|
-
import { IWatcher } from '../watcher/IWatcher'
|
|
5
|
+
import { ISelector, ISelectorConfig } from '../selector/ISelector'
|
|
6
|
+
import { IInteraction, IInteractionCanvas, IInteractionConfig } from '../interaction/IInteraction'
|
|
7
|
+
import { IWatcher, IWatcherConfig } from '../watcher/IWatcher'
|
|
8
8
|
import { IAutoBounds, IScreenSizeData } from '../math/IMath'
|
|
9
9
|
import { ICanvasManager } from '../canvas/ICanvasManager'
|
|
10
10
|
import { IHitCanvasManager } from '../canvas/IHitCanvasManager'
|
|
11
11
|
import { IImageManager } from '../image/IImageManager'
|
|
12
|
+
import { IEventListenerId } from '../event/IEventer'
|
|
12
13
|
import { IObject } from '../data/IData'
|
|
13
14
|
import { IZoomView } from '../display/IView'
|
|
14
|
-
import {
|
|
15
|
+
import { IApp } from './IApp'
|
|
15
16
|
import { ILeaferImage, ILeaferImageConfig } from '../image/ILeaferImage'
|
|
16
|
-
import {
|
|
17
|
+
import { IControl } from '../control/IControl'
|
|
17
18
|
|
|
18
19
|
|
|
20
|
+
export type ILeaferType = 'draw' | 'design' | 'board' | 'document' | 'user'
|
|
19
21
|
export interface ILeaferConfig extends IRendererConfig, ILeaferCanvasConfig, IInteractionConfig, ILayouterConfig {
|
|
20
22
|
start?: boolean
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
type?: ILeaferType
|
|
24
|
+
realCanvas?: boolean
|
|
23
25
|
}
|
|
24
26
|
|
|
25
|
-
export interface ILeafer extends IZoomView {
|
|
27
|
+
export interface ILeafer extends IZoomView, IControl {
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
readonly isSupperLeafer: boolean
|
|
30
|
-
parent?: ISupperLeafer
|
|
29
|
+
readonly isApp: boolean
|
|
30
|
+
parent?: IApp
|
|
31
31
|
|
|
32
32
|
running: boolean
|
|
33
|
+
ready: boolean
|
|
34
|
+
viewReady: boolean
|
|
33
35
|
|
|
34
|
-
|
|
36
|
+
pixelRatio: number
|
|
37
|
+
|
|
38
|
+
view: unknown
|
|
35
39
|
|
|
36
40
|
canvas: ILeaferCanvas
|
|
37
41
|
renderer: IRenderer
|
|
@@ -46,26 +50,39 @@ export interface ILeafer extends IZoomView {
|
|
|
46
50
|
hitCanvasManager?: IHitCanvasManager
|
|
47
51
|
imageManager: IImageManager
|
|
48
52
|
|
|
49
|
-
|
|
50
|
-
|
|
53
|
+
autoLayout?: IAutoBounds
|
|
54
|
+
|
|
55
|
+
config: ILeaferConfig
|
|
56
|
+
|
|
57
|
+
__eventIds: IEventListenerId[]
|
|
58
|
+
|
|
59
|
+
init(userConfig?: ILeaferConfig, parentApp?: IApp): void
|
|
60
|
+
|
|
61
|
+
forceFullRender(): void
|
|
51
62
|
|
|
52
63
|
resize(size: IScreenSizeData): void
|
|
53
64
|
}
|
|
54
65
|
|
|
55
|
-
export interface
|
|
56
|
-
|
|
57
|
-
|
|
66
|
+
export interface ILeaferTypeFunction {
|
|
67
|
+
(leafer: ILeafer): void
|
|
68
|
+
}
|
|
58
69
|
|
|
70
|
+
export interface ILeaferTypeList {
|
|
71
|
+
[key: string]: ILeaferTypeFunction
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
export interface ICreator {
|
|
59
76
|
image?(options?: ILeaferImageConfig): ILeaferImage
|
|
60
77
|
canvas?(options?: ILeaferCanvasConfig, manager?: ICanvasManager): ILeaferCanvas
|
|
61
78
|
hitCanvas?(options?: IHitCanvasConfig, manager?: ICanvasManager): IHitCanvas
|
|
62
79
|
|
|
63
|
-
watcher?(target: ILeaf): IWatcher
|
|
64
|
-
layouter?(target: ILeaf): ILayouter
|
|
65
|
-
renderer?(target: ILeaf, canvas: ILeaferCanvas, options
|
|
66
|
-
selector?(target: ILeaf): ISelector
|
|
80
|
+
watcher?(target: ILeaf, options?: IWatcherConfig): IWatcher
|
|
81
|
+
layouter?(target: ILeaf, options?: ILayouterConfig): ILayouter
|
|
82
|
+
renderer?(target: ILeaf, canvas: ILeaferCanvas, options?: IRendererConfig): IRenderer
|
|
83
|
+
selector?(target: ILeaf, options?: ISelectorConfig): ISelector
|
|
67
84
|
|
|
68
|
-
interaction?(target: ILeaf, canvas:
|
|
85
|
+
interaction?(target: ILeaf, canvas: IInteractionCanvas, selector: ISelector, options?: IInteractionConfig): IInteraction
|
|
69
86
|
}
|
|
70
87
|
|
|
71
88
|
export interface IUICreator {
|
package/src/canvas/ICanvas.ts
CHANGED
|
@@ -10,9 +10,7 @@ type CanvasTextAlign = 'center' | 'end' | 'left' | 'right' | 'start'
|
|
|
10
10
|
type CanvasTextBaseline = 'alphabetic' | 'bottom' | 'hanging' | 'ideographic' | 'middle' | 'top'
|
|
11
11
|
//type CanvasTextRendering = 'auto' | 'geometricPrecision' | 'optimizeLegibility' | 'optimizeSpeed'
|
|
12
12
|
|
|
13
|
-
/** This Canvas 2D API interface is used to declare a path that can then be used on a CanvasRenderingContext2D object. The path methods of the CanvasRenderingContext2D interface are also present on this interface, which gives you the convenience of being able to retain and replay your path whenever desired. */
|
|
14
13
|
export interface IPath2D extends CanvasPath {
|
|
15
|
-
/** Adds to the path the path given by the argument. */
|
|
16
14
|
addPath(path: IPath2D, transform?: DOMMatrix2DInit): void
|
|
17
15
|
}
|
|
18
16
|
|
|
@@ -60,13 +58,7 @@ interface CanvasFilters {
|
|
|
60
58
|
filter: string
|
|
61
59
|
}
|
|
62
60
|
|
|
63
|
-
/** An opaque object describing a gradient. It is returned by the methods CanvasRenderingContext2D.createLinearGradient() or CanvasRenderingContext2D.createRadialGradient(). */
|
|
64
61
|
export interface CanvasGradient {
|
|
65
|
-
/**
|
|
66
|
-
* Adds a color stop with the given color to the gradient at the given offset. 0.0 is the offset at one end of the gradient, 1.0 is the offset at the other end.
|
|
67
|
-
*
|
|
68
|
-
* Throws an 'IndexSizeError' DOMException if the offset is out of range. Throws a 'SyntaxError' DOMException if the color cannot be parsed.
|
|
69
|
-
*/
|
|
70
62
|
addColorStop(offset: number, color: string): void
|
|
71
63
|
}
|
|
72
64
|
|
|
@@ -89,11 +81,11 @@ interface CanvasImageSmoothing {
|
|
|
89
81
|
}
|
|
90
82
|
|
|
91
83
|
interface CanvasPath {
|
|
92
|
-
arc(x: number, y: number, radius: number, startAngle: number, endAngle: number,
|
|
84
|
+
arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void
|
|
93
85
|
arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void
|
|
94
86
|
bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void
|
|
95
87
|
closePath(): void
|
|
96
|
-
ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number,
|
|
88
|
+
ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void
|
|
97
89
|
lineTo(x: number, y: number): void
|
|
98
90
|
moveTo(x: number, y: number): void
|
|
99
91
|
quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void
|
|
@@ -111,9 +103,7 @@ interface CanvasPathDrawingStyles {
|
|
|
111
103
|
setLineDash(segments: number[]): void
|
|
112
104
|
}
|
|
113
105
|
|
|
114
|
-
/** An opaque object describing a pattern, based on an image, a canvas, or a video, created by the CanvasRenderingContext2D.createPattern() method. */
|
|
115
106
|
export interface CanvasPattern {
|
|
116
|
-
/** Sets the transformation matrix that will be used when rendering the pattern during a fill or stroke painting operation. */
|
|
117
107
|
setTransform(transform?: DOMMatrix2DInit): void
|
|
118
108
|
}
|
|
119
109
|
|
|
@@ -135,8 +125,6 @@ interface CanvasRenderingContext2DSettings {
|
|
|
135
125
|
desynchronized?: boolean
|
|
136
126
|
willReadFrequently?: boolean
|
|
137
127
|
}
|
|
138
|
-
|
|
139
|
-
/** The CanvasRenderingContext2D interface, part of the Canvas API, provides the 2D rendering context for the drawing surface of a <canvas> element. It is used for drawing shapes, text, images, and other objects. */
|
|
140
128
|
export interface ICanvasContext2D extends CanvasCompositing, CanvasDrawImage, CanvasDrawPath, CanvasFillStrokeStyles, CanvasFilters, CanvasImageData, CanvasImageSmoothing, CanvasPath, CanvasPathDrawingStyles, CanvasRect, CanvasShadowStyles, CanvasState, CanvasText, CanvasTextDrawingStyles, CanvasTransform, CanvasUserInterface {
|
|
141
129
|
readonly canvas: HTMLCanvasElement
|
|
142
130
|
getContextAttributes(): CanvasRenderingContext2DSettings
|
|
@@ -165,7 +153,6 @@ interface CanvasUserInterface {
|
|
|
165
153
|
}
|
|
166
154
|
|
|
167
155
|
|
|
168
|
-
/** The dimensions of a piece of text in the canvas, as created by the CanvasRenderingContext2D.measureText() method. */
|
|
169
156
|
export interface ITextMetrics {
|
|
170
157
|
/** Returns the measurement described below. */
|
|
171
158
|
readonly actualBoundingBoxAscent: number
|
|
@@ -277,7 +264,6 @@ interface DOMMatrixReadOnly {
|
|
|
277
264
|
rotateFromVector(x?: number, y?: number): DOMMatrix
|
|
278
265
|
scale(scaleX?: number, scaleY?: number, scaleZ?: number, originX?: number, originY?: number, originZ?: number): DOMMatrix
|
|
279
266
|
scale3d(scale?: number, originX?: number, originY?: number, originZ?: number): DOMMatrix
|
|
280
|
-
/** @deprecated */
|
|
281
267
|
scaleNonUniform(scaleX?: number, scaleY?: number): DOMMatrix
|
|
282
268
|
skewX(sx?: number): DOMMatrix
|
|
283
269
|
skewY(sy?: number): DOMMatrix
|
|
@@ -10,6 +10,9 @@ export interface ILeaferCanvasConfig extends IAutoBoundsData {
|
|
|
10
10
|
view?: string | IObject
|
|
11
11
|
fill?: string
|
|
12
12
|
pixelRatio?: number
|
|
13
|
+
smooth?: boolean
|
|
14
|
+
hittable?: boolean
|
|
15
|
+
offscreen?: boolean
|
|
13
16
|
webgl?: boolean
|
|
14
17
|
}
|
|
15
18
|
|
|
@@ -26,7 +29,7 @@ export interface ICanvasStrokeOptions {
|
|
|
26
29
|
miterLimit?: number
|
|
27
30
|
}
|
|
28
31
|
|
|
29
|
-
export interface ICanvasAttr extends ICanvasStrokeOptions {
|
|
32
|
+
export interface ICanvasAttr extends ICanvasStrokeOptions, IObject {
|
|
30
33
|
|
|
31
34
|
smooth: boolean // imageSmoothingEnabled: boolean
|
|
32
35
|
smoothLevel: string // imageSmoothingQuality: string
|
|
@@ -71,6 +74,7 @@ interface ICanvasMethod {
|
|
|
71
74
|
strokeRect(x: number, y: number, width: number, height: number): void
|
|
72
75
|
clearRect(x: number, y: number, width: number, height: number): void
|
|
73
76
|
|
|
77
|
+
transform(a: number, b: number, c: number, d: number, e: number, f: number): void
|
|
74
78
|
translate(x: number, y: number): void
|
|
75
79
|
scale(x: number, y: number): void
|
|
76
80
|
rotate(angle: number): void
|
|
@@ -96,32 +100,38 @@ interface ICanvasMethod {
|
|
|
96
100
|
|
|
97
101
|
// custom
|
|
98
102
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
103
|
+
saveBlendMode(blendMode?: string): void
|
|
104
|
+
restoreBlendMode(): void
|
|
105
|
+
|
|
106
|
+
hitFill(point: IPointData, fillRule?: string): boolean
|
|
107
|
+
hitStroke(point: IPointData, strokeWidth?: number): boolean
|
|
102
108
|
|
|
109
|
+
setStroke(strokeStyle: string | object, strokeWidth: number, options?: ICanvasStrokeOptions): void
|
|
110
|
+
setStrokeOptions(options: ICanvasStrokeOptions): void
|
|
103
111
|
|
|
104
112
|
setWorld(matrix: IMatrixData, parentMatrix?: IMatrixData): void
|
|
105
113
|
|
|
114
|
+
setWorldShadow(x: number, y: number, blur: number, color?: string): void
|
|
115
|
+
setWorldBlur(blur: number): void
|
|
116
|
+
|
|
117
|
+
copyWorld(canvas: ILeaferCanvas, fromBounds?: IBoundsData, toBounds?: IBoundsData, blendMode?: string): void
|
|
118
|
+
copyWorldToInner(canvas: ILeaferCanvas, fromWorld: IMatrixWithBoundsData, toInnerBounds: IBoundsData, blendMode?: string): void
|
|
119
|
+
useMask(maskCanvas: ILeaferCanvas, fromBounds?: IBoundsData, toBounds?: IBoundsData): void
|
|
106
120
|
|
|
107
|
-
|
|
108
|
-
|
|
121
|
+
fillWorld(bounds: IBoundsData, color: string | object, blendMode?: string): void
|
|
122
|
+
strokeWorld(bounds: IBoundsData, color: string | object, blendMode?: string): void
|
|
123
|
+
clipWorld(bounds: IBoundsData, ceilPixel?: boolean): void
|
|
124
|
+
clearWorld(bounds: IBoundsData, ceilPixel?: boolean): void
|
|
109
125
|
|
|
110
|
-
replaceBy(canvas: ILeaferCanvas, fromBounds?: IBoundsData, toBounds?: IBoundsData): void
|
|
111
|
-
copy(canvas: ILeaferCanvas, fromBounds?: IBoundsData, toBounds?: IBoundsData, blendMode?: string): void
|
|
112
|
-
copyWorldToLocal(canvas: ILeaferCanvas, fromWorld: IMatrixWithBoundsData, toLocalBounds: IBoundsData, blendMode?: string): void
|
|
113
|
-
fillBounds(bounds: IBoundsData, color: string | object, blendMode?: string): void
|
|
114
|
-
strokeBounds(bounds: IBoundsData, color: string | object, blendMode?: string): void
|
|
115
|
-
clipBounds(bounds: IBoundsData): void
|
|
116
|
-
clearBounds(bounds: IBoundsData): void
|
|
117
126
|
clear(): void
|
|
118
127
|
}
|
|
119
128
|
|
|
120
129
|
export interface ILeaferCanvas extends ICanvasAttr, ICanvasMethod, IPathDrawer {
|
|
121
130
|
|
|
122
|
-
manager: ICanvasManager
|
|
123
|
-
|
|
124
131
|
readonly innerId: InnerId
|
|
132
|
+
name: string
|
|
133
|
+
|
|
134
|
+
manager: ICanvasManager
|
|
125
135
|
|
|
126
136
|
width: number
|
|
127
137
|
height: number
|
|
@@ -129,29 +139,45 @@ export interface ILeaferCanvas extends ICanvasAttr, ICanvasMethod, IPathDrawer {
|
|
|
129
139
|
pixelRatio: number
|
|
130
140
|
readonly pixelWidth: number
|
|
131
141
|
readonly pixelHeight: number
|
|
142
|
+
readonly allowBackgroundColor?: boolean
|
|
132
143
|
|
|
133
144
|
bounds: IBounds
|
|
134
145
|
|
|
146
|
+
config: ILeaferCanvasConfig
|
|
147
|
+
|
|
148
|
+
autoLayout: boolean
|
|
149
|
+
|
|
135
150
|
view: unknown
|
|
151
|
+
parentView: unknown
|
|
152
|
+
|
|
153
|
+
unreal?: boolean
|
|
154
|
+
|
|
155
|
+
offscreen: boolean
|
|
156
|
+
|
|
136
157
|
context: ICanvasContext2D
|
|
137
158
|
|
|
138
159
|
recycled?: boolean
|
|
139
160
|
|
|
140
|
-
|
|
161
|
+
worldTransform: IMatrixData
|
|
162
|
+
|
|
163
|
+
init(): void
|
|
164
|
+
|
|
165
|
+
setBackgroundColor(color: string): void
|
|
166
|
+
setHittable(hittable: boolean): void
|
|
141
167
|
|
|
142
|
-
|
|
168
|
+
startAutoLayout(autoBounds: IAutoBounds, listener: IResizeEventListener): void
|
|
143
169
|
stopAutoLayout(): void
|
|
144
170
|
|
|
145
171
|
resize(size: IScreenSizeData): void
|
|
146
|
-
|
|
172
|
+
setViewSize(size: IScreenSizeData): void
|
|
147
173
|
|
|
148
174
|
// other
|
|
149
175
|
isSameSize(options: ILeaferCanvasConfig): boolean
|
|
150
|
-
getSameCanvas(
|
|
176
|
+
getSameCanvas(useSameWorldTransform?: boolean): ILeaferCanvas
|
|
151
177
|
getBiggerCanvas(addWidth: number, addHeight: number): ILeaferCanvas
|
|
152
|
-
useSameTransform(canvas: ILeaferCanvas): void
|
|
153
178
|
recycle(): void
|
|
154
179
|
|
|
180
|
+
unrealCanvas(): void
|
|
155
181
|
destroy(): void
|
|
156
182
|
}
|
|
157
183
|
|
package/src/data/IData.ts
CHANGED
|
@@ -3,8 +3,7 @@ export type __Boolean = boolean // boolean | string will convert to boolean
|
|
|
3
3
|
export type __String = string // string | other will convert to string
|
|
4
4
|
export type __Object = IObject // will convert to object
|
|
5
5
|
export type __Value = __Number | __Boolean | __String | __Object //
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
export type ITimer = any
|
|
8
7
|
export interface IObject {
|
|
9
8
|
[name: string]: any
|
|
10
9
|
}
|
package/src/data/ILeafData.ts
CHANGED
|
@@ -5,8 +5,13 @@ export interface IDataProcessor extends IObject {
|
|
|
5
5
|
__leaf: ILeaf
|
|
6
6
|
__input: IObject
|
|
7
7
|
__middle: IObject
|
|
8
|
+
__get(name: string): unknown
|
|
9
|
+
|
|
8
10
|
__setInput(name: string, value: unknown): void
|
|
9
11
|
__getInput(name: string): unknown
|
|
12
|
+
__removeInput(name: string): void
|
|
13
|
+
__getInputData(): IObject
|
|
14
|
+
|
|
10
15
|
__setMiddle(name: string, value: unknown): void
|
|
11
16
|
__getMiddle(name: string): unknown
|
|
12
17
|
destroy(): void
|
package/src/display/IBranch.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { ILeaf } from './ILeaf'
|
|
|
3
3
|
export interface IBranch extends ILeaf {
|
|
4
4
|
children: ILeaf[]
|
|
5
5
|
|
|
6
|
-
__updateSortChildren(): void
|
|
7
|
-
add(child: ILeaf, index?: number): void
|
|
8
|
-
remove(child?: ILeaf): void
|
|
6
|
+
// __updateSortChildren(): void
|
|
7
|
+
// add(child: ILeaf, index?: number): void
|
|
8
|
+
// remove(child?: ILeaf): void
|
|
9
9
|
}
|
package/src/display/ILeaf.ts
CHANGED
|
@@ -5,15 +5,16 @@ import { ILeaferCanvas, IHitCanvas } from '../canvas/ILeaferCanvas'
|
|
|
5
5
|
import { IRenderOptions } from '../renderer/IRenderer'
|
|
6
6
|
|
|
7
7
|
import { IObject, __Number, __Boolean, __Value, __String } from '../data/IData'
|
|
8
|
-
import { IMatrixWithBoundsData, IMatrix, IBoundsData, IRadiusPointData } from '../math/IMath'
|
|
8
|
+
import { IMatrixWithBoundsData, IMatrix, IPointData, IBoundsData, IMatrixData, IRadiusPointData, IMatrixDecompositionAttr } from '../math/IMath'
|
|
9
9
|
import { IFunction } from '../function/IFunction'
|
|
10
10
|
|
|
11
11
|
import { ILeafDataProxy } from './module/ILeafDataProxy'
|
|
12
12
|
import { ILeafMatrix } from './module/ILeafMatrix'
|
|
13
13
|
import { ILeafBounds } from './module/ILeafBounds'
|
|
14
|
-
import { ILeafLayout } from '../layout/ILeafLayout'
|
|
14
|
+
import { ILeafLayout, ILayoutBoundsType, ILayoutLocationType } from '../layout/ILeafLayout'
|
|
15
15
|
import { ILeafHit } from './module/ILeafHit'
|
|
16
16
|
import { ILeafRender } from './module/ILeafRender'
|
|
17
|
+
import { ILeafMask } from './module/ILeafMask'
|
|
17
18
|
import { ILeafData } from '../data/ILeafData'
|
|
18
19
|
|
|
19
20
|
|
|
@@ -23,14 +24,17 @@ export interface ICachedLeaf {
|
|
|
23
24
|
bounds: IBoundsData
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
|
|
26
28
|
export interface ILeafAttrData {
|
|
27
29
|
// layer data
|
|
28
30
|
id: __String
|
|
29
31
|
name: __String
|
|
30
32
|
className: __String
|
|
31
33
|
|
|
34
|
+
blendMode: IBlendMode
|
|
32
35
|
opacity: __Number
|
|
33
36
|
visible: __Boolean
|
|
37
|
+
isMask: __Boolean
|
|
34
38
|
zIndex: __Number
|
|
35
39
|
|
|
36
40
|
// layout data
|
|
@@ -45,16 +49,57 @@ export interface ILeafAttrData {
|
|
|
45
49
|
skewY: __Number
|
|
46
50
|
|
|
47
51
|
draggable: __Boolean
|
|
52
|
+
|
|
53
|
+
hittable: __Boolean
|
|
54
|
+
hitFill: IHitType
|
|
55
|
+
hitStroke: IHitType
|
|
56
|
+
hitChildren: __Boolean
|
|
57
|
+
hitSelf: __Boolean
|
|
48
58
|
}
|
|
49
59
|
|
|
60
|
+
export type IHitType =
|
|
61
|
+
| 'path'
|
|
62
|
+
| 'pixel'
|
|
63
|
+
| 'all'
|
|
64
|
+
| 'none'
|
|
65
|
+
|
|
66
|
+
export type IBlendMode =
|
|
67
|
+
| 'pass-through'
|
|
68
|
+
| 'normal'
|
|
69
|
+
| 'multiply'
|
|
70
|
+
| 'screen'
|
|
71
|
+
| 'overlay'
|
|
72
|
+
| 'darken'
|
|
73
|
+
| 'lighten'
|
|
74
|
+
| 'color-dodge'
|
|
75
|
+
| 'color-burn'
|
|
76
|
+
| 'hard-light'
|
|
77
|
+
| 'soft-light'
|
|
78
|
+
| 'difference'
|
|
79
|
+
| 'exclusion'
|
|
80
|
+
| 'hue'
|
|
81
|
+
| 'saturation'
|
|
82
|
+
| 'color'
|
|
83
|
+
| 'luminosity'
|
|
84
|
+
| 'source-over' // other
|
|
85
|
+
| 'source-in'
|
|
86
|
+
| 'source-out'
|
|
87
|
+
| 'source-atop'
|
|
88
|
+
| 'destination-over'
|
|
89
|
+
| 'destination-in'
|
|
90
|
+
| 'destination-out'
|
|
91
|
+
| 'destination-atop'
|
|
92
|
+
|
|
50
93
|
export interface ILeafInputData {
|
|
51
94
|
// layer data
|
|
52
95
|
id?: __String
|
|
53
96
|
name?: __String
|
|
54
97
|
className?: __String
|
|
55
98
|
|
|
99
|
+
blendMode?: IBlendMode
|
|
56
100
|
opacity?: __Number
|
|
57
101
|
visible?: __Boolean
|
|
102
|
+
isMask?: __Boolean
|
|
58
103
|
zIndex?: __Number
|
|
59
104
|
|
|
60
105
|
// layout data
|
|
@@ -69,6 +114,12 @@ export interface ILeafInputData {
|
|
|
69
114
|
skewY?: __Number
|
|
70
115
|
|
|
71
116
|
draggable?: __Boolean
|
|
117
|
+
|
|
118
|
+
hittable?: __Boolean
|
|
119
|
+
hitFill?: IHitType
|
|
120
|
+
hitStroke?: IHitType
|
|
121
|
+
hitChildren?: __Boolean
|
|
122
|
+
hitSelf?: __Boolean
|
|
72
123
|
}
|
|
73
124
|
export interface ILeafComputedData {
|
|
74
125
|
// layer data
|
|
@@ -76,8 +127,10 @@ export interface ILeafComputedData {
|
|
|
76
127
|
name?: string
|
|
77
128
|
className?: string
|
|
78
129
|
|
|
130
|
+
blendMode?: IBlendMode
|
|
79
131
|
opacity?: number
|
|
80
132
|
visible?: boolean
|
|
133
|
+
isMask?: boolean
|
|
81
134
|
zIndex?: number
|
|
82
135
|
|
|
83
136
|
// layout data
|
|
@@ -92,77 +145,116 @@ export interface ILeafComputedData {
|
|
|
92
145
|
skewY?: number
|
|
93
146
|
|
|
94
147
|
draggable?: boolean
|
|
148
|
+
|
|
149
|
+
hittable?: boolean
|
|
150
|
+
hitFill?: IHitType
|
|
151
|
+
hitStroke?: IHitType
|
|
152
|
+
hitChildren?: boolean
|
|
153
|
+
hitSelf?: boolean
|
|
154
|
+
|
|
155
|
+
// other
|
|
156
|
+
__childBranchNumber?: number // 存在子分支的个数
|
|
157
|
+
__complex?: boolean // 外观是否复杂
|
|
95
158
|
}
|
|
96
159
|
|
|
97
|
-
export interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix, ILeafDataProxy, ILeafInputData, IEventer {
|
|
98
|
-
|
|
160
|
+
export interface ILeaf extends ILeafMask, ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix, ILeafDataProxy, ILeafInputData, IEventer {
|
|
161
|
+
tag: string
|
|
162
|
+
readonly __tag: string
|
|
163
|
+
readonly innerName: string
|
|
164
|
+
|
|
99
165
|
readonly __DataProcessor: IObject // IDataProcessor
|
|
100
166
|
readonly __LayoutProcessor: IObject // ILeafLayout
|
|
101
167
|
|
|
102
168
|
leafer?: ILeafer
|
|
103
|
-
root?: ILeaf
|
|
104
169
|
parent?: ILeaf
|
|
105
170
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
__isBranch?: boolean
|
|
111
|
-
__isBranchLeaf?: boolean
|
|
171
|
+
readonly isApp?: boolean
|
|
172
|
+
isLeafer?: boolean
|
|
173
|
+
isBranch?: boolean
|
|
174
|
+
isBranchLeaf?: boolean
|
|
112
175
|
|
|
113
176
|
__: ILeafData
|
|
114
177
|
__layout: ILeafLayout
|
|
115
178
|
|
|
116
|
-
|
|
179
|
+
__local: IMatrixWithBoundsData
|
|
117
180
|
__world: IMatrixWithBoundsData
|
|
118
|
-
|
|
119
181
|
__worldOpacity: number
|
|
120
|
-
|
|
121
|
-
|
|
182
|
+
|
|
183
|
+
readonly worldTransform: IMatrixData
|
|
184
|
+
readonly localTransform: IMatrixData
|
|
185
|
+
|
|
186
|
+
readonly worldBoxBounds: IBoundsData
|
|
187
|
+
readonly worldStrokeBounds: IBoundsData
|
|
188
|
+
readonly worldRenderBounds: IBoundsData
|
|
189
|
+
|
|
190
|
+
readonly worldOpacity: number
|
|
191
|
+
|
|
192
|
+
__renderTime?: number // μs 1000微秒 = 1毫秒
|
|
122
193
|
|
|
123
194
|
__level: number // 图层级别 root(1) -> hight
|
|
124
195
|
__tempNumber?: number // 用于临时运算储存状态
|
|
125
196
|
|
|
197
|
+
__hasMask?: boolean
|
|
126
198
|
__hitCanvas?: IHitCanvas
|
|
127
199
|
|
|
200
|
+
readonly __onlyHitMask: boolean
|
|
201
|
+
readonly __ignoreHitWorld: boolean
|
|
202
|
+
|
|
128
203
|
__parentWait?: IFunction[]
|
|
204
|
+
__leaferWait?: IFunction[]
|
|
129
205
|
|
|
130
|
-
|
|
131
|
-
|
|
206
|
+
waitParent(item: IFunction): void
|
|
207
|
+
waitLeafer(item: IFunction): void
|
|
132
208
|
|
|
133
|
-
|
|
134
|
-
__setAsRoot(): void
|
|
209
|
+
__bindLeafer(leafer: ILeafer | null): void
|
|
135
210
|
|
|
136
|
-
|
|
211
|
+
set(data: IObject): void
|
|
212
|
+
get(attrNames?: string[]): IObject
|
|
137
213
|
|
|
138
214
|
// ILeafData ->
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
215
|
+
__setAttr(attrName: string, newValue: __Value): void
|
|
216
|
+
__getAttr(attrName: string): __Value
|
|
217
|
+
|
|
218
|
+
forceUpdate(attrName?: string): void
|
|
142
219
|
|
|
143
220
|
// ILeafMatrix ->
|
|
144
221
|
__updateWorldMatrix(): void
|
|
145
|
-
|
|
222
|
+
__updateLocalMatrix(): void
|
|
146
223
|
|
|
147
224
|
// ILeafBounds ->
|
|
148
225
|
__updateWorldBounds(): void
|
|
149
226
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
227
|
+
__updateLocalBoxBounds(): void
|
|
228
|
+
__updateLocalStrokeBounds(): void
|
|
229
|
+
__updateLocalRenderBounds(): void
|
|
153
230
|
|
|
154
231
|
__updateBoxBounds(): void
|
|
155
|
-
|
|
232
|
+
__updateStrokeBounds(): void
|
|
156
233
|
__updateRenderBounds(): void
|
|
157
234
|
|
|
158
|
-
|
|
159
|
-
|
|
235
|
+
__updateStrokeSpread(): number
|
|
236
|
+
__updateRenderSpread(): number
|
|
160
237
|
|
|
161
238
|
__onUpdateSize(): void
|
|
162
239
|
|
|
240
|
+
// IBranchMask ->
|
|
241
|
+
__updateMask(value?: boolean): void
|
|
242
|
+
__renderMask(canvas: ILeaferCanvas, content: ILeaferCanvas, mask: ILeaferCanvas): void
|
|
243
|
+
__removeMask(child?: ILeaf): void
|
|
244
|
+
|
|
245
|
+
// convert
|
|
246
|
+
getWorld(attrName: IMatrixDecompositionAttr): number
|
|
247
|
+
getBounds(type: ILayoutBoundsType, locationType?: ILayoutLocationType): IBoundsData
|
|
248
|
+
|
|
249
|
+
worldToLocal(world: IPointData, to?: IPointData, isMovePoint?: boolean): void
|
|
250
|
+
localToWorld(local: IPointData, to?: IPointData, isMovePoint?: boolean): void
|
|
251
|
+
worldToInner(world: IPointData, to?: IPointData, isMovePoint?: boolean): void
|
|
252
|
+
innerToWorld(inner: IPointData, to?: IPointData, isMovePoint?: boolean): void
|
|
253
|
+
|
|
163
254
|
// ILeafHit ->
|
|
164
255
|
__hitWorld(point: IRadiusPointData): boolean
|
|
165
256
|
__hit(local: IRadiusPointData): boolean
|
|
257
|
+
__drawHitPath(canvas: ILeaferCanvas): void
|
|
166
258
|
__updateHitCanvas(): void
|
|
167
259
|
|
|
168
260
|
// ILeafRender ->
|
|
@@ -170,6 +262,8 @@ export interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix,
|
|
|
170
262
|
__drawFast(canvas: ILeaferCanvas, options: IRenderOptions): void
|
|
171
263
|
__draw(canvas: ILeaferCanvas, options: IRenderOptions): void
|
|
172
264
|
|
|
265
|
+
__renderShape(canvas: ILeaferCanvas, options: IRenderOptions): void
|
|
266
|
+
|
|
173
267
|
__updateWorldOpacity(): void
|
|
174
268
|
__updateChange(): void
|
|
175
269
|
|
|
@@ -181,11 +275,8 @@ export interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix,
|
|
|
181
275
|
|
|
182
276
|
// branch
|
|
183
277
|
children?: ILeaf[]
|
|
184
|
-
__childBranchNumber?: number // 存在子分支的个数
|
|
185
278
|
|
|
186
279
|
__updateSortChildren(): void
|
|
187
280
|
add(child: ILeaf, index?: number): void
|
|
188
281
|
remove(child?: ILeaf): void
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
|
|
282
|
+
}
|
package/src/display/IView.ts
CHANGED
|
@@ -5,16 +5,16 @@ export type ILeafBoundsModule = ILeafBounds & ThisType<ILeaf>
|
|
|
5
5
|
export interface ILeafBounds {
|
|
6
6
|
__updateWorldBounds?(): void
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
__updateLocalBoxBounds?(): void
|
|
9
|
+
__updateLocalStrokeBounds?(): void
|
|
10
|
+
__updateLocalRenderBounds?(): void
|
|
11
11
|
|
|
12
12
|
__updateBoxBounds?(): void
|
|
13
|
-
|
|
13
|
+
__updateStrokeBounds?(): void
|
|
14
14
|
__updateRenderBounds?(): void
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
__updateStrokeSpread?(): number
|
|
17
|
+
__updateRenderSpread?(): number
|
|
18
18
|
|
|
19
19
|
__onUpdateSize?(): void
|
|
20
20
|
}
|