@leafer/path 1.0.0-rc.17 → 1.0.0-rc.18

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/path",
3
- "version": "1.0.0-rc.17",
3
+ "version": "1.0.0-rc.18",
4
4
  "description": "@leafer/path",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,10 +22,10 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/math": "1.0.0-rc.17",
26
- "@leafer/debug": "1.0.0-rc.17"
25
+ "@leafer/math": "1.0.0-rc.18",
26
+ "@leafer/debug": "1.0.0-rc.18"
27
27
  },
28
28
  "devDependencies": {
29
- "@leafer/interface": "1.0.0-rc.17"
29
+ "@leafer/interface": "1.0.0-rc.18"
30
30
  }
31
31
  }
@@ -13,11 +13,16 @@ export class PathCreator implements IPathDrawer {
13
13
  public __path: IPathCommandData // 提供一个更安全的内部变量(比如覆盖给Pen时需要用到,避免与原有属性冲突)
14
14
 
15
15
  constructor(path?: IPathCommandData | IPathString) {
16
+ this.set(path)
17
+ }
18
+
19
+ public set(path?: IPathCommandData | IPathString): PathCreator {
16
20
  if (path) {
17
21
  this.__path = typeof path === 'string' ? PathHelper.parse(path) : path
18
22
  } else {
19
23
  this.__path = []
20
24
  }
25
+ return this
21
26
  }
22
27
 
23
28
  public beginPath(): PathCreator {
package/src/index.ts CHANGED
@@ -19,3 +19,5 @@ import { PathHelper } from './PathHelper'
19
19
  PathHelper.creator = new PathCreator()
20
20
  PathHelper.parse = PathConvert.parse
21
21
  PathHelper.convertToCanvasData = PathConvert.toCanvasData
22
+
23
+ export const pen = new PathCreator()
package/types/index.d.ts CHANGED
@@ -26,6 +26,7 @@ declare class PathCreator implements IPathDrawer {
26
26
  get path(): IPathCommandData;
27
27
  __path: IPathCommandData;
28
28
  constructor(path?: IPathCommandData | IPathString);
29
+ set(path?: IPathCommandData | IPathString): PathCreator;
29
30
  beginPath(): PathCreator;
30
31
  moveTo(x: number, y: number): PathCreator;
31
32
  lineTo(x: number, y: number): PathCreator;
@@ -99,4 +100,6 @@ declare const NeedConvertToCanvasCommandMap: INumberMap;
99
100
  declare const PathNumberCommandMap: IStringMap;
100
101
  declare const PathNumberCommandLengthMap: INumberMap;
101
102
 
102
- export { BezierHelper, EllipseHelper, NeedConvertToCanvasCommandMap, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, RectHelper };
103
+ declare const pen: PathCreator;
104
+
105
+ export { BezierHelper, EllipseHelper, NeedConvertToCanvasCommandMap, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, RectHelper, pen };