@leafer/interface 1.0.0-beta.9 → 1.0.0-rc.10

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.
Files changed (41) hide show
  1. package/package.json +5 -2
  2. package/src/app/IApp.ts +3 -3
  3. package/src/app/ILeafer.ts +41 -17
  4. package/src/canvas/ICanvas.ts +2 -0
  5. package/src/canvas/IHitCanvasManager.ts +0 -1
  6. package/src/canvas/ILeaferCanvas.ts +13 -9
  7. package/src/canvas/ISkiaCanvas.ts +20 -1
  8. package/src/data/IData.ts +5 -7
  9. package/src/data/ILeafData.ts +12 -6
  10. package/src/data/IList.ts +9 -6
  11. package/src/display/IBranch.ts +4 -2
  12. package/src/display/ILeaf.ts +251 -73
  13. package/src/display/IView.ts +1 -4
  14. package/src/display/module/IBranchRender.ts +2 -2
  15. package/src/display/module/ILeafBounds.ts +4 -0
  16. package/src/display/module/ILeafDataProxy.ts +5 -3
  17. package/src/display/module/ILeafHit.ts +3 -1
  18. package/src/display/module/ILeafRender.ts +1 -0
  19. package/src/event/IEvent.ts +3 -23
  20. package/src/event/IEventer.ts +6 -1
  21. package/src/event/IUIEvent.ts +18 -11
  22. package/src/file/IExport.ts +24 -0
  23. package/src/file/IFileType.ts +1 -1
  24. package/src/function/IFunction.ts +9 -0
  25. package/src/image/IImageManager.ts +13 -2
  26. package/src/image/ILeaferImage.ts +32 -1
  27. package/src/index.ts +17 -16
  28. package/src/interaction/ICursor.ts +16 -0
  29. package/src/interaction/IInteraction.ts +35 -7
  30. package/src/layout/ILeafLayout.ts +33 -15
  31. package/src/layouter/ILayouter.ts +3 -0
  32. package/src/math/IMath.ts +70 -36
  33. package/src/path/IPathDrawer.ts +5 -0
  34. package/src/platform/IPlatform.ts +21 -4
  35. package/src/plugin/IPlugin.ts +2 -2
  36. package/src/renderer/IRenderer.ts +3 -2
  37. package/src/selector/ISelector.ts +26 -9
  38. package/src/task/ITaskProcessor.ts +19 -3
  39. package/src/watcher/IWatcher.ts +5 -1
  40. package/types/index.d.ts +1859 -0
  41. package/src/display/module/ILeafMask.ts +0 -12
@@ -0,0 +1,24 @@
1
+ import { IBlob, ILeaferCanvas } from '../canvas/ILeaferCanvas'
2
+ import { IBoundsData } from '../math/IMath'
3
+
4
+
5
+ export interface IExportOptions {
6
+ quality?: number
7
+ blob?: boolean
8
+ scale?: number
9
+ pixelRatio?: number
10
+ slice?: boolean
11
+ trim?: boolean
12
+ fill?: string
13
+ screenshot?: IBoundsData | boolean
14
+ }
15
+
16
+ export interface IExportResult {
17
+ data: ILeaferCanvas | IBlob | string | boolean
18
+ renderBounds?: IBoundsData
19
+ trimBounds?: IBoundsData
20
+ }
21
+
22
+ export interface IExportResultFunction {
23
+ (data: IExportResult): void
24
+ }
@@ -1,2 +1,2 @@
1
1
  export type IExportImageType = 'jpg' | 'png' | 'webp'
2
- export type IExportFileType = IExportImageType | 'svg' | 'pdf' | 'json'
2
+ export type IExportFileType = IExportImageType | 'svg' | 'pdf' | 'json'
@@ -10,4 +10,13 @@ export interface INumberFunction {
10
10
 
11
11
  export interface IPointDataFunction {
12
12
  (...arg: any): IPointData
13
+ }
14
+
15
+
16
+ export interface IAttrDecorator {
17
+ (...arg: any): IAttrDecoratorInner
18
+ }
19
+
20
+ interface IAttrDecoratorInner {
21
+ (target: any, key: string): any
13
22
  }
@@ -1,10 +1,21 @@
1
1
  import { ILeaferImage, ILeaferImageConfig } from './ILeaferImage'
2
2
  import { ITaskProcessor } from '../task/ITaskProcessor'
3
- import { IFunction } from '../function/IFunction'
3
+ import { IExportFileType } from '../file/IFileType'
4
+
5
+ interface ILeaferImageMap {
6
+ [name: string]: ILeaferImage
7
+ }
4
8
 
5
9
  export interface IImageManager {
10
+ map: ILeaferImageMap
11
+ recycledList: ILeaferImage[]
6
12
  tasker: ITaskProcessor
13
+ patternTasker: ITaskProcessor
14
+ readonly isComplete: boolean
7
15
  get(config: ILeaferImageConfig): ILeaferImage
8
- load(image: ILeaferImage, onSuccess: IFunction, onError: IFunction): void
16
+ recycle(image: ILeaferImage): void
17
+ clearRecycled(): void
18
+ hasOpacityPixel(config: ILeaferImageConfig): boolean // png / svg / webp
19
+ isFormat(format: IExportFileType, config: ILeaferImageConfig): boolean
9
20
  destroy(): void
10
21
  }
@@ -1,8 +1,13 @@
1
+ import { ICanvasPattern } from '../canvas/ICanvas'
1
2
  import { IObject } from '../data/IData'
3
+ import { InnerId } from '../event/IEventer'
4
+ import { IExportFileType } from '../file/IFileType'
5
+ import { IMatrixData } from '../math/IMath'
2
6
 
3
7
  export interface ILeaferImageConfig {
4
8
  url: string
5
9
  thumb?: string
10
+ format?: IExportFileType
6
11
  }
7
12
 
8
13
  export interface ILeaferImageOnLoaded {
@@ -13,13 +18,39 @@ export interface ILeaferImageOnError {
13
18
  (error?: string | IObject, image?: ILeaferImage): any
14
19
  }
15
20
 
21
+ export interface ILeaferImageCacheCanvas {
22
+ data: IObject
23
+ params: IArguments
24
+ }
25
+
26
+ export interface ILeaferImagePatternPaint {
27
+ transform: IMatrixData
28
+ }
29
+
16
30
  export interface ILeaferImage {
31
+ readonly innerId: InnerId
32
+ readonly url: string
33
+
17
34
  view: unknown
18
35
  width: number
19
36
  height: number
37
+
38
+ isSVG: boolean
39
+ hasOpacityPixel: boolean
40
+
41
+ readonly completed: boolean
20
42
  ready: boolean
21
- load(onSuccess?: ILeaferImageOnLoaded, onError?: ILeaferImageOnError): Promise<void>
43
+ error: IObject
44
+ loading: boolean
45
+
46
+ use: number
47
+ config: ILeaferImageConfig
48
+
49
+ load(onSuccess?: ILeaferImageOnLoaded, onError?: ILeaferImageOnError): number
50
+ unload(index: number, stopEvent?: boolean): void
22
51
  getCanvas(width: number, height: number, opacity?: number, _filters?: IObject): unknown
52
+ getPattern(canvas: any, repeat: string | null, transform?: IMatrixData, paint?: IObject): ICanvasPattern
53
+ destroy(): void
23
54
  }
24
55
 
25
56
  export type IImageStatus = 'wait' | 'thumb-loading' | 'thumb-success' | 'thumb-error' | 'loading' | 'success' | 'error'
package/src/index.ts CHANGED
@@ -1,12 +1,12 @@
1
- export { IApp } from './app/IApp'
2
- export { ILeafer, ILeaferType, ILeaferTypeCreator, ILeaferTypeFunction, ILeaferTypeList, ILeaferConfig, ICreator, IUICreator } from './app/ILeafer'
3
- export { ILeaf, ILeafAttrData, ILeafComputedData, ILeafInputData, ICachedLeaf, IHitType, IBlendMode } from './display/ILeaf'
1
+ export { IAppBase } from './app/IApp'
2
+ export { ILeaferBase, ILeaferAttrData, ILeaferType, ILeaferTypeCreator, ILeaferTypeFunction, ILeaferTypeList, ILeaferConfig, ICreator, IUICreator } from './app/ILeafer'
3
+ export { ILeaf, ILeafAttrData, ILeafComputedData, ILeafInputData, ICachedLeaf, IHitType, IMaskType, IBlendMode, IEditSize, IImageCursor, ICursorType, IAround } from './display/ILeaf'
4
4
  export { IBranch } from './display/IBranch'
5
5
  export { IZoomView } from './display/IView'
6
6
 
7
7
 
8
- export { ILeafData, IDataProcessor } from './data/ILeafData'
9
- export { ILeafLayout, ILayoutLocationType, ILayoutBoundsType } from './layout/ILeafLayout'
8
+ export { ILeafData, IDataProcessor, ILeafDataOptions } from './data/ILeafData'
9
+ export { ILeafLayout, ILocationType, IBoundsType } from './layout/ILeafLayout'
10
10
 
11
11
  export { ILeafDataProxy, ILeafDataProxyModule } from './display/module/ILeafDataProxy'
12
12
  export { ILeafMatrix, ILeafMatrixModule } from './display/module/ILeafMatrix'
@@ -14,19 +14,18 @@ export { ILeafBounds, ILeafBoundsModule } from './display/module/ILeafBounds'
14
14
  export { ILeafHit, ILeafHitModule } from './display/module/ILeafHit'
15
15
  export { ILeafRender, ILeafRenderModule } from './display/module/ILeafRender'
16
16
  export { ILeafEventer, ILeafEventerModule } from './display/module/ILeafEventer'
17
- export { ILeafMask, ILeafMaskModule } from './display/module/ILeafMask'
18
17
  export { IBranchRender, IBranchRenderModule } from './display/module/IBranchRender'
19
18
 
20
19
  export { IRenderer, IRendererConfig, IRenderOptions } from './renderer/IRenderer'
21
20
  export { IWatcher, IWatchEventData, IWatcherConfig } from './watcher/IWatcher'
22
21
  export { ILayouter, ILayoutChangedData, ILayoutBlockData, ILayouterConfig, IPartLayoutConfig } from './layouter/ILayouter'
23
- export { ISelector, ISelectorConfig, ISelectPathResult, ISelectPathOptions } from './selector/ISelector'
22
+ export { ISelector, ISelectorConfig, ISelectorProxy, IFindMethod, IPickResult, IPickOptions, IAnswer } from './selector/ISelector'
24
23
 
25
24
  export { ICanvasManager } from './canvas/ICanvasManager'
26
25
  export { IHitCanvasManager } from './canvas/IHitCanvasManager'
27
26
  export { IImageManager } from './image/IImageManager'
28
27
 
29
- export { ITaskProcessor, ITaskProcessorConfig } from './task/ITaskProcessor'
28
+ export { ITaskProcessor, ITaskProcessorConfig, ITaskItem, ITaskOptions } from './task/ITaskProcessor'
30
29
 
31
30
 
32
31
  export { IControl } from './control/IControl'
@@ -34,22 +33,24 @@ export { IPlatform, IMiniapp, IMiniappSelect, IMiniappSizeView } from './platfor
34
33
  export { IPlugin } from './plugin/IPlugin'
35
34
 
36
35
 
37
- export { ILeaferCanvas, IHitCanvas, ICanvasAttr, ICanvasStrokeOptions, ILeaferCanvasConfig, IHitCanvasConfig, IBlobFunction, IBlob } from './canvas/ILeaferCanvas'
38
- export { ISkiaCanvas, ISkiaCanvasExportConfig, ICanvasType } from './canvas/ISkiaCanvas'
36
+ export { ILeaferCanvas, ILeaferCanvasView, IHitCanvas, ICanvasAttr, ICanvasStrokeOptions, ILeaferCanvasConfig, IHitCanvasConfig, IBlobFunction, IBlob } from './canvas/ILeaferCanvas'
37
+ export { ISkiaCanvas, ISkiaCanvasExportConfig, ICanvasType, ISkiaNAPICanvas } from './canvas/ISkiaCanvas'
39
38
  export { IPathDrawer, IPathCreator } from './path/IPathDrawer'
40
- export { IWindingRule, ICanvasContext2D, ITextMetrics, IPath2D } from './canvas/ICanvas'
39
+ export { IWindingRule, ICanvasContext2D, ITextMetrics, IPath2D, ICanvasPattern } from './canvas/ICanvas'
41
40
  export { CanvasPathCommand, IPathCommandData, MCommandData, HCommandData, VCommandData, LCommandData, CCommandData, SCommandData, QCommandData, TCommandData, ZCommandData, ACommandData, RectCommandData, RoundRectCommandData, EllipseCommandData, ArcCommandData, ArcToCommandData } from './path/IPathCommand'
42
41
 
43
- export { ILeaferImage, ILeaferImageConfig, ILeaferImageOnLoaded, ILeaferImageOnError } from './image/ILeaferImage'
42
+ export { ILeaferImage, ILeaferImageConfig, ILeaferImageOnLoaded, ILeaferImageOnError, ILeaferImageCacheCanvas, ILeaferImagePatternPaint } from './image/ILeaferImage'
44
43
  export { IExportFileType, IExportImageType } from './file/IFileType'
44
+ export { IExportOptions, IExportResult, IExportResultFunction } from './file/IExport'
45
45
 
46
46
  export { InnerId, IEventer, IEventListener, IEventListenerOptions, IEventListenerMap, IEventListenerItem, IEventListenerId } from './event/IEventer'
47
- export { IEventTarget, IEvent, ILeaferEvent, IPropertyEvent, ILayoutEvent, IRenderEvent, IAnimateEvent, IChildEvent, IResizeEvent, IResizeEventListener, IUpdateEvent, IWatchEvent, ITransformEvent, ITransformEventData, TransformMode, IMultiTouchData, IKeepTouchData } from './event/IEvent'
47
+ export { IEventTarget, IEvent, ILeaferEvent, IPropertyEvent, ILayoutEvent, IRenderEvent, IAnimateEvent, IChildEvent, IResizeEvent, IResizeEventListener, IUpdateEvent, IWatchEvent, IMultiTouchData, IKeepTouchData } from './event/IEvent'
48
48
  export { IUIEvent, IPointerEvent, PointerType, IDragEvent, IDropEvent, ISwipeEvent, IMoveEvent, IZoomEvent, IRotateEvent, IKeyEvent, IImageEvent } from './event/IUIEvent'
49
+ export { ICursorTypeMap, ICursorRotate, ICursorRotateMap } from './interaction/ICursor'
49
50
  export { IInteraction, IInteractionCanvas, IInteractionConfig, IWheelConfig, IPointerConfig } from './interaction/IInteraction'
50
51
 
51
52
 
52
- export { __Number, __Boolean, __String, __Object, __Value, IPathString, ITimer, IObject, INumberMap, IStringMap, IBooleanMap, IDataTypeHandle } from './data/IData'
53
+ export { INumber, IBoolean, IString, IValue, IPathString, ITimer, IObject, INumberMap, IStringMap, IBooleanMap, IDataTypeHandle } from './data/IData'
53
54
  export { ILeafList, ILeafArrayMap, ILeafMap, ILeafLevelList, ILeafListItemCallback } from './data/IList'
54
- export { IPoint, IPointData, IRadiusPointData, ISize, ISizeData, IScreenSizeData, IBounds, IBoundsData, IBoundsDataHandle, IOffsetBoundsData, ITwoPointBounds, ITwoPointBoundsData, IAutoBounds, IAutoBoundsData, IMatrix, IMatrixData, IMatrixWithBoundsData, IMatrixDecompositionData, IMatrixDecompositionAttr } from './math/IMath'
55
- export { IFunction } from './function/IFunction'
55
+ export { IPoint, IPointData, IRadiusPointData, ISize, ISizeData, IScreenSizeData, IBounds, IBoundsData, IBoundsDataFn, IOffsetBoundsData, ITwoPointBoundsData, IAutoBounds, IAutoBoundsData, IMatrix, IMatrixData, IMatrixWithBoundsData, IMatrixWithScaleData, IMatrixWithOptionScaleData, IMatrixWithBoundsScaleData, IMatrixWithLayoutData, IScaleRotationData, IScaleData, ISkewData, ILayoutBoundsData, ILayoutData, ILayoutAttr } from './math/IMath'
56
+ export { IFunction, IAttrDecorator } from './function/IFunction'
@@ -0,0 +1,16 @@
1
+ import { ICursorType } from '../display/ILeaf'
2
+
3
+
4
+ export interface ICursorTypeMap {
5
+ [name: string]: ICursorType | ICursorType[]
6
+ }
7
+
8
+
9
+ export interface ICursorRotate {
10
+ rotation?: number
11
+ data?: string
12
+ }
13
+
14
+ export interface ICursorRotateMap {
15
+ [name: string]: ICursorRotate
16
+ }
@@ -1,9 +1,9 @@
1
1
  import { INumberFunction, IPointDataFunction } from '../function/IFunction'
2
- import { IPointerEvent, IMoveEvent, IZoomEvent, IRotateEvent, IUIEvent } from '../event/IUIEvent'
3
- import { ILeaf } from '../display/ILeaf'
2
+ import { IPointerEvent, IMoveEvent, IZoomEvent, IRotateEvent, IUIEvent, IKeyEvent } from '../event/IUIEvent'
3
+ import { ILeaf, ICursorType } from '../display/ILeaf'
4
4
  import { ILeafList } from '../data/IList'
5
5
  import { IPointData } from '../math/IMath'
6
- import { ISelector } from '../selector/ISelector'
6
+ import { ISelector, IPickOptions } from '../selector/ISelector'
7
7
  import { IBounds } from '../math/IMath'
8
8
  import { IControl } from '../control/IControl'
9
9
  import { IKeepTouchData } from '../event/IEvent'
@@ -17,21 +17,27 @@ export interface IInteraction extends IControl {
17
17
 
18
18
  running: boolean
19
19
  readonly dragging: boolean
20
+ readonly isDragEmpty: boolean
21
+ readonly isHoldRightKey: boolean
22
+ readonly moveMode: boolean
20
23
 
21
24
  config: IInteractionConfig
22
25
 
26
+ cursor: ICursorType | ICursorType[]
23
27
  readonly hitRadius: number
28
+
24
29
  shrinkCanvasBounds: IBounds
25
30
 
26
31
  downData: IPointerEvent
32
+ hoverData: IPointerEvent
27
33
  downTime: number
28
34
 
29
35
  receive(event: any): void
30
36
 
31
- pointerDown(data: IPointerEvent): void
32
- pointerMove(data: IPointerEvent): void
37
+ pointerDown(data?: IPointerEvent, defaultPath?: boolean): void
38
+ pointerMove(data?: IPointerEvent): void
33
39
  pointerMoveReal(data: IPointerEvent): void
34
- pointerUp(data: IPointerEvent): void
40
+ pointerUp(data?: IPointerEvent): void
35
41
  pointerCancel(): void
36
42
 
37
43
  multiTouch(data: IUIEvent, list: IKeepTouchData[]): void
@@ -40,6 +46,18 @@ export interface IInteraction extends IControl {
40
46
  zoom(data: IZoomEvent): void
41
47
  rotate(data: IRotateEvent): void
42
48
 
49
+ keyDown(data: IKeyEvent): void
50
+ keyUp(data: IKeyEvent): void
51
+
52
+ findPath(data: IPointerEvent, options?: IPickOptions): ILeafList
53
+ isDrag(leaf: ILeaf): boolean
54
+
55
+ updateDownData(data?: IPointerEvent, options?: IPickOptions): void
56
+ updateHoverData(data: IPointerEvent): void
57
+
58
+ updateCursor(hoverData?: IPointerEvent): void
59
+ setCursor(cursor: ICursorType | ICursorType[]): void
60
+
43
61
  emit(type: string, data: IUIEvent, path?: ILeafList, excludePath?: ILeafList): void
44
62
  }
45
63
 
@@ -50,6 +68,7 @@ export interface IInteractionCanvas extends ILeaferCanvas {
50
68
  export interface IInteractionConfig {
51
69
  wheel?: IWheelConfig
52
70
  pointer?: IPointerConfig
71
+ cursor?: ICursorConfig
53
72
  zoom?: IZoomConfig
54
73
  move?: IMoveConfig
55
74
  eventer?: IObject
@@ -61,13 +80,17 @@ export interface IZoomConfig {
61
80
  }
62
81
 
63
82
  export interface IMoveConfig {
83
+ holdSpaceKey?: boolean
84
+ holdMiddleKey?: boolean
85
+ holdRightKey?: boolean
86
+ drag?: boolean
64
87
  dragEmpty?: boolean
65
88
  dragOut?: boolean
66
89
  autoDistance?: number
67
90
  }
68
91
 
69
92
  export interface IWheelConfig {
70
- zoomMode?: boolean
93
+ zoomMode?: boolean | 'mouse'
71
94
  zoomSpeed?: number // 取值范围 0 ~ 1, 默认0.5
72
95
  moveSpeed?: number
73
96
  rotateSpeed?: number // 取值范围 0 ~ 1, 默认0.5
@@ -89,4 +112,9 @@ export interface IPointerConfig {
89
112
  swipeDistance?: number
90
113
  ignoreMove?: boolean // 性能优化字段, 控制move事件触发次数
91
114
  preventDefault?: boolean
115
+ preventDefaultMenu?: boolean
116
+ }
117
+
118
+ export interface ICursorConfig {
119
+ stop?: boolean
92
120
  }
@@ -1,16 +1,16 @@
1
- import { IBoundsData, IMatrixData, IMatrixDecompositionData } from '../math/IMath'
1
+ import { IBoundsData, IMatrixData, ILayoutBoundsData, IPointData } from '../math/IMath'
2
2
  import { ILeaf } from '../display/ILeaf'
3
3
 
4
- export type ILayoutLocationType = 'world' | 'local' | 'inner'
5
- export type ILayoutBoundsType = 'content' | 'box' | 'stroke' | 'margin' | 'render'
4
+ export type ILocationType = 'world' | 'local' | 'inner'
5
+ export type IBoundsType = 'content' | 'box' | 'stroke' | 'margin' | 'render'
6
6
 
7
7
  export interface ILeafLayout {
8
8
 
9
9
  leaf: ILeaf
10
10
 
11
- useZoomProxy: boolean
11
+ proxyZoom: boolean
12
12
 
13
- // local
13
+ // inner
14
14
 
15
15
  boxBounds: IBoundsData // | content + padding |
16
16
  strokeBounds: IBoundsData // | boxBounds + border |
@@ -23,17 +23,17 @@ export interface ILeafLayout {
23
23
  // local
24
24
 
25
25
  //localBoxBounds: IBoundsData = leaf.__local
26
- localStrokeBounds: IBoundsData
27
- localRenderBounds: IBoundsData
26
+ localStrokeBounds?: IBoundsData
27
+ localRenderBounds?: IBoundsData
28
28
 
29
29
  // state
30
+ resized: boolean
31
+ waitAutoLayout: boolean
30
32
 
31
33
  // matrix changed
32
34
  matrixChanged: boolean // include positionChanged scaleChanged skewChanged
33
- positionChanged: boolean // x, y
34
- originChanged?: boolean // originX originY
35
35
  scaleChanged: boolean // scaleX scaleY
36
- rotationChanged: boolean // rotaiton, skewX scaleY 数据更新
36
+ rotationChanged: boolean // rotaiton, skewX skewY 数据更新
37
37
 
38
38
  // bounds changed
39
39
  boundsChanged: boolean
@@ -55,17 +55,33 @@ export interface ILeafLayout {
55
55
  // keep state
56
56
  affectScaleOrRotation: boolean
57
57
  affectRotation: boolean
58
+ affectChildrenSort?: boolean
58
59
 
59
60
  strokeSpread: number
60
61
  renderSpread: number
61
62
  strokeBoxSpread: number
62
63
  renderShapeSpread: number
63
64
 
64
- checkUpdate(force?: boolean): void
65
+ // temp local
66
+ a: number
67
+ b: number
68
+ c: number
69
+ d: number
70
+ e: number
71
+ f: number
72
+ x: number
73
+ y: number
74
+ width: number
75
+ height: number
76
+
77
+ createLocal(): void
65
78
 
66
- getTransform(locationType: ILayoutLocationType): IMatrixData
67
- decomposeTransform(locationType: ILayoutLocationType): IMatrixDecompositionData
68
- getBounds(type: ILayoutBoundsType, locationType: ILayoutLocationType): IBoundsData
79
+ update(): void
80
+
81
+ getTransform(relative?: ILocationType | ILeaf): IMatrixData
82
+ getBounds(type?: IBoundsType, relative?: ILocationType | ILeaf): IBoundsData
83
+ getLayoutBounds(type?: IBoundsType, relative?: ILocationType | ILeaf, unscale?: boolean): ILayoutBoundsData
84
+ getLayoutPoints(type?: IBoundsType, relative?: ILocationType | ILeaf): IPointData[]
69
85
 
70
86
  // 独立 / 引用 boxBounds
71
87
  spreadStroke(): void
@@ -80,13 +96,15 @@ export interface ILeafLayout {
80
96
  renderChange(): void
81
97
 
82
98
  // matrix
83
- positionChange(): void
84
99
  scaleChange(): void
85
100
  rotationChange(): void
101
+ matrixChange(): void
86
102
 
87
103
  // face
88
104
  surfaceChange(): void
89
105
  opacityChange(): void
90
106
 
107
+ childrenSortChange(): void
108
+
91
109
  destroy(): void
92
110
  }
@@ -34,6 +34,7 @@ export interface ILayouterConfig {
34
34
  export interface ILayouter extends IControl {
35
35
  target: ILeaf
36
36
  layoutedBlocks: ILayoutBlockData[]
37
+ extraBlock: ILayoutBlockData
37
38
 
38
39
  totalTimes: number
39
40
  times: number
@@ -54,6 +55,8 @@ export interface ILayouter extends IControl {
54
55
  partLayout(): void
55
56
  fullLayout(): void
56
57
 
58
+ addExtra(leaf: ILeaf): void
59
+
57
60
  createBlock(data: ILeafList | ILeaf[]): ILayoutBlockData
58
61
  getBlocks(list: ILeafList): ILayoutBlockData[]
59
62
  addBlocks(current: ILayoutBlockData[]): void
package/src/math/IMath.ts CHANGED
@@ -6,21 +6,28 @@ export interface IPointData {
6
6
  }
7
7
 
8
8
  export interface IPoint extends IPointData {
9
- set(x?: number, y?: number): void
10
- copy(point: IPointData): IPoint
9
+ set(x?: number | IPointData, y?: number): IPoint
10
+ get(): IPointData
11
11
  clone(): IPoint
12
12
 
13
- rotate(angle: number, center?: IPointData): IPoint
13
+ move(x: number, y: number): IPoint
14
+ scale(scaleX: number, scaleY?: number): IPoint
15
+ scaleOf(origin: IPointData, scaleX: number, scaleY?: number): IPoint
16
+ rotate(rotation: number, origin?: IPointData): IPoint
17
+ rotateOf(origin: IPointData, rotation: number): IPoint
18
+ getRotation(origin: IPointData, to: IPointData, toOrigin?: IPointData): number
14
19
 
15
20
  toInnerOf(matrix: IMatrixData, to?: IPointData): IPoint
16
21
  toOuterOf(matrix: IMatrixData, to?: IPointData): IPoint
17
22
 
18
- getCenter(to: IPointData): IPointData
23
+ getCenter(to: IPointData): IPoint
19
24
  getDistance(to: IPointData): number
25
+ getDistancePoint(to: IPointData, distance: number): IPoint
26
+
20
27
  getAngle(to: IPointData): number
21
28
  getAtan2(to: IPointData): number
22
29
 
23
- reset(): void
30
+ reset(): IPoint
24
31
  }
25
32
 
26
33
  export interface IRadiusPointData extends IPointData {
@@ -47,31 +54,38 @@ export interface IOffsetBoundsData extends IBoundsData {
47
54
  offsetY: number
48
55
  }
49
56
 
50
- export interface IBoundsDataHandle {
57
+ export interface IBoundsDataFn {
51
58
  (target: any): IBoundsData
52
59
  }
53
60
 
54
- export interface IBounds extends IBoundsData {
55
- set(x?: number, y?: number, width?: number, height?: number): void
56
- copy(bounds: IBoundsData): IBounds
61
+ export interface IBounds extends IBoundsData, ITwoPointBoundsData {
62
+ set(x?: number | IBoundsData, y?: number, width?: number, height?: number): IBounds
63
+ get(): IBoundsData
57
64
  clone(): IBounds
58
65
 
59
- scale(scale: number): IBounds
66
+ move(x: number, y: number): IBounds
67
+ scale(scaleX: number, scaleY?: number): IBounds
68
+ scaleOf(origin: IPointData, scaleX: number, scaleY?: number): IBounds
60
69
  toOuterOf(matrix: IMatrixData, to?: IBoundsData): IBounds
70
+ toInnerOf(matrix: IMatrixData, to?: IBoundsData): IBounds
61
71
  getFitMatrix(put: IBoundsData): IMatrix
62
72
 
63
- spread(size: number): IBounds
73
+ spread(spreadX: number, spreadY?: number): IBounds
64
74
  ceil(): IBounds
75
+ unsign(): IBounds
76
+ float(maxLength?: number): IBounds
65
77
 
66
78
  add(bounds: IBoundsData): IBounds
67
- addList(boundsList: IBounds[]): IBounds
68
- setByList(boundsList: IBounds[], addMode?: boolean): IBounds
69
- addListWithHandle(list: IObject[], boundsDataHandle: IBoundsDataHandle): IBounds
70
- setByListWithHandle(list: IObject[], boundsDataHandle: IBoundsDataHandle, addMode: boolean): IBounds
71
- setByPoints(points: IPointData[]): IBounds
79
+ addList(boundsList: IBoundsData[]): IBounds
80
+ setList(boundsList: IBoundsData[]): IBounds
81
+ addListWithFn(list: IObject[], boundsDataHandle: IBoundsDataFn): IBounds
82
+ setListWithFn(list: IObject[], boundsDataHandle: IBoundsDataFn): IBounds
83
+
84
+ setPoints(points: IPointData[]): IBounds
85
+ getPoints(): IPointData[] // topLeft, topRight, bottomRight, bottomLeft
72
86
 
73
87
  hitPoint(point: IPointData, pointMatrix?: IMatrixData): boolean
74
- hitRadiusPoint(point: IRadiusPointData, pointMatrix?: IMatrixData): boolean
88
+ hitRadiusPoint(point: IRadiusPointData, pointMatrix?: IMatrixWithLayoutData): boolean
75
89
  hit(bounds: IBoundsData, boundsMatrix?: IMatrixData): boolean
76
90
  includes(bounds: IBoundsData, boundsMatrix?: IMatrixData): boolean
77
91
 
@@ -90,12 +104,6 @@ export interface ITwoPointBoundsData {
90
104
  maxY: number
91
105
  }
92
106
 
93
- export interface ITwoPointBounds extends ITwoPointBoundsData {
94
- addPoint(x: number, y: number): void
95
- addBounds(x: number, y: number, width: number, height: number): void
96
- add(pointBounds: ITwoPointBoundsData): void
97
- }
98
-
99
107
 
100
108
  export interface IAutoBoundsData {
101
109
  top?: number
@@ -124,17 +132,24 @@ export interface IMatrixData {
124
132
  f: number
125
133
  }
126
134
 
127
- export interface IMatrixDecompositionData {
128
- x: number
129
- y: number
135
+ export interface IScaleData {
130
136
  scaleX: number
131
137
  scaleY: number
138
+ }
139
+
140
+ export interface IScaleRotationData extends IScaleData {
132
141
  rotation: number
142
+ }
143
+
144
+ export interface ISkewData {
133
145
  skewX: number
134
146
  skewY: number
135
147
  }
136
148
 
137
- export type IMatrixDecompositionAttr =
149
+ export interface ILayoutData extends IScaleRotationData, ISkewData, IPointData {
150
+ }
151
+
152
+ export type ILayoutAttr =
138
153
  | 'x'
139
154
  | 'y'
140
155
  | 'scaleX'
@@ -143,9 +158,13 @@ export type IMatrixDecompositionAttr =
143
158
  | 'skewX'
144
159
  | 'skewY'
145
160
 
161
+
162
+ export interface ILayoutBoundsData extends ILayoutData, IBoundsData {
163
+ }
146
164
  export interface IMatrix extends IMatrixData {
147
- set(a: number, b: number, c: number, d: number, e: number, f: number): void
148
- copy(matrix: IMatrixData): IMatrix
165
+
166
+ set(a: number | IMatrixData, b: number, c: number, d: number, e: number, f: number): IMatrix
167
+ get(): IMatrixData
149
168
  clone(): IMatrix
150
169
 
151
170
  translate(x: number, y: number): IMatrix
@@ -163,18 +182,33 @@ export interface IMatrix extends IMatrixData {
163
182
  skewOfOuter(origin: IPointData, x: number, y?: number): IMatrix
164
183
  skewOfInner(origin: IPointData, x: number, y?: number): IMatrix
165
184
 
166
- multiply(matrix: IMatrixData): IMatrix
167
- divide(matrix: IMatrixData): IMatrix
168
- preMultiply(matrix: IMatrixData): IMatrix
185
+ multiply(child: IMatrixData): IMatrix
186
+ multiplyParent(parent: IMatrixData): IMatrix
187
+
188
+ divide(child: IMatrixData): IMatrix
189
+ divideParent(parent: IMatrixData): IMatrix
169
190
  invert(): IMatrix
170
191
 
171
- toOuterPoint(inner: IPointData, to?: IPointData): void
172
- toInnerPoint(outer: IPointData, to?: IPointData): void
192
+ toOuterPoint(inner: IPointData, to?: IPointData, distance?: boolean): void
193
+ toInnerPoint(outer: IPointData, to?: IPointData, distance?: boolean): void
194
+
195
+ setLayout(data: ILayoutData, origin?: IPointData): IMatrix
196
+ getLayout(origin?: IPointData, firstSkewY?: boolean): ILayoutData
173
197
 
174
- decompose(): IMatrixDecompositionData
198
+ withScale(scaleX?: number, scaleY?: number): IMatrixWithScaleData
175
199
 
176
200
  reset(): void
177
201
  }
178
202
 
179
-
180
203
  export interface IMatrixWithBoundsData extends IMatrixData, IBoundsData { }
204
+
205
+ export interface IMatrixWithScaleData extends IMatrixData, IScaleData { }
206
+
207
+ export interface IMatrixWithOptionScaleData extends IMatrixData {
208
+ scaleX?: number
209
+ scaleY?: number
210
+ }
211
+
212
+ export interface IMatrixWithBoundsScaleData extends IMatrixData, IBoundsData, IScaleData { }
213
+
214
+ export interface IMatrixWithLayoutData extends IMatrixData, ILayoutBoundsData { }
@@ -33,4 +33,9 @@ export interface IPathCreator {
33
33
 
34
34
  rect(x: number, y: number, width: number, height: number): IPathCreator
35
35
  roundRect(x: number, y: number, width: number, height: number, radius?: number | number[]): IPathCreator
36
+
37
+ // new
38
+ drawEllipse(x: number, y: number, radiusX: number, radiusY: number, rotation?: number, startAngle?: number, endAngle?: number, anticlockwise?: boolean): IPathCreator
39
+ drawArc(x: number, y: number, radius: number, startAngle?: number, endAngle?: number, anticlockwise?: boolean): IPathCreator
40
+ drawPoints(points: number[], curve?: boolean | number, close?: boolean): IPathCreator
36
41
  }