@leafer/interface 1.0.5 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer/interface",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "@leafer/interface",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -16,7 +16,7 @@ import { ILeafHit } from './module/ILeafHit'
16
16
  import { ILeafRender } from './module/ILeafRender'
17
17
  import { ILeafData } from '../data/ILeafData'
18
18
  import { IFindMethod } from '../selector/ISelector'
19
- import { IPathCommandData } from '../path/IPathCommand'
19
+ import { IPathCommandObject, IPathCommandData } from '../path/IPathCommand'
20
20
  import { IWindingRule, IPath2D } from '../canvas/ICanvas'
21
21
  import { IJSONOptions } from '../file/IExport'
22
22
  import { IMotionPathData } from '../path/IPathData'
@@ -246,7 +246,7 @@ export interface ILeafAttrData {
246
246
  lazy?: IBoolean
247
247
  pixelRatio?: INumber
248
248
 
249
- path?: IPathCommandData | IPathString
249
+ path?: IPathCommandData | IPathCommandObject[] | IPathString
250
250
  windingRule?: IWindingRule
251
251
  closed?: IBoolean
252
252
 
@@ -665,7 +665,7 @@ export interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix,
665
665
  children?: ILeaf[]
666
666
 
667
667
  __updateSortChildren(): void
668
- add(child: ILeaf | ILeafInputData, index?: number): void
668
+ add(child: ILeaf | ILeaf[] | ILeafInputData | ILeafInputData[], index?: number): void
669
669
  remove(child?: ILeaf | number | string | IFindMethod, destroy?: boolean): void
670
670
  dropTo(parent: ILeaf, index?: number, resize?: boolean): void
671
671
  }
package/src/index.ts CHANGED
@@ -38,7 +38,7 @@ export { ISkiaCanvas, ISkiaCanvasExportConfig, ICanvasType, ISkiaNAPICanvas } fr
38
38
  export { IPathDrawer, IPathCreator } from './path/IPathDrawer'
39
39
  export { IMotionPathData } from './path/IPathData'
40
40
  export { IWindingRule, ICanvasContext2D, ICanvasContext2DSettings, ITextMetrics, IPath2D, ICanvasPattern } from './canvas/ICanvas'
41
- export { CanvasPathCommand, IPathCommandData, MCommandData, HCommandData, VCommandData, LCommandData, CCommandData, SCommandData, QCommandData, TCommandData, ZCommandData, ACommandData, RectCommandData, RoundRectCommandData, EllipseCommandData, ArcCommandData, ArcToCommandData } from './path/IPathCommand'
41
+ export { CanvasPathCommand, IPathCommandData, MCommandData, HCommandData, VCommandData, LCommandData, CCommandData, SCommandData, QCommandData, TCommandData, ZCommandData, ACommandData, RectCommandData, RoundRectCommandData, EllipseCommandData, ArcCommandData, ArcToCommandData, MoveToCommandObject, LineToCommandObject, BezierCurveToCommandObject, QuadraticCurveToCommandObject, IPathCommandObject } from './path/IPathCommand'
42
42
 
43
43
  export { ILeaferImage, ILeaferImageConfig, ILeaferImageOnLoaded, ILeaferImageOnError, ILeaferImageCacheCanvas, ILeaferImagePatternPaint } from './image/ILeaferImage'
44
44
  export { IExportFileType, IExportImageType } from './file/IFileType'
@@ -48,3 +48,40 @@ export type ArcToCommandData = [Command, x1, y1, x2, y2, radius]
48
48
  export type CanvasPathCommand = 1 | 2 | 5 | 7 | 11 // M | L | C | Q | Z canvas可以绘制的命令
49
49
 
50
50
  export type IPathCommandData = number[] // ...(MCommandData | LCommandData | CCommandData | QCommandData | ZCommandData)
51
+
52
+
53
+ // 路径命令对象
54
+ export interface MoveToCommandObject {
55
+ name: 'M'
56
+ x: number
57
+ y: number
58
+ }
59
+ export interface LineToCommandObject {
60
+ name: 'L'
61
+ x: number
62
+ y: number
63
+ }
64
+
65
+ export interface BezierCurveToCommandObject {
66
+ name: 'C'
67
+ x1: number
68
+ y1: number
69
+ x2: number
70
+ y2: number
71
+ x: number
72
+ y: number
73
+ }
74
+
75
+ export interface QuadraticCurveToCommandObject {
76
+ name: 'Q'
77
+ x1: number
78
+ y1: number
79
+ x: number
80
+ y: number
81
+ }
82
+
83
+ export interface ClosePathCommandObject {
84
+ name: 'Z'
85
+ }
86
+
87
+ export type IPathCommandObject = MoveToCommandObject | LineToCommandObject | BezierCurveToCommandObject | QuadraticCurveToCommandObject | ClosePathCommandObject // M | L | C | Q | Z canvas可以绘制的命令
@@ -4,8 +4,8 @@ export interface IPathDrawer {
4
4
 
5
5
  moveTo(x: number, y: number): void
6
6
  lineTo(x: number, y: number): void
7
- bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void
8
- quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void
7
+ bezierCurveTo(x1: number, y1: number, x2: number, y2: number, x: number, y: number): void
8
+ quadraticCurveTo(x1: number, y1: number, x: number, y: number): void
9
9
  closePath(): void
10
10
 
11
11
  arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void
@@ -24,8 +24,8 @@ export interface IPathCreator extends IPathDrawer {
24
24
 
25
25
  moveTo(x: number, y: number): IPathCreator
26
26
  lineTo(x: number, y: number): IPathCreator
27
- bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): IPathCreator
28
- quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): IPathCreator
27
+ bezierCurveTo(x1: number, y1: number, x2: number, y2: number, x: number, y: number): IPathCreator
28
+ quadraticCurveTo(x1: number, y1: number, x: number, y: number): IPathCreator
29
29
  closePath(): IPathCreator
30
30
 
31
31
  arc(x: number, y: number, radius: number, startAngle?: number, endAngle?: number, anticlockwise?: boolean): IPathCreator
package/types/index.d.ts CHANGED
@@ -770,13 +770,43 @@ type ArcCommandData = [Command, x, y, radius, startAngle, endAngle, anticlockwis
770
770
  type ArcToCommandData = [Command, x1, y1, x2, y2, radius];
771
771
  type CanvasPathCommand = 1 | 2 | 5 | 7 | 11;
772
772
  type IPathCommandData = number[];
773
+ interface MoveToCommandObject {
774
+ name: 'M';
775
+ x: number;
776
+ y: number;
777
+ }
778
+ interface LineToCommandObject {
779
+ name: 'L';
780
+ x: number;
781
+ y: number;
782
+ }
783
+ interface BezierCurveToCommandObject {
784
+ name: 'C';
785
+ x1: number;
786
+ y1: number;
787
+ x2: number;
788
+ y2: number;
789
+ x: number;
790
+ y: number;
791
+ }
792
+ interface QuadraticCurveToCommandObject {
793
+ name: 'Q';
794
+ x1: number;
795
+ y1: number;
796
+ x: number;
797
+ y: number;
798
+ }
799
+ interface ClosePathCommandObject {
800
+ name: 'Z';
801
+ }
802
+ type IPathCommandObject = MoveToCommandObject | LineToCommandObject | BezierCurveToCommandObject | QuadraticCurveToCommandObject | ClosePathCommandObject;
773
803
 
774
804
  interface IPathDrawer {
775
805
  beginPath?(): void;
776
806
  moveTo(x: number, y: number): void;
777
807
  lineTo(x: number, y: number): void;
778
- bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void;
779
- quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void;
808
+ bezierCurveTo(x1: number, y1: number, x2: number, y2: number, x: number, y: number): void;
809
+ quadraticCurveTo(x1: number, y1: number, x: number, y: number): void;
780
810
  closePath(): void;
781
811
  arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void;
782
812
  arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void;
@@ -790,8 +820,8 @@ interface IPathCreator extends IPathDrawer {
790
820
  beginPath(): IPathCreator;
791
821
  moveTo(x: number, y: number): IPathCreator;
792
822
  lineTo(x: number, y: number): IPathCreator;
793
- bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): IPathCreator;
794
- quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): IPathCreator;
823
+ bezierCurveTo(x1: number, y1: number, x2: number, y2: number, x: number, y: number): IPathCreator;
824
+ quadraticCurveTo(x1: number, y1: number, x: number, y: number): IPathCreator;
795
825
  closePath(): IPathCreator;
796
826
  arc(x: number, y: number, radius: number, startAngle?: number, endAngle?: number, anticlockwise?: boolean): IPathCreator;
797
827
  arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): IPathCreator;
@@ -1337,7 +1367,7 @@ interface ILeafAttrData {
1337
1367
  around?: IAlign | IUnitPointData;
1338
1368
  lazy?: IBoolean;
1339
1369
  pixelRatio?: INumber;
1340
- path?: IPathCommandData | IPathString;
1370
+ path?: IPathCommandData | IPathCommandObject[] | IPathString;
1341
1371
  windingRule?: IWindingRule;
1342
1372
  closed?: IBoolean;
1343
1373
  flow?: IFlowType;
@@ -1631,7 +1661,7 @@ interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix, ILeafDa
1631
1661
  __emitLifeEvent(type: string): void;
1632
1662
  children?: ILeaf[];
1633
1663
  __updateSortChildren(): void;
1634
- add(child: ILeaf | ILeafInputData, index?: number): void;
1664
+ add(child: ILeaf | ILeaf[] | ILeafInputData | ILeafInputData[], index?: number): void;
1635
1665
  remove(child?: ILeaf | number | string | IFindMethod, destroy?: boolean): void;
1636
1666
  dropTo(parent: ILeaf, index?: number, resize?: boolean): void;
1637
1667
  }
@@ -2139,4 +2169,4 @@ interface ICursorRotateMap {
2139
2169
  [name: string]: ICursorRotate;
2140
2170
  }
2141
2171
 
2142
- export type { ACommandData, ArcCommandData, ArcToCommandData, CCommandData, CanvasPathCommand, EllipseCommandData, HCommandData, IAlign, IAnimateEvent, IAnswer, IAppBase, IAround, IAttrDecorator, IAutoBounds, IAutoBoundsData, IAutoBoxData, IAutoSize, IAxis, IAxisAlign, IAxisReverse, IBaseLineAlign, IBlendMode, IBlob, IBlobFunction, IBoolean, IBooleanMap, IBounds, IBoundsData, IBoundsDataFn, IBoundsType, IBranch, IBranchRender, IBranchRenderModule, ICachedLeaf, ICanvasAttr, ICanvasCacheOptions, ICanvasContext2D, ICanvasContext2DSettings, ICanvasManager, ICanvasPattern, ICanvasStrokeOptions, ICanvasType, IChildEvent, IClientPointData, IConstraint, IConstraintType, IControl, ICreator, ICursorRotate, ICursorRotateMap, ICursorType, ICursorTypeMap, IDataProcessor, IDataTypeHandle, IDirection, IDirection4, IDragEvent, IDropEvent, IEditSize, IEraserType, IEvent, IEventListener, IEventListenerId, IEventListenerItem, IEventListenerMap, IEventListenerOptions, IEventMap, IEventOption, IEventTarget, IEventer, IExportFileType, IExportImageType, IExportOnCanvasFunction, IExportOptions, IExportResult, IExportResultFunction, IFindCondition, IFindMethod, IFlowAlign, IFlowAxisAlign, IFlowBoxType, IFlowType, IFlowWrap, IFourNumber, IFromToData, IFunction, IFunctionMap, IGap, IHitCanvas, IHitCanvasConfig, IHitCanvasManager, IHitType, IImageCursor, IImageEvent, IImageManager, IInteraction, IInteractionCanvas, IInteractionConfig, IJSONOptions, IKeepTouchData, IKeyEvent, ILayoutAttr, ILayoutBlockData, ILayoutBoundsData, ILayoutChangedData, ILayoutData, ILayoutEvent, ILayouter, ILayouterConfig, ILeaf, ILeafArrayMap, ILeafAttrData, ILeafAttrDescriptor, ILeafAttrDescriptorFn, ILeafBounds, ILeafBoundsModule, ILeafComputedData, ILeafData, ILeafDataOptions, ILeafDataProxy, ILeafDataProxyModule, ILeafEventer, ILeafEventerModule, ILeafHit, ILeafHitModule, ILeafInputData, ILeafLayout, ILeafLevelList, ILeafList, ILeafListItemCallback, ILeafMap, ILeafMatrix, ILeafMatrixModule, ILeafRender, ILeafRenderModule, ILeaferAttrData, ILeaferBase, ILeaferCanvas, ILeaferCanvasConfig, ILeaferCanvasView, ILeaferConfig, ILeaferEvent, ILeaferImage, ILeaferImageCacheCanvas, ILeaferImageConfig, ILeaferImageOnError, ILeaferImageOnLoaded, ILeaferImagePatternPaint, ILeaferType, ILeaferTypeCreator, ILeaferTypeFunction, ILeaferTypeList, ILocationType, IMaskType, IMatrix, IMatrixData, IMatrixWithBoundsData, IMatrixWithBoundsScaleData, IMatrixWithLayoutData, IMatrixWithOptionScaleData, IMatrixWithScaleData, IMiniapp, IMiniappSelect, IMiniappSizeView, IMotionPathData, IMoveEvent, IMultiTouchConfig, IMultiTouchData, INumber, INumberFunction, INumberMap, IObject, IObjectFunction, IOffsetBoundsData, IPartLayoutConfig, IPath2D, IPathCommandData, IPathCreator, IPathDrawer, IPathString, IPercentData, IPickBottom, IPickOptions, IPickResult, IPlatform, IPlugin, IPoint, IPointData, IPointDataFunction, IPointDataMap, IPointGap, IPointerConfig, IPointerEvent, IPropertyEvent, IRadiusPointData, IRangeSize, IRenderEvent, IRenderOptions, IRenderer, IRendererConfig, IResizeEvent, IResizeEventListener, IRotateEvent, IRotationPointData, IScaleData, IScaleRotationData, IScreenSizeData, IScrollPointData, ISelector, ISelectorConfig, ISelectorProxy, ISide, ISize, ISizeData, ISkewData, ISkiaCanvas, ISkiaCanvasExportConfig, ISkiaNAPICanvas, IStateStyleType, IString, IStringFunction, IStringMap, ISwipeEvent, ITaskItem, ITaskOptions, ITaskProcessor, ITaskProcessorConfig, ITextMetrics, ITimer, ITouchConfig, ITwoPointBoundsData, IUICreator, IUIEvent, IUnitData, IUnitPointData, IUpdateEvent, IValue, IWatchEvent, IWatchEventData, IWatcher, IWatcherConfig, IWheelConfig, IWindingRule, IZoomEvent, IZoomType, IZoomView, InnerId, LCommandData, MCommandData, PointerType, QCommandData, RectCommandData, RoundRectCommandData, SCommandData, TCommandData, VCommandData, ZCommandData };
2172
+ export type { ACommandData, ArcCommandData, ArcToCommandData, BezierCurveToCommandObject, CCommandData, CanvasPathCommand, EllipseCommandData, HCommandData, IAlign, IAnimateEvent, IAnswer, IAppBase, IAround, IAttrDecorator, IAutoBounds, IAutoBoundsData, IAutoBoxData, IAutoSize, IAxis, IAxisAlign, IAxisReverse, IBaseLineAlign, IBlendMode, IBlob, IBlobFunction, IBoolean, IBooleanMap, IBounds, IBoundsData, IBoundsDataFn, IBoundsType, IBranch, IBranchRender, IBranchRenderModule, ICachedLeaf, ICanvasAttr, ICanvasCacheOptions, ICanvasContext2D, ICanvasContext2DSettings, ICanvasManager, ICanvasPattern, ICanvasStrokeOptions, ICanvasType, IChildEvent, IClientPointData, IConstraint, IConstraintType, IControl, ICreator, ICursorRotate, ICursorRotateMap, ICursorType, ICursorTypeMap, IDataProcessor, IDataTypeHandle, IDirection, IDirection4, IDragEvent, IDropEvent, IEditSize, IEraserType, IEvent, IEventListener, IEventListenerId, IEventListenerItem, IEventListenerMap, IEventListenerOptions, IEventMap, IEventOption, IEventTarget, IEventer, IExportFileType, IExportImageType, IExportOnCanvasFunction, IExportOptions, IExportResult, IExportResultFunction, IFindCondition, IFindMethod, IFlowAlign, IFlowAxisAlign, IFlowBoxType, IFlowType, IFlowWrap, IFourNumber, IFromToData, IFunction, IFunctionMap, IGap, IHitCanvas, IHitCanvasConfig, IHitCanvasManager, IHitType, IImageCursor, IImageEvent, IImageManager, IInteraction, IInteractionCanvas, IInteractionConfig, IJSONOptions, IKeepTouchData, IKeyEvent, ILayoutAttr, ILayoutBlockData, ILayoutBoundsData, ILayoutChangedData, ILayoutData, ILayoutEvent, ILayouter, ILayouterConfig, ILeaf, ILeafArrayMap, ILeafAttrData, ILeafAttrDescriptor, ILeafAttrDescriptorFn, ILeafBounds, ILeafBoundsModule, ILeafComputedData, ILeafData, ILeafDataOptions, ILeafDataProxy, ILeafDataProxyModule, ILeafEventer, ILeafEventerModule, ILeafHit, ILeafHitModule, ILeafInputData, ILeafLayout, ILeafLevelList, ILeafList, ILeafListItemCallback, ILeafMap, ILeafMatrix, ILeafMatrixModule, ILeafRender, ILeafRenderModule, ILeaferAttrData, ILeaferBase, ILeaferCanvas, ILeaferCanvasConfig, ILeaferCanvasView, ILeaferConfig, ILeaferEvent, ILeaferImage, ILeaferImageCacheCanvas, ILeaferImageConfig, ILeaferImageOnError, ILeaferImageOnLoaded, ILeaferImagePatternPaint, ILeaferType, ILeaferTypeCreator, ILeaferTypeFunction, ILeaferTypeList, ILocationType, IMaskType, IMatrix, IMatrixData, IMatrixWithBoundsData, IMatrixWithBoundsScaleData, IMatrixWithLayoutData, IMatrixWithOptionScaleData, IMatrixWithScaleData, IMiniapp, IMiniappSelect, IMiniappSizeView, IMotionPathData, IMoveEvent, IMultiTouchConfig, IMultiTouchData, INumber, INumberFunction, INumberMap, IObject, IObjectFunction, IOffsetBoundsData, IPartLayoutConfig, IPath2D, IPathCommandData, IPathCommandObject, IPathCreator, IPathDrawer, IPathString, IPercentData, IPickBottom, IPickOptions, IPickResult, IPlatform, IPlugin, IPoint, IPointData, IPointDataFunction, IPointDataMap, IPointGap, IPointerConfig, IPointerEvent, IPropertyEvent, IRadiusPointData, IRangeSize, IRenderEvent, IRenderOptions, IRenderer, IRendererConfig, IResizeEvent, IResizeEventListener, IRotateEvent, IRotationPointData, IScaleData, IScaleRotationData, IScreenSizeData, IScrollPointData, ISelector, ISelectorConfig, ISelectorProxy, ISide, ISize, ISizeData, ISkewData, ISkiaCanvas, ISkiaCanvasExportConfig, ISkiaNAPICanvas, IStateStyleType, IString, IStringFunction, IStringMap, ISwipeEvent, ITaskItem, ITaskOptions, ITaskProcessor, ITaskProcessorConfig, ITextMetrics, ITimer, ITouchConfig, ITwoPointBoundsData, IUICreator, IUIEvent, IUnitData, IUnitPointData, IUpdateEvent, IValue, IWatchEvent, IWatchEventData, IWatcher, IWatcherConfig, IWheelConfig, IWindingRule, IZoomEvent, IZoomType, IZoomView, InnerId, LCommandData, LineToCommandObject, MCommandData, MoveToCommandObject, PointerType, QCommandData, QuadraticCurveToCommandObject, RectCommandData, RoundRectCommandData, SCommandData, TCommandData, VCommandData, ZCommandData };