@leafer/path 1.10.1 → 1.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -5
- package/src/PathCommandNodeHelper.ts +11 -0
- package/src/PathConvert.ts +18 -13
- package/src/index.ts +1 -0
- package/types/index.d.ts +8 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer/path",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.1",
|
|
4
4
|
"description": "@leafer/path",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
"leaferjs"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@leafer/data": "1.
|
|
26
|
-
"@leafer/math": "1.
|
|
27
|
-
"@leafer/debug": "1.
|
|
25
|
+
"@leafer/data": "1.11.1",
|
|
26
|
+
"@leafer/math": "1.11.1",
|
|
27
|
+
"@leafer/debug": "1.11.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@leafer/interface": "1.
|
|
30
|
+
"@leafer/interface": "1.11.1"
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IPathCommandNode, IPathCommandData, IPathNodeBase } from '@leafer/interface'
|
|
2
|
+
|
|
3
|
+
// 路径节点辅助(适合可视化编辑),提供接口(需重写)
|
|
4
|
+
export const PathCommandNodeHelper = {
|
|
5
|
+
toCommand(_nodes: IPathCommandNode[] | IPathNodeBase[]): IPathCommandData {
|
|
6
|
+
return []
|
|
7
|
+
},
|
|
8
|
+
toNode(_data: IPathCommandData): IPathCommandNode[] {
|
|
9
|
+
return []
|
|
10
|
+
}
|
|
11
|
+
}
|
package/src/PathConvert.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { IPathCommandData, IPathCommandObject, IPointData } from '@leafer/interface'
|
|
1
|
+
import { IPathCommandData, IPathCommandNode, IPathCommandObject, IPointData } from '@leafer/interface'
|
|
2
2
|
import { MathHelper, StringNumberMap } from '@leafer/math'
|
|
3
3
|
import { Debug } from '@leafer/debug'
|
|
4
4
|
|
|
5
5
|
import { PathCommandMap as Command, NeedConvertToCanvasCommandMap, NeedConvertToCurveCommandMap, PathCommandLengthMap, PathNumberCommandMap, PathNumberCommandLengthMap } from './PathCommandMap'
|
|
6
6
|
import { BezierHelper } from './BezierHelper'
|
|
7
7
|
import { EllipseHelper } from './EllipseHelper'
|
|
8
|
+
import { PathCommandNodeHelper } from './PathCommandNodeHelper'
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
interface ICurrentCommand {
|
|
@@ -303,18 +304,22 @@ export const PathConvert = {
|
|
|
303
304
|
|
|
304
305
|
},
|
|
305
306
|
|
|
306
|
-
objectToCanvasData(list: IPathCommandObject[]): IPathCommandData {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
307
|
+
objectToCanvasData(list: IPathCommandNode[] | IPathCommandObject[]): IPathCommandData {
|
|
308
|
+
if (list[0].name.length > 1) { // nodes
|
|
309
|
+
return PathCommandNodeHelper.toCommand(list as IPathCommandNode[])
|
|
310
|
+
} else {
|
|
311
|
+
const data: IPathCommandData = []
|
|
312
|
+
list.forEach(item => {
|
|
313
|
+
switch (item.name) {
|
|
314
|
+
case 'M': data.push(M, item.x, item.y); break
|
|
315
|
+
case 'L': data.push(L, item.x, item.y); break
|
|
316
|
+
case 'C': data.push(C, item.x1, item.y1, item.x2, item.y2, item.x, item.y); break
|
|
317
|
+
case 'Q': data.push(Q, item.x1, item.y1, item.x, item.y); break
|
|
318
|
+
case 'Z': data.push(Z)
|
|
319
|
+
}
|
|
320
|
+
})
|
|
321
|
+
return data
|
|
322
|
+
}
|
|
318
323
|
},
|
|
319
324
|
|
|
320
325
|
copyData(data: IPathCommandData, old: IPathCommandData, index: number, count: number): void {
|
package/src/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { PathHelper } from './PathHelper'
|
|
|
2
2
|
export { PathConvert } from './PathConvert'
|
|
3
3
|
export { PathCreator } from './PathCreator'
|
|
4
4
|
export { PathCommandDataHelper } from './PathCommandDataHelper'
|
|
5
|
+
export { PathCommandNodeHelper } from './PathCommandNodeHelper'
|
|
5
6
|
export { PathDrawer } from './PathDrawer'
|
|
6
7
|
export { PathBounds } from './PathBounds'
|
|
7
8
|
export { PathCorner } from './PathCorner'
|
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IPathCreator, IPathCommandData, IPathCommandObject, IPathString, IPointData, IPathDrawer, IBoundsData, ITwoPointBoundsData, INumberMap, IStringMap } from '@leafer/interface';
|
|
1
|
+
import { IPathCreator, IPathCommandData, IPathCommandNode, IPathCommandObject, IPathString, IPointData, IPathNodeBase, IPathDrawer, IBoundsData, ITwoPointBoundsData, INumberMap, IStringMap } from '@leafer/interface';
|
|
2
2
|
|
|
3
3
|
declare const PathHelper: {
|
|
4
4
|
creator: IPathCreator;
|
|
@@ -17,7 +17,7 @@ declare const PathConvert: {
|
|
|
17
17
|
stringify(data: IPathCommandData, floatLength?: number): string;
|
|
18
18
|
parse(pathString: string, curveMode?: boolean): IPathCommandData;
|
|
19
19
|
toCanvasData(old: IPathCommandData, curveMode?: boolean): IPathCommandData;
|
|
20
|
-
objectToCanvasData(list: IPathCommandObject[]): IPathCommandData;
|
|
20
|
+
objectToCanvasData(list: IPathCommandNode[] | IPathCommandObject[]): IPathCommandData;
|
|
21
21
|
copyData(data: IPathCommandData, old: IPathCommandData, index: number, count: number): void;
|
|
22
22
|
pushData(data: IPathCommandData, strNum: string | number): void;
|
|
23
23
|
};
|
|
@@ -63,6 +63,11 @@ declare const PathCommandDataHelper: {
|
|
|
63
63
|
drawPoints(data: IPathCommandData, points: number[] | IPointData[], curve?: boolean | number, close?: boolean): void;
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
+
declare const PathCommandNodeHelper: {
|
|
67
|
+
toCommand(_nodes: IPathCommandNode[] | IPathNodeBase[]): IPathCommandData;
|
|
68
|
+
toNode(_data: IPathCommandData): IPathCommandNode[];
|
|
69
|
+
};
|
|
70
|
+
|
|
66
71
|
declare const PathDrawer: {
|
|
67
72
|
drawPathByData(drawer: IPathDrawer, data: IPathCommandData): void;
|
|
68
73
|
};
|
|
@@ -107,4 +112,4 @@ declare const PathNumberCommandLengthMap: INumberMap;
|
|
|
107
112
|
declare function path(path?: IPathCommandData | IPathString): PathCreator;
|
|
108
113
|
declare const pen: PathCreator;
|
|
109
114
|
|
|
110
|
-
export { BezierHelper, EllipseHelper, NeedConvertToCanvasCommandMap, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, RectHelper, path, pen };
|
|
115
|
+
export { BezierHelper, EllipseHelper, NeedConvertToCanvasCommandMap, PathBounds, PathCommandDataHelper, PathCommandMap, PathCommandNodeHelper, PathConvert, PathCorner, PathCreator, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, RectHelper, path, pen };
|