@leafer/interface 1.0.0-alpha.1 → 1.0.0-alpha.21

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,11 +1,13 @@
1
1
  {
2
2
  "name": "@leafer/interface",
3
- "version": "1.0.0-alpha.1",
3
+ "version": "1.0.0-alpha.21",
4
4
  "description": "@leafer/interface",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
7
7
  "main": "src/index.ts",
8
- "files": ["src"],
8
+ "files": [
9
+ "src"
10
+ ],
9
11
  "repository": {
10
12
  "type": "git",
11
13
  "url": "https://github.com/leaferjs/leafer.git"
@@ -16,4 +18,4 @@
16
18
  "leafer",
17
19
  "leaferjs"
18
20
  ]
19
- }
21
+ }
@@ -1,5 +1,5 @@
1
1
  import { ILeafer } from './ILeafer'
2
2
 
3
- export interface ISupperLeafer extends ILeafer {
3
+ export interface IApp extends ILeafer {
4
4
  children: ILeafer[]
5
5
  }
@@ -11,23 +11,23 @@ import { IHitCanvasManager } from '../canvas/IHitCanvasManager'
11
11
  import { IImageManager } from '../image/IImageManager'
12
12
  import { IObject } from '../data/IData'
13
13
  import { IZoomView } from '../display/IView'
14
- import { ISupperLeafer } from './ISupperLeafer'
14
+ import { IApp } from './IApp'
15
15
  import { ILeaferImage, ILeaferImageConfig } from '../image/ILeaferImage'
16
16
  import { IEvent } from '../event/IEvent'
17
17
 
18
18
 
19
19
  export interface ILeaferConfig extends IRendererConfig, ILeaferCanvasConfig, IInteractionConfig, ILayouterConfig {
20
- start?: boolean
21
- zoom?: boolean
22
- move?: boolean
20
+ autoStart?: boolean
21
+ useZoom?: boolean
22
+ useMove?: boolean
23
23
  }
24
24
 
25
25
  export interface ILeafer extends IZoomView {
26
26
 
27
27
  creator: ICreator
28
28
 
29
- readonly isSupperLeafer: boolean
30
- parent?: ISupperLeafer
29
+ readonly isApp: boolean
30
+ parent?: IApp
31
31
 
32
32
  running: boolean
33
33
 
@@ -46,6 +46,8 @@ export interface ILeafer extends IZoomView {
46
46
  hitCanvasManager?: IHitCanvasManager
47
47
  imageManager: IImageManager
48
48
 
49
+ config: ILeaferConfig
50
+
49
51
  start(): void
50
52
  stop(): void
51
53
 
@@ -1,24 +1,24 @@
1
1
  type GlobalCompositeOperation = 'color' | 'color-burn' | 'color-dodge' | 'copy' | 'darken' | 'destination-atop' | 'destination-in' | 'destination-out' | 'destination-over' | 'difference' | 'exclusion' | 'hard-light' | 'hue' | 'lighten' | 'lighter' | 'luminosity' | 'multiply' | 'overlay' | 'saturation' | 'screen' | 'soft-light' | 'source-atop' | 'source-in' | 'source-out' | 'source-over' | 'xor'
2
2
  type CanvasDirection = 'inherit' | 'ltr' | 'rtl'
3
- export type CanvasFillRule = 'evenodd' | 'nonzero'
4
- type CanvasFontKerning = 'auto' | 'none' | 'normal'
5
- type CanvasFontStretch = 'condensed' | 'expanded' | 'extra-condensed' | 'extra-expanded' | 'normal' | 'semi-condensed' | 'semi-expanded' | 'ultra-condensed' | 'ultra-expanded'
6
- type CanvasFontVariantCaps = 'all-petite-caps' | 'all-small-caps' | 'normal' | 'petite-caps' | 'small-caps' | 'titling-caps' | 'unicase'
3
+ export type IWindingRule = 'evenodd' | 'nonzero'
4
+ // type CanvasFontKerning = 'auto' | 'none' | 'normal'
5
+ // type CanvasFontStretch = 'condensed' | 'expanded' | 'extra-condensed' | 'extra-expanded' | 'normal' | 'semi-condensed' | 'semi-expanded' | 'ultra-condensed' | 'ultra-expanded'
6
+ // type CanvasFontVariantCaps = 'all-petite-caps' | 'all-small-caps' | 'normal' | 'petite-caps' | 'small-caps' | 'titling-caps' | 'unicase'
7
7
  type CanvasLineCap = 'butt' | 'round' | 'square'
8
8
  type CanvasLineJoin = 'bevel' | 'miter' | 'round'
9
9
  type CanvasTextAlign = 'center' | 'end' | 'left' | 'right' | 'start'
10
10
  type CanvasTextBaseline = 'alphabetic' | 'bottom' | 'hanging' | 'ideographic' | 'middle' | 'top'
11
- type CanvasTextRendering = 'auto' | 'geometricPrecision' | 'optimizeLegibility' | 'optimizeSpeed'
11
+ //type CanvasTextRendering = 'auto' | 'geometricPrecision' | 'optimizeLegibility' | 'optimizeSpeed'
12
12
 
13
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
- interface Path2D extends CanvasPath {
14
+ export interface IPath2D extends CanvasPath {
15
15
  /** Adds to the path the path given by the argument. */
16
- addPath(path: Path2D, transform?: DOMMatrix2DInit): void
16
+ addPath(path: IPath2D, transform?: DOMMatrix2DInit): void
17
17
  }
18
18
 
19
- export declare var Path2D: {
20
- prototype: Path2D
21
- new(path?: Path2D | string): Path2D
19
+ declare var IPath2D: {
20
+ prototype: IPath2D
21
+ new(path?: IPath2D | string): IPath2D
22
22
  }
23
23
 
24
24
  interface CanvasCompositing {
@@ -35,16 +35,16 @@ interface CanvasDrawImage {
35
35
 
36
36
  interface CanvasDrawPath {
37
37
  beginPath(): void
38
- clip(fillRule?: CanvasFillRule): void
39
- clip(path: Path2D, fillRule?: CanvasFillRule): void
40
- fill(fillRule?: CanvasFillRule): void
41
- fill(path: Path2D, fillRule?: CanvasFillRule): void
42
- isPointInPath(x: number, y: number, fillRule?: CanvasFillRule): boolean
43
- isPointInPath(path: Path2D, x: number, y: number, fillRule?: CanvasFillRule): boolean
38
+ clip(fillRule?: IWindingRule): void
39
+ clip(path: IPath2D, fillRule?: IWindingRule): void
40
+ fill(fillRule?: IWindingRule): void
41
+ fill(path: IPath2D, fillRule?: IWindingRule): void
42
+ isPointInPath(x: number, y: number, fillRule?: IWindingRule): boolean
43
+ isPointInPath(path: IPath2D, x: number, y: number, fillRule?: IWindingRule): boolean
44
44
  isPointInStroke(x: number, y: number): boolean
45
- isPointInStroke(path: Path2D, x: number, y: number): boolean
45
+ isPointInStroke(path: IPath2D, x: number, y: number): boolean
46
46
  stroke(): void
47
- stroke(path: Path2D): void
47
+ stroke(path: IPath2D): void
48
48
  }
49
49
 
50
50
  interface CanvasFillStrokeStyles {
@@ -137,14 +137,14 @@ interface CanvasRenderingContext2DSettings {
137
137
  }
138
138
 
139
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
- export interface CanvasRenderingContext2D extends CanvasCompositing, CanvasDrawImage, CanvasDrawPath, CanvasFillStrokeStyles, CanvasFilters, CanvasImageData, CanvasImageSmoothing, CanvasPath, CanvasPathDrawingStyles, CanvasRect, CanvasShadowStyles, CanvasState, CanvasText, CanvasTextDrawingStyles, CanvasTransform, CanvasUserInterface {
140
+ export interface ICanvasContext2D extends CanvasCompositing, CanvasDrawImage, CanvasDrawPath, CanvasFillStrokeStyles, CanvasFilters, CanvasImageData, CanvasImageSmoothing, CanvasPath, CanvasPathDrawingStyles, CanvasRect, CanvasShadowStyles, CanvasState, CanvasText, CanvasTextDrawingStyles, CanvasTransform, CanvasUserInterface {
141
141
  readonly canvas: HTMLCanvasElement
142
142
  getContextAttributes(): CanvasRenderingContext2DSettings
143
143
  }
144
144
 
145
- declare var CanvasRenderingContext2D: {
146
- prototype: CanvasRenderingContext2D
147
- new(): CanvasRenderingContext2D
145
+ declare var ICanvasContext2D: {
146
+ prototype: ICanvasContext2D
147
+ new(): ICanvasContext2D
148
148
  }
149
149
 
150
150
  interface CanvasShadowStyles {
@@ -161,12 +161,12 @@ interface CanvasState {
161
161
 
162
162
  interface CanvasUserInterface {
163
163
  drawFocusIfNeeded(element: any): void
164
- drawFocusIfNeeded(path: Path2D, element: any): void
164
+ drawFocusIfNeeded(path: IPath2D, element: any): void
165
165
  }
166
166
 
167
167
 
168
168
  /** The dimensions of a piece of text in the canvas, as created by the CanvasRenderingContext2D.measureText() method. */
169
- export interface TextMetrics {
169
+ export interface ITextMetrics {
170
170
  /** Returns the measurement described below. */
171
171
  readonly actualBoundingBoxAscent: number
172
172
  /** Returns the measurement described below. */
@@ -184,13 +184,13 @@ export interface TextMetrics {
184
184
  }
185
185
 
186
186
  declare var TextMetrics: {
187
- prototype: TextMetrics
188
- new(): TextMetrics
187
+ prototype: ITextMetrics
188
+ new(): ITextMetrics
189
189
  }
190
190
 
191
191
  interface CanvasText {
192
192
  fillText(text: string, x: number, y: number, maxWidth?: number): void
193
- measureText(text: string): TextMetrics
193
+ measureText(text: string): ITextMetrics
194
194
  strokeText(text: string, x: number, y: number, maxWidth?: number): void
195
195
  }
196
196
 
@@ -1,19 +1,17 @@
1
1
  import { IObject } from '../data/IData'
2
2
  import { IBounds, IMatrixData, IBoundsData, IAutoBoundsData, IAutoBounds, IScreenSizeData, IMatrixWithBoundsData, IPointData } from '../math/IMath'
3
- import { CanvasRenderingContext2D, CanvasFillRule, Path2D, TextMetrics, CanvasGradient, CanvasPattern } from './ICanvas'
3
+ import { ICanvasContext2D, IWindingRule, IPath2D, ITextMetrics, CanvasGradient, CanvasPattern } from './ICanvas'
4
4
  import { IResizeEventListener } from '../event/IEvent'
5
- import { ICanvasDrawPath } from './ICanvasPathDrawer'
5
+ import { IPathDrawer } from '../path/IPathDrawer'
6
6
  import { InnerId } from '../event/IEventer'
7
7
  import { ICanvasManager } from './ICanvasManager'
8
8
 
9
- export interface ILeaferCanvasContext extends CanvasRenderingContext2D {
10
-
11
- }
12
-
13
9
  export interface ILeaferCanvasConfig extends IAutoBoundsData {
14
10
  view?: string | IObject
15
11
  fill?: string
16
12
  pixelRatio?: number
13
+ hittable?: boolean
14
+ offscreen?: boolean
17
15
  webgl?: boolean
18
16
  }
19
17
 
@@ -67,9 +65,9 @@ interface ICanvasMethod {
67
65
  save(): void
68
66
  restore(): void
69
67
 
70
- fill(path?: Path2D | CanvasFillRule, rule?: CanvasFillRule): void
71
- stroke(path?: Path2D): void
72
- clip(path?: Path2D | CanvasFillRule, rule?: CanvasFillRule): void
68
+ fill(path?: IPath2D | IWindingRule, rule?: IWindingRule): void
69
+ stroke(path?: IPath2D): void
70
+ clip(path?: IPath2D | IWindingRule, rule?: IWindingRule): void
73
71
 
74
72
  fillRect(x: number, y: number, width: number, height: number): void
75
73
  strokeRect(x: number, y: number, width: number, height: number): void
@@ -95,33 +93,32 @@ interface ICanvasMethod {
95
93
  // text
96
94
 
97
95
  fillText(text: string, x: number, y: number, maxWidth?: number): void
98
- measureText(text: string): TextMetrics
96
+ measureText(text: string): ITextMetrics
99
97
  strokeText(text: string, x: number, y: number, maxWidth?: number): void
100
98
 
101
99
  // custom
102
100
 
103
- setStroke(strokeStyle: string | object, strokeWidth: number, options?: ICanvasStrokeOptions): void
104
- setShadow(x: number, y: number, blur: number, color?: string): void
105
- setBlur(blur: number): void
101
+ hitPath(point: IPointData, fillRule?: string): boolean
102
+ hitStroke(point: IPointData): boolean
106
103
 
104
+ setStroke(strokeStyle: string | object, strokeWidth: number, options?: ICanvasStrokeOptions): void
107
105
 
108
106
  setWorld(matrix: IMatrixData, parentMatrix?: IMatrixData): void
109
107
 
108
+ setWorldShadow(x: number, y: number, blur: number, color?: string): void
109
+ setWorldBlur(blur: number): void
110
110
 
111
- hitPath(point: IPointData, fillRule?: string): boolean
112
- hitStroke(point: IPointData): boolean
113
-
114
- replaceBy(canvas: ILeaferCanvas, fromBounds?: IBoundsData, toBounds?: IBoundsData): void
115
- copy(canvas: ILeaferCanvas, fromBounds?: IBoundsData, toBounds?: IBoundsData, blendMode?: string): void
111
+ copyWorld(canvas: ILeaferCanvas, fromBounds?: IBoundsData, toBounds?: IBoundsData, blendMode?: string): void
116
112
  copyWorldToLocal(canvas: ILeaferCanvas, fromWorld: IMatrixWithBoundsData, toLocalBounds: IBoundsData, blendMode?: string): void
117
- fillBounds(bounds: IBoundsData, color: string | object, blendMode?: string): void
118
- strokeBounds(bounds: IBoundsData, color: string | object, blendMode?: string): void
119
- clipBounds(bounds: IBoundsData): void
120
- clearBounds(bounds: IBoundsData): void
113
+ fillWorld(bounds: IBoundsData, color: string | object, blendMode?: string): void
114
+ strokeWorld(bounds: IBoundsData, color: string | object, blendMode?: string): void
115
+ clipWorld(bounds: IBoundsData, ceilPixel?: boolean): void
116
+ clearWorld(bounds: IBoundsData, ceilPixel?: boolean): void
117
+
121
118
  clear(): void
122
119
  }
123
120
 
124
- export interface ILeaferCanvas extends ICanvasAttr, ICanvasMethod, ICanvasDrawPath {
121
+ export interface ILeaferCanvas extends ICanvasAttr, ICanvasMethod, IPathDrawer {
125
122
 
126
123
  manager: ICanvasManager
127
124
 
@@ -137,13 +134,12 @@ export interface ILeaferCanvas extends ICanvasAttr, ICanvasMethod, ICanvasDrawPa
137
134
  bounds: IBounds
138
135
 
139
136
  view: unknown
140
- context: ILeaferCanvasContext
137
+ offscreen: boolean
138
+ context: ICanvasContext2D
141
139
 
142
140
  recycled?: boolean
143
141
 
144
- debug(): void
145
-
146
- autoLayout(autoBounds: IAutoBounds, listener: IResizeEventListener): void
142
+ startAutoLayout(autoBounds: IAutoBounds, listener: IResizeEventListener): void
147
143
  stopAutoLayout(): void
148
144
 
149
145
  resize(size: IScreenSizeData): void
@@ -23,6 +23,7 @@ export interface ICachedLeaf {
23
23
  bounds: IBoundsData
24
24
  }
25
25
 
26
+
26
27
  export interface ILeafAttrData {
27
28
  // layer data
28
29
  id: __String
@@ -45,8 +46,14 @@ export interface ILeafAttrData {
45
46
  skewY: __Number
46
47
 
47
48
  draggable: __Boolean
49
+
50
+ hittable: __Boolean
51
+ hitType: IHitType
52
+ hitChildren: __Boolean
48
53
  }
49
54
 
55
+ export type IHitType = 'visible' | 'fill-visible' | 'stroke-visible' | 'all' | 'fill' | 'stroke'
56
+
50
57
  export interface ILeafInputData {
51
58
  // layer data
52
59
  id?: __String
@@ -69,6 +76,10 @@ export interface ILeafInputData {
69
76
  skewY?: __Number
70
77
 
71
78
  draggable?: __Boolean
79
+
80
+ hittable?: __Boolean
81
+ hitType?: IHitType
82
+ hitChildren?: __Boolean
72
83
  }
73
84
  export interface ILeafComputedData {
74
85
  // layer data
@@ -92,6 +103,14 @@ export interface ILeafComputedData {
92
103
  skewY?: number
93
104
 
94
105
  draggable?: boolean
106
+
107
+ hittable?: boolean
108
+ hitType?: IHitType
109
+ hitChildren?: boolean
110
+
111
+ // other
112
+ __childBranchNumber?: number // 存在子分支的个数
113
+ __complex?: boolean // 外观是否复杂
95
114
  }
96
115
 
97
116
  export interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix, ILeafDataProxy, ILeafInputData, IEventer {
@@ -103,9 +122,6 @@ export interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix,
103
122
  root?: ILeaf
104
123
  parent?: ILeaf
105
124
 
106
- __interactionOff?: boolean
107
- __childrenInteractionOff?: boolean
108
-
109
125
  __isRoot?: boolean
110
126
  __isBranch?: boolean
111
127
  __isBranchLeaf?: boolean
@@ -118,7 +134,6 @@ export interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix,
118
134
 
119
135
  __worldOpacity: number
120
136
  __renderTime: number // μs 1000微秒 = 1毫秒
121
- __complex: boolean // 外观是否复杂, 将调用__drawComplex()
122
137
 
123
138
  __level: number // 图层级别 root(1) -> hight
124
139
  __tempNumber?: number // 用于临时运算储存状态
@@ -171,6 +186,7 @@ export interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix,
171
186
  __draw(canvas: ILeaferCanvas, options: IRenderOptions): void
172
187
 
173
188
  __updateWorldOpacity(): void
189
+ __updateRenderTime(): void
174
190
  __updateChange(): void
175
191
 
176
192
  // path
@@ -181,7 +197,6 @@ export interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix,
181
197
 
182
198
  // branch
183
199
  children?: ILeaf[]
184
- __childBranchNumber?: number // 存在子分支的个数
185
200
 
186
201
  __updateSortChildren(): void
187
202
  add(child: ILeaf, index?: number): void
@@ -6,12 +6,13 @@ export type ILeafRenderModule = ILeafRender & ThisType<ILeaf>
6
6
 
7
7
  export interface ILeafRender {
8
8
  __render?(canvas: ILeaferCanvas, options: IRenderOptions): void
9
- __drawFast?(canvas: ILeaferCanvas, options: IRenderOptions): void
10
9
  __draw?(canvas: ILeaferCanvas, options: IRenderOptions): void
10
+ __drawFast?(canvas: ILeaferCanvas, options: IRenderOptions): void
11
11
 
12
12
  __drawBefore?(canvas: ILeaferCanvas, options: IRenderOptions): void
13
13
  __drawAfter?(canvas: ILeaferCanvas, options: IRenderOptions): void
14
14
 
15
15
  __updateWorldOpacity?(): void
16
+ __updateRenderTime?(): void
16
17
  __updateChange?(): void
17
18
  }
@@ -1,5 +1,5 @@
1
1
  import { IEvent, IFunction, IObject } from '@leafer/interface'
2
- import { LeafEventer } from '../display/module/ILeafEventer'
2
+ import { ILeafEventer } from '../display/module/ILeafEventer'
3
3
 
4
4
  export type IEventListener = IFunction
5
5
 
@@ -24,7 +24,7 @@ export interface IEventListenerId {
24
24
 
25
25
  export type InnerId = number
26
26
 
27
- export interface IEventer extends LeafEventer {
27
+ export interface IEventer extends ILeafEventer {
28
28
 
29
29
  readonly innerId: InnerId
30
30
  __captureMap?: IEventListenerMap
@@ -3,6 +3,10 @@ export interface ILeaferImageConfig {
3
3
  thumb?: string
4
4
  }
5
5
 
6
+
7
+
6
8
  export interface ILeaferImage {
9
+ //load(url: string):Promise<>
10
+ }
7
11
 
8
- }
12
+ export type IImageStatus = 'wait' | 'thumb-loading' | 'thumb-success' | 'thumb-error' | 'loading' | 'success' | 'error'
package/src/index.ts CHANGED
@@ -1,6 +1,6 @@
1
- export { ISupperLeafer } from './app/ISupperLeafer'
1
+ export { IApp } from './app/IApp'
2
2
  export { ILeafer, ILeaferConfig, ICreator, IUICreator } from './app/ILeafer'
3
- export { ILeaf, ILeafAttrData, ILeafComputedData, ILeafInputData, ICachedLeaf } from './display/ILeaf'
3
+ export { ILeaf, ILeafAttrData, ILeafComputedData, ILeafInputData, ICachedLeaf, IHitType } from './display/ILeaf'
4
4
  export { IBranch } from './display/IBranch'
5
5
  export { IZoomView } from './display/IView'
6
6
 
@@ -29,9 +29,9 @@ export { IPlatform } from './platform/IPlatform'
29
29
  export { IPlugin } from './plugin/IPlugin'
30
30
 
31
31
 
32
- export { ILeaferCanvas, IHitCanvas, ICanvasAttr, ICanvasStrokeOptions, ILeaferCanvasContext, ILeaferCanvasConfig, IHitCanvasConfig } from './canvas/ILeaferCanvas'
33
- export { ICanvasDrawPath } from './canvas/ICanvasPathDrawer'
34
- export { CanvasFillRule, CanvasRenderingContext2D, TextMetrics, Path2D } from './canvas/ICanvas'
32
+ export { ILeaferCanvas, IHitCanvas, ICanvasAttr, ICanvasStrokeOptions, ILeaferCanvasConfig, IHitCanvasConfig } from './canvas/ILeaferCanvas'
33
+ export { IPathDrawer } from './path/IPathDrawer'
34
+ export { IWindingRule, ICanvasContext2D, ITextMetrics, IPath2D } from './canvas/ICanvas'
35
35
  export { CanvasPathCommand, IPathCommandData, MCommandData, HCommandData, VCommandData, LCommandData, CCommandData, SCommandData, QCommandData, TCommandData, ZCommandData, ACommandData, RectCommandData, RoundRectCommandData, EllipseCommandData, ArcCommandData, ArcToCommandData } from './path/IPathCommand'
36
36
 
37
37
  export { ILeaferImage, ILeaferImageConfig } from './image/ILeaferImage'
@@ -1,20 +1,33 @@
1
1
  import { INumberFunction, IPointDataFunction } from '../function/IFunction'
2
- import { IPointerEvent, IMoveEvent, IZoomEvent, IRotateEvent } from '../event/IUIEvent'
2
+ import { IPointerEvent, IMoveEvent, IZoomEvent, IRotateEvent, IUIEvent } from '../event/IUIEvent'
3
3
  import { ILeaf } from '../display/ILeaf'
4
+ import { ILeafList } from '../data/IList'
4
5
  import { IPointData } from '../math/IMath'
6
+ import { ISelector } from '../selector/ISelector'
7
+ import { ILeaferCanvas } from '../canvas/ILeaferCanvas'
8
+ import { IBounds } from '../math/IMath'
5
9
 
6
10
  export interface IInteraction {
7
11
  target: ILeaf
8
- config: IInteractionConfig
12
+ canvas: ILeaferCanvas
13
+ selector: ISelector
14
+
9
15
  running: boolean
16
+ readonly dragging: boolean
17
+
18
+ config: IInteractionConfig
19
+
20
+ readonly hitRadius: number
21
+ shrinkCanvasBounds: IBounds
10
22
 
11
- pointerMoveIgnore: boolean
23
+ downData: IPointerEvent
12
24
 
13
25
  start(): void
14
26
  stop(): void
15
27
 
16
28
  pointerDown(data: IPointerEvent): void
17
29
  pointerMove(data: IPointerEvent): void
30
+ pointerMoveReal(data: IPointerEvent): void
18
31
  pointerUp(data: IPointerEvent): void
19
32
  pointerCancel(): void
20
33
 
@@ -22,6 +35,8 @@ export interface IInteraction {
22
35
  zoom(data: IZoomEvent): void
23
36
  rotate(data: IRotateEvent): void
24
37
 
38
+ emit(type: string, data: IUIEvent, path?: ILeafList, excludePath?: ILeafList): void
39
+
25
40
  destroy(): void
26
41
  }
27
42
 
@@ -36,7 +51,7 @@ export interface IWheelConfig {
36
51
  zoomSpeed?: number // 取值范围 0 ~ 1, 默认0.5
37
52
  moveSpeed?: number
38
53
  rotateSpeed?: number // 取值范围 0 ~ 1, 默认0.5
39
- delta?: IPointData
54
+ delta?: IPointData // 以chrome为基准, 鼠标滚动一格的距离
40
55
  getScale?: INumberFunction
41
56
  getMove?: IPointDataFunction
42
57
  }
@@ -50,4 +65,5 @@ export interface IPointerConfig {
50
65
  dragDistance?: number
51
66
  swipeDistance?: number
52
67
  autoMoveDistance?: number
68
+ ignoreMove: boolean // 性能优化字段, 控制move事件触发次数
53
69
  }
@@ -33,20 +33,27 @@ export interface ILayouterConfig {
33
33
  export interface ILayouter {
34
34
  target: ILeaf
35
35
  layoutedBlocks: ILayoutBlockData[]
36
+
36
37
  totalTimes: number
37
38
  times: number
38
- config: ILayouterConfig
39
+
39
40
  running: boolean
41
+ changed: boolean
42
+
43
+ config: ILayouterConfig
40
44
 
41
45
  start(): void
42
46
  stop(): void
47
+ update(): void
48
+
49
+ layout(): void
50
+ layoutOnce(): void
51
+ partLayout(): void
52
+ fullLayout(): void
43
53
 
44
54
  createBlock(data: ILeafList | ILeaf[]): ILayoutBlockData
45
55
  getBlocks(list: ILeafList): ILayoutBlockData[]
46
56
  setBlocks(current: ILayoutBlockData[]): void
47
57
 
48
- layout(): void
49
- partLayout(): void
50
- fullLayout(): void
51
58
  destroy(): void
52
59
  }
package/src/math/IMath.ts CHANGED
@@ -10,10 +10,10 @@ export interface IPoint extends IPointData {
10
10
  copy(point: IPointData): IPoint
11
11
  clone(): IPoint
12
12
 
13
- rotate(angle: number, center?: IPointData): void
13
+ rotate(angle: number, center?: IPointData): IPoint
14
14
 
15
- toLocal(matrix: IMatrixData): void
16
- toWorld(matrix: IMatrixData): void
15
+ toLocal(matrix: IMatrixData, to?: IPointData): IPoint
16
+ toWorld(matrix: IMatrixData, to?: IPointData): IPoint
17
17
 
18
18
  getCenter(to: IPointData): IPointData
19
19
  getDistance(to: IPointData): number
@@ -54,27 +54,27 @@ export interface IBounds extends IBoundsData {
54
54
  copy(bounds: IBoundsData): IBounds
55
55
  clone(): IBounds
56
56
 
57
- timesMatrix(matrix: IMatrixData): IBounds
58
- divideMatrix(matrix: IMatrixData): IBounds
57
+ scale(scale: number): IBounds
58
+ toWorld(matrix: IMatrixData, to?: IBoundsData): IBounds
59
59
  getFitMatrix(put: IBoundsData): IMatrix
60
- spread(size: number): void
61
- ceil(): void
62
60
 
63
- add(bounds: IBoundsData): void
64
- addList(boundsList: IBounds[]): void
65
- setByList(boundsList: IBounds[], addMode?: boolean): void
66
- addListWithHandle(list: IObject[], boundsDataHandle: IBoundsDataHandle): void
67
- setByListWithHandle(list: IObject[], boundsDataHandle: IBoundsDataHandle, addMode: boolean): void
68
- setByBoundsTimesMatrix(fromBounds: IBoundsData, fromMatrix: IMatrixData): void
69
- setByPoints(points: IPointData[]): void
61
+ spread(size: number): IBounds
62
+ ceil(): IBounds
63
+
64
+ add(bounds: IBoundsData): IBounds
65
+ addList(boundsList: IBounds[]): IBounds
66
+ setByList(boundsList: IBounds[], addMode?: boolean): IBounds
67
+ addListWithHandle(list: IObject[], boundsDataHandle: IBoundsDataHandle): IBounds
68
+ setByListWithHandle(list: IObject[], boundsDataHandle: IBoundsDataHandle, addMode: boolean): IBounds
69
+ setByPoints(points: IPointData[]): IBounds
70
70
 
71
71
  hitPoint(point: IPointData, pointMatrix?: IMatrixData): boolean
72
72
  hitRadiusPoint(point: IRadiusPointData, pointMatrix?: IMatrixData): boolean
73
73
  hit(bounds: IBoundsData, boundsMatrix?: IMatrixData): boolean
74
74
  includes(bounds: IBoundsData, boundsMatrix?: IMatrixData): boolean
75
75
 
76
+ intersect(bounds: IBoundsData, boundsMatrix?: IMatrixData): IBounds
76
77
  getIntersect(bounds: IBoundsData, boundsMatrix?: IMatrixData): IBounds
77
- setByIntersect(bounds: IBoundsData, boundsMatrix?: IMatrixData): void
78
78
 
79
79
  isSame(bounds: IBoundsData): boolean
80
80
  isEmpty(): boolean
@@ -129,12 +129,12 @@ export interface IMatrix extends IMatrixData {
129
129
  scale(x: number, y?: number): IMatrix
130
130
  rotate(angle: number): IMatrix
131
131
 
132
- times(matrix: IMatrixData): void
133
- divide(matrix: IMatrixData): void
134
- invert(): void
132
+ times(matrix: IMatrixData): IMatrix
133
+ divide(matrix: IMatrixData): IMatrix
134
+ invert(): IMatrix
135
135
 
136
- toWorldPoint(local: IPointData, world?: IPointData): void
137
- toLocalPoint(world: IPointData, local?: IPointData): void
136
+ toWorldPoint(local: IPointData, to?: IPointData): void
137
+ toLocalPoint(world: IPointData, to?: IPointData): void
138
138
  }
139
139
 
140
140
 
@@ -1,4 +1,4 @@
1
- export interface ICanvasDrawPath {
1
+ export interface IPathDrawer {
2
2
  beginPath?(): void
3
3
 
4
4
  moveTo(x: number, y: number): void
@@ -12,5 +12,5 @@ export interface ICanvasDrawPath {
12
12
  ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, counterclockwise?: boolean): void
13
13
 
14
14
  rect(x: number, y: number, width: number, height: number): void
15
- roundRect?(x: number, y: number, width: number, height: number, radius?: number | number[]): void
15
+ roundRect(x: number, y: number, width: number, height: number, radius?: number | number[]): void
16
16
  }
@@ -4,4 +4,5 @@ import { ILeaferCanvas } from '../canvas/ILeaferCanvas'
4
4
  export interface IPlatform {
5
5
  requestRender?(render: IFunction): void
6
6
  canvas?: ILeaferCanvas
7
+ isWorker?: boolean
7
8
  }
@@ -2,7 +2,6 @@ import { ILeaferCanvas } from '../canvas/ILeaferCanvas'
2
2
  import { ILeaf } from '../display/ILeaf'
3
3
  import { IBounds, IMatrix } from '../math/IMath'
4
4
  import { IFunction } from '../function/IFunction'
5
- import { ILayoutBlockData } from '../layouter/ILayouter'
6
5
 
7
6
  export interface IRenderOptions {
8
7
  bounds?: IBounds,
@@ -12,26 +11,38 @@ export interface IRenderOptions {
12
11
  }
13
12
 
14
13
  export interface IRendererConfig {
14
+ usePartRender?: boolean
15
15
  maxFPS?: number
16
16
  }
17
17
 
18
18
  export interface IRenderer {
19
- canvas: ILeaferCanvas
20
19
  target: ILeaf
21
- layoutedBlocks: ILayoutBlockData[]
22
- running: boolean
20
+ canvas: ILeaferCanvas
21
+ updateBlocks: IBounds[]
22
+
23
+ FPS: number
23
24
  totalTimes: number
24
25
  times: number
25
- config: IRendererConfig
26
26
 
27
- FPS: number
27
+ running: boolean
28
+ changed: boolean
29
+
30
+ config: IRendererConfig
28
31
 
29
32
  start(): void
30
33
  stop(): void
34
+ update(): void
31
35
 
32
36
  requestLayout(): void
37
+
33
38
  render(callback?: IFunction): void
34
- clipRender(bounds: IBounds): void
39
+ renderOnce(callback?: IFunction): void
40
+ partRender(): void
41
+ clipRender(bounds: IBounds, fullMode?: boolean): void
35
42
  fullRender(bounds?: IBounds): void
43
+
44
+ addBlock(block: IBounds): void
45
+ mergeBlocks(): void
46
+
36
47
  destroy(): void
37
48
  }
@@ -15,8 +15,8 @@ export interface ISelectPathOptions {
15
15
 
16
16
  export interface ISelector {
17
17
  target: ILeaf
18
-
19
18
  defaultPath: ILeafList
19
+
20
20
  getHitPointPath(hitPoint: IPointData, hitRadius: number, options?: ISelectPathOptions): ISelectPathResult
21
21
 
22
22
  find(name: number | string, branch?: ILeaf): ILeaf | ILeaf[]
@@ -12,11 +12,14 @@ export interface IWatcherConfig {
12
12
  export interface IWatcher {
13
13
  target: ILeaf
14
14
  updatedList: ILeafList
15
+
15
16
  totalTimes: number
16
- config: IWatcherConfig
17
+
17
18
  running: boolean
18
19
  changed: boolean
19
20
 
21
+ config: IWatcherConfig
22
+
20
23
  start(): void
21
24
  stop(): void
22
25