@visactor/vrender 0.15.5 → 0.15.7
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/cjs/common/segment/monotone.js +2 -2
- package/cjs/common/segment/monotone.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.min.js +1 -1
- package/es/common/segment/monotone.js +2 -2
- package/es/common/segment/monotone.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -41,11 +41,11 @@ class MonotoneX {
|
|
|
41
41
|
lineEnd() {
|
|
42
42
|
switch (this._point) {
|
|
43
43
|
case 2:
|
|
44
|
-
this.context.lineTo(this._x1, this._y1, !1 !== this._lastDefined2, this.lastPoint1);
|
|
44
|
+
this.context.lineTo(this._x1, this._y1, !1 !== this._lastDefined1 && !1 !== this._lastDefined2, this.lastPoint1);
|
|
45
45
|
break;
|
|
46
46
|
|
|
47
47
|
case 3:
|
|
48
|
-
point(this, this._t0, slope2(this, this._t0), !1 !== this._lastDefined2, this.lastPoint1);
|
|
48
|
+
point(this, this._t0, slope2(this, this._t0), !1 !== this._lastDefined1 && !1 !== this._lastDefined2, this.lastPoint1);
|
|
49
49
|
}
|
|
50
50
|
(this._line || 0 !== this._line && 1 === this._point) && this.context.closePath(),
|
|
51
51
|
this._line = 1 - this._line;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/common/segment/monotone.ts"],"names":[],"mappings":";;;AACA,6CAAuC;AACvC,qCAA6C;AAC7C,qCAA4C;AAC5C,gDAA+D;AAC/D,oCAAqC;AAsBrC,SAAS,IAAI,CAAC,CAAS;IACrB,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACxB,CAAC;AAMD,SAAS,MAA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AC,iBAAS,CAAC,MAAM,CAAC,CACxB,CAAC;IACF,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAExD,wBAAwB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAE5C,OAAO,UAAU,CAAC;AACpB,CAAC;AApBD,oDAoBC","file":"monotone.js","sourcesContent":["import type { IPointLike } from '@visactor/vutils';\nimport { abs } from '@visactor/vutils';\nimport { genLinearSegments } from './linear';\nimport { genCurveSegments } from './common';\nimport { ReflectSegContext, SegContext } from '../seg-context';\nimport { Direction } from '../enums';\nimport type { ICurvedSegment, IGenSegmentParams, ISegPath2D } from '../../interface/curve';\n\n/**\n * 部分源码参考 https://github.com/d3/d3-shape/\n * Copyright 2010-2022 Mike Bostock\n\n Permission to use, copy, modify, and/or distribute this software for any purpose\n with or without fee is hereby granted, provided that the above copyright notice\n and this permission notice appear in all copies.\n\n THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND\n FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS\n OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER\n TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\n THIS SOFTWARE.\n */\n\n// 基于d3-shape重构\n// https://github.com/d3/d3-shape/blob/main/src/curve/monotone.js\nfunction sign(x: number): number {\n return x < 0 ? -1 : 1;\n}\n\n// Calculate the slopes of the tangents (Hermite-type interpolation) based on\n// the following paper: Steffen, M. 1990. A Simple Method for Monotonic\n// Interpolation in One Dimension. Astronomy and Astrophysics, Vol. 239, NO.\n// NOV(II), P. 443, 1990.\nfunction slope3(curveClass: MonotoneX | MonotoneY, x2: number, y2: number) {\n const h0 = curveClass._x1 - curveClass._x0;\n const h1 = x2 - curveClass._x1;\n const s0 = (curveClass._y1 - curveClass._y0) / (h0 || Number(h1 < 0 && -0));\n const s1 = (y2 - curveClass._y1) / (h1 || Number(h0 < 0 && -0));\n const p = (s0 * h1 + s1 * h0) / (h0 + h1);\n return (sign(s0) + sign(s1)) * Math.min(Math.abs(s0), Math.abs(s1), 0.5 * Math.abs(p)) || 0;\n}\n\n// Calculate a one-sided slope.\nfunction slope2(curveClass: MonotoneX | MonotoneY, t: number) {\n const h = curveClass._x1 - curveClass._x0;\n return h ? ((3 * (curveClass._y1 - curveClass._y0)) / h - t) / 2 : t;\n}\n\n// According to https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Representations\n// \"you can express cubic Hermite interpolation in terms of cubic Bézier curves\n// with respect to the four values p0, p0 + m0 / 3, p1 - m1 / 3, p1\".\nfunction point(curveClass: MonotoneX | MonotoneY, t0: number, t1: number, defined: boolean, p: IPointLike) {\n const x0 = curveClass._x0;\n const y0 = curveClass._y0;\n const x1 = curveClass._x1;\n const y1 = curveClass._y1;\n const dx = (x1 - x0) / 3;\n curveClass.context.bezierCurveTo(\n x0 + dx,\n y0 + dx * t0,\n x1 - dx,\n y1 - dx * t1,\n x1,\n y1,\n defined,\n curveClass.lastPoint1\n );\n}\n\nexport class MonotoneX implements ICurvedSegment {\n protected _lastDefined1?: boolean;\n protected _lastDefined2?: boolean;\n declare context: ISegPath2D;\n declare _t0: number;\n\n protected startPoint?: IPointLike;\n lastPoint0?: IPointLike;\n lastPoint1?: IPointLike;\n\n constructor(context: ISegPath2D, startPoint?: IPointLike) {\n this.context = context;\n this.startPoint = startPoint;\n }\n _x: number;\n _y: number;\n _x0: number;\n _x1: number;\n _y0: number;\n _y1: number;\n _line: number;\n _point: number;\n\n areaStart() {\n this._line = 0;\n }\n areaEnd() {\n this._line = NaN;\n }\n lineStart() {\n this._x0 = this._x1 = this._y0 = this._y1 = this._t0 = NaN;\n this._point = 0;\n this.startPoint && this.point(this.startPoint);\n }\n lineEnd() {\n switch (this._point) {\n case 2:\n this.context.lineTo(this._x1, this._y1, this._lastDefined2 !== false, this.lastPoint1);\n break;\n case 3:\n point(this, this._t0, slope2(this, this._t0), this._lastDefined2 !== false, this.lastPoint1);\n break;\n }\n if (this._line || (this._line !== 0 && this._point === 1)) {\n this.context.closePath();\n }\n this._line = 1 - this._line;\n }\n point(p: IPointLike): void {\n let t1 = NaN;\n const x = p.x;\n const y = p.y;\n if (x === this._x1 && y === this._y1) {\n return;\n } // Ignore coincident points.\n switch (this._point) {\n case 0:\n this._point = 1;\n this._line\n ? this.context.lineTo(x, y, this._lastDefined1 !== false && this._lastDefined2 !== false, p)\n : this.context.moveTo(x, y, p);\n break;\n case 1:\n this._point = 2;\n break;\n case 2:\n this._point = 3;\n point(\n this,\n slope2(this, (t1 = slope3(this, x, y))),\n t1,\n this._lastDefined1 !== false && this._lastDefined2 !== false,\n p\n );\n break;\n default:\n point(\n this,\n this._t0,\n (t1 = slope3(this, x, y)),\n this._lastDefined1 !== false && this._lastDefined2 !== false,\n p\n );\n break;\n }\n\n (this._x0 = this._x1), (this._x1 = x);\n (this._y0 = this._y1), (this._y1 = y);\n this._t0 = t1;\n this._lastDefined1 = this._lastDefined2;\n this._lastDefined2 = p.defined !== false;\n this.lastPoint0 = this.lastPoint1;\n this.lastPoint1 = p;\n }\n\n tryUpdateLength(): number {\n return this.context.tryUpdateLength();\n }\n}\n\nexport class MonotoneY extends MonotoneX {\n declare context: ISegPath2D;\n\n protected declare startPoint?: IPointLike;\n\n constructor(context: ISegPath2D, startPoint?: IPointLike) {\n super(context, startPoint);\n }\n\n point(p: IPointLike): void {\n return super.point({ y: p.x, x: p.y, defined: p.defined } as any);\n }\n}\n\nexport function genMonotpneXTypeSegments(path: MonotoneX, points: IPointLike[]): void {\n return genCurveSegments(path, points, 2);\n}\n\nexport function genMonotoneXSegments(points: IPointLike[], params: IGenSegmentParams = {}): ISegPath2D | null {\n const { direction, startPoint } = params;\n\n if (points.length < 2 - Number(!!startPoint)) {\n return null;\n }\n if (points.length < 3 - Number(!!startPoint)) {\n return genLinearSegments(points, params);\n }\n const segContext = new SegContext(\n 'monotoneX',\n direction ??\n (abs(points[points.length - 1].x - points[0].x) > abs(points[points.length - 1].y - points[0].y)\n ? Direction.ROW\n : Direction.COLUMN)\n );\n const monotoneX = new MonotoneX(segContext, startPoint);\n\n genMonotpneXTypeSegments(monotoneX, points);\n\n return segContext;\n}\n\nexport function genMonotpneYTypeSegments(path: MonotoneX, points: IPointLike[]): void {\n return genCurveSegments(path, points, 2);\n}\n\nexport function genMonotoneYSegments(points: IPointLike[], params: IGenSegmentParams = {}): ISegPath2D | null {\n const { direction, startPoint } = params;\n if (points.length < 2 - Number(!!startPoint)) {\n return null;\n }\n if (points.length < 3 - Number(!!startPoint)) {\n return genLinearSegments(points, params);\n }\n const segContext = new ReflectSegContext(\n 'monotoneY',\n direction ??\n (abs(points[points.length - 1].x - points[0].x) > abs(points[points.length - 1].y - points[0].y)\n ? Direction.ROW\n : Direction.COLUMN)\n );\n const monotoneY = new MonotoneY(segContext, startPoint);\n\n genMonotpneYTypeSegments(monotoneY, points);\n\n return segContext;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/common/segment/monotone.ts"],"names":[],"mappings":";;;AACA,6CAAuC;AACvC,qCAA6C;AAC7C,qCAA4C;AAC5C,gDAA+D;AAC/D,oCAAqC;AAsBrC,SAAS,IAAI,CAAC,CAAS;IACrB,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACxB,CAAC;AAMD,SAAS,MAAM,CAAC,UAAiC,EAAE,EAAU,EAAE,EAAU;IACvE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,GAAG,UAAU,CAAC,GAAG,CAAC;IAC3C,MAAM,EAAE,GAAG,EAAE,GAAG,U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AU,EAAE,UAAU,CAAC,CAAC;IAExD,wBAAwB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAE5C,OAAO,UAAU,CAAC;AACpB,CAAC;AApBD,oDAoBC","file":"monotone.js","sourcesContent":["import type { IPointLike } from '@visactor/vutils';\nimport { abs } from '@visactor/vutils';\nimport { genLinearSegments } from './linear';\nimport { genCurveSegments } from './common';\nimport { ReflectSegContext, SegContext } from '../seg-context';\nimport { Direction } from '../enums';\nimport type { ICurvedSegment, IGenSegmentParams, ISegPath2D } from '../../interface/curve';\n\n/**\n * 部分源码参考 https://github.com/d3/d3-shape/\n * Copyright 2010-2022 Mike Bostock\n\n Permission to use, copy, modify, and/or distribute this software for any purpose\n with or without fee is hereby granted, provided that the above copyright notice\n and this permission notice appear in all copies.\n\n THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND\n FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS\n OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER\n TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\n THIS SOFTWARE.\n */\n\n// 基于d3-shape重构\n// https://github.com/d3/d3-shape/blob/main/src/curve/monotone.js\nfunction sign(x: number): number {\n return x < 0 ? -1 : 1;\n}\n\n// Calculate the slopes of the tangents (Hermite-type interpolation) based on\n// the following paper: Steffen, M. 1990. A Simple Method for Monotonic\n// Interpolation in One Dimension. Astronomy and Astrophysics, Vol. 239, NO.\n// NOV(II), P. 443, 1990.\nfunction slope3(curveClass: MonotoneX | MonotoneY, x2: number, y2: number) {\n const h0 = curveClass._x1 - curveClass._x0;\n const h1 = x2 - curveClass._x1;\n const s0 = (curveClass._y1 - curveClass._y0) / (h0 || Number(h1 < 0 && -0));\n const s1 = (y2 - curveClass._y1) / (h1 || Number(h0 < 0 && -0));\n const p = (s0 * h1 + s1 * h0) / (h0 + h1);\n return (sign(s0) + sign(s1)) * Math.min(Math.abs(s0), Math.abs(s1), 0.5 * Math.abs(p)) || 0;\n}\n\n// Calculate a one-sided slope.\nfunction slope2(curveClass: MonotoneX | MonotoneY, t: number) {\n const h = curveClass._x1 - curveClass._x0;\n return h ? ((3 * (curveClass._y1 - curveClass._y0)) / h - t) / 2 : t;\n}\n\n// According to https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Representations\n// \"you can express cubic Hermite interpolation in terms of cubic Bézier curves\n// with respect to the four values p0, p0 + m0 / 3, p1 - m1 / 3, p1\".\nfunction point(curveClass: MonotoneX | MonotoneY, t0: number, t1: number, defined: boolean, p: IPointLike) {\n const x0 = curveClass._x0;\n const y0 = curveClass._y0;\n const x1 = curveClass._x1;\n const y1 = curveClass._y1;\n const dx = (x1 - x0) / 3;\n curveClass.context.bezierCurveTo(\n x0 + dx,\n y0 + dx * t0,\n x1 - dx,\n y1 - dx * t1,\n x1,\n y1,\n defined,\n curveClass.lastPoint1\n );\n}\n\nexport class MonotoneX implements ICurvedSegment {\n protected _lastDefined1?: boolean;\n protected _lastDefined2?: boolean;\n declare context: ISegPath2D;\n declare _t0: number;\n\n protected startPoint?: IPointLike;\n lastPoint0?: IPointLike;\n lastPoint1?: IPointLike;\n\n constructor(context: ISegPath2D, startPoint?: IPointLike) {\n this.context = context;\n this.startPoint = startPoint;\n }\n _x: number;\n _y: number;\n _x0: number;\n _x1: number;\n _y0: number;\n _y1: number;\n _line: number;\n _point: number;\n\n areaStart() {\n this._line = 0;\n }\n areaEnd() {\n this._line = NaN;\n }\n lineStart() {\n this._x0 = this._x1 = this._y0 = this._y1 = this._t0 = NaN;\n this._point = 0;\n this.startPoint && this.point(this.startPoint);\n }\n lineEnd() {\n switch (this._point) {\n case 2:\n this.context.lineTo(\n this._x1,\n this._y1,\n this._lastDefined1 !== false && this._lastDefined2 !== false,\n this.lastPoint1\n );\n break;\n case 3:\n point(\n this,\n this._t0,\n slope2(this, this._t0),\n this._lastDefined1 !== false && this._lastDefined2 !== false,\n this.lastPoint1\n );\n break;\n }\n if (this._line || (this._line !== 0 && this._point === 1)) {\n this.context.closePath();\n }\n this._line = 1 - this._line;\n }\n point(p: IPointLike): void {\n let t1 = NaN;\n const x = p.x;\n const y = p.y;\n if (x === this._x1 && y === this._y1) {\n return;\n } // Ignore coincident points.\n switch (this._point) {\n case 0:\n this._point = 1;\n this._line\n ? this.context.lineTo(x, y, this._lastDefined1 !== false && this._lastDefined2 !== false, p)\n : this.context.moveTo(x, y, p);\n break;\n case 1:\n this._point = 2;\n break;\n case 2:\n this._point = 3;\n point(\n this,\n slope2(this, (t1 = slope3(this, x, y))),\n t1,\n this._lastDefined1 !== false && this._lastDefined2 !== false,\n p\n );\n break;\n default:\n point(\n this,\n this._t0,\n (t1 = slope3(this, x, y)),\n this._lastDefined1 !== false && this._lastDefined2 !== false,\n p\n );\n break;\n }\n\n (this._x0 = this._x1), (this._x1 = x);\n (this._y0 = this._y1), (this._y1 = y);\n this._t0 = t1;\n this._lastDefined1 = this._lastDefined2;\n this._lastDefined2 = p.defined !== false;\n this.lastPoint0 = this.lastPoint1;\n this.lastPoint1 = p;\n }\n\n tryUpdateLength(): number {\n return this.context.tryUpdateLength();\n }\n}\n\nexport class MonotoneY extends MonotoneX {\n declare context: ISegPath2D;\n\n protected declare startPoint?: IPointLike;\n\n constructor(context: ISegPath2D, startPoint?: IPointLike) {\n super(context, startPoint);\n }\n\n point(p: IPointLike): void {\n return super.point({ y: p.x, x: p.y, defined: p.defined } as any);\n }\n}\n\nexport function genMonotpneXTypeSegments(path: MonotoneX, points: IPointLike[]): void {\n return genCurveSegments(path, points, 2);\n}\n\nexport function genMonotoneXSegments(points: IPointLike[], params: IGenSegmentParams = {}): ISegPath2D | null {\n const { direction, startPoint } = params;\n\n if (points.length < 2 - Number(!!startPoint)) {\n return null;\n }\n if (points.length < 3 - Number(!!startPoint)) {\n return genLinearSegments(points, params);\n }\n const segContext = new SegContext(\n 'monotoneX',\n direction ??\n (abs(points[points.length - 1].x - points[0].x) > abs(points[points.length - 1].y - points[0].y)\n ? Direction.ROW\n : Direction.COLUMN)\n );\n const monotoneX = new MonotoneX(segContext, startPoint);\n\n genMonotpneXTypeSegments(monotoneX, points);\n\n return segContext;\n}\n\nexport function genMonotpneYTypeSegments(path: MonotoneX, points: IPointLike[]): void {\n return genCurveSegments(path, points, 2);\n}\n\nexport function genMonotoneYSegments(points: IPointLike[], params: IGenSegmentParams = {}): ISegPath2D | null {\n const { direction, startPoint } = params;\n if (points.length < 2 - Number(!!startPoint)) {\n return null;\n }\n if (points.length < 3 - Number(!!startPoint)) {\n return genLinearSegments(points, params);\n }\n const segContext = new ReflectSegContext(\n 'monotoneY',\n direction ??\n (abs(points[points.length - 1].x - points[0].x) > abs(points[points.length - 1].y - points[0].y)\n ? Direction.ROW\n : Direction.COLUMN)\n );\n const monotoneY = new MonotoneY(segContext, startPoint);\n\n genMonotpneYTypeSegments(monotoneY, points);\n\n return segContext;\n}\n"]}
|
package/cjs/index.d.ts
CHANGED
package/cjs/index.js
CHANGED
|
@@ -18,7 +18,7 @@ var __createBinding = this && this.__createBinding || (Object.create ? function(
|
|
|
18
18
|
Object.defineProperty(exports, "__esModule", {
|
|
19
19
|
value: !0
|
|
20
20
|
}), exports.wrapContext = exports.wrapCanvas = exports.version = void 0, require("core-js/proposals/reflect-metadata"),
|
|
21
|
-
require("./modules"), exports.version = "0.15.
|
|
21
|
+
require("./modules"), exports.version = "0.15.7", __exportStar(require("./container"), exports),
|
|
22
22
|
__exportStar(require("./core/global"), exports), __exportStar(require("./graphic"), exports),
|
|
23
23
|
__exportStar(require("./modules"), exports), __exportStar(require("./create"), exports),
|
|
24
24
|
__exportStar(require("./event"), exports), __exportStar(require("./interface"), exports),
|
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,8CAA4C;AAC5C,qBAAmB;AAGN,QAAA,OAAO,GAAG,QAAQ,CAAC;AAEhC,8CAA4B;AAC5B,gDAA8B;AAC9B,4CAA0B;AAC1B,4CAA0B;AAC1B,2CAAyB;AACzB,0CAAwB;AACxB,8CAA4B;AAC5B,2CAAyB;AACzB,4EAA0D;AAC1D,2CAAyB;AACzB,yCAAuB;AACvB,2CAAyB;AACzB,yCAAuB;AACvB,4CAA0B;AAC1B,2DAAyC;AAGzC,gDAA8B;AAC9B,wDAAsC;AACtC,0DAAwC;AACxC,uDAAqC;AACrC,yDAAuC;AACvC,mDAAiC;AACjC,wDAAsC;AACtC,iEAA+C;AAC/C,qDAAmC;AACnC,iDAA+B;AAC/B,qDAAmC;AACnC,sDAAoC;AAEpC,oDAAkC;AAClC,wDAAsC;AACtC,uDAAqC;AACrC,+DAA6C;AAC7C,gDAA8B;AAC9B,0DAAwC;AACxC,sDAAoC;AACpC,iDAA+B;AAC/B,qDAAmC;AACnC,sDAAoC;AACpC,8DAA4C;AAE5C,2DAAyC;AACzC,sCAAwD;AAA/C,kGAAA,UAAU,OAAA;AAAE,mGAAA,WAAW,OAAA;AAChC,wCAAsB","file":"index.js","sourcesContent":["import 'core-js/proposals/reflect-metadata';\nimport './modules';\n\n// 导出版本号\nexport const version = \"0.15.
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,8CAA4C;AAC5C,qBAAmB;AAGN,QAAA,OAAO,GAAG,QAAQ,CAAC;AAEhC,8CAA4B;AAC5B,gDAA8B;AAC9B,4CAA0B;AAC1B,4CAA0B;AAC1B,2CAAyB;AACzB,0CAAwB;AACxB,8CAA4B;AAC5B,2CAAyB;AACzB,4EAA0D;AAC1D,2CAAyB;AACzB,yCAAuB;AACvB,2CAAyB;AACzB,yCAAuB;AACvB,4CAA0B;AAC1B,2DAAyC;AAGzC,gDAA8B;AAC9B,wDAAsC;AACtC,0DAAwC;AACxC,uDAAqC;AACrC,yDAAuC;AACvC,mDAAiC;AACjC,wDAAsC;AACtC,iEAA+C;AAC/C,qDAAmC;AACnC,iDAA+B;AAC/B,qDAAmC;AACnC,sDAAoC;AAEpC,oDAAkC;AAClC,wDAAsC;AACtC,uDAAqC;AACrC,+DAA6C;AAC7C,gDAA8B;AAC9B,0DAAwC;AACxC,sDAAoC;AACpC,iDAA+B;AAC/B,qDAAmC;AACnC,sDAAoC;AACpC,8DAA4C;AAE5C,2DAAyC;AACzC,sCAAwD;AAA/C,kGAAA,UAAU,OAAA;AAAE,mGAAA,WAAW,OAAA;AAChC,wCAAsB","file":"index.js","sourcesContent":["import 'core-js/proposals/reflect-metadata';\nimport './modules';\n\n// 导出版本号\nexport const version = \"0.15.7\";\n\nexport * from './container';\nexport * from './core/global';\nexport * from './graphic';\nexport * from './modules';\nexport * from './create';\nexport * from './event';\nexport * from './interface';\nexport * from './render';\nexport * from './render/contributions/render/base-render';\nexport * from './canvas';\nexport * from './core';\nexport * from './picker';\nexport * from './kits';\nexport * from './animate';\nexport * from './resource-loader/loader';\n\n/* export common */\nexport * from './common/text';\nexport * from './common/bezier-utils';\nexport * from './common/bounds-context';\nexport * from './common/seg-context';\nexport * from './common/custom-path2d';\nexport * from './common/segment';\nexport * from './common/canvas-utils';\nexport * from './common/contribution-provider';\nexport * from './common/generator';\nexport * from './common/utils';\nexport * from './common/shape/arc';\nexport * from './common/shape/rect';\n\nexport * from './common/path-svg';\nexport * from './common/render-curve';\nexport * from './common/render-area';\nexport * from './common/render-command-list';\nexport * from './common/sort';\nexport * from './common/morphing-utils';\nexport * from './common/split-path';\nexport * from './common/enums';\nexport * from './common/generator';\nexport * from './plugins/constants';\nexport * from './allocator/matrix-allocate';\n\nexport * from './animate/default-ticker';\nexport { wrapCanvas, wrapContext } from './canvas/util';\nexport * from './jsx';\n"]}
|
package/dist/index.js
CHANGED
|
@@ -8533,10 +8533,10 @@
|
|
|
8533
8533
|
lineEnd() {
|
|
8534
8534
|
switch (this._point) {
|
|
8535
8535
|
case 2:
|
|
8536
|
-
this.context.lineTo(this._x1, this._y1, this._lastDefined2 !== false, this.lastPoint1);
|
|
8536
|
+
this.context.lineTo(this._x1, this._y1, this._lastDefined1 !== false && this._lastDefined2 !== false, this.lastPoint1);
|
|
8537
8537
|
break;
|
|
8538
8538
|
case 3:
|
|
8539
|
-
point$1(this, this._t0, slope2(this, this._t0), this._lastDefined2 !== false, this.lastPoint1);
|
|
8539
|
+
point$1(this, this._t0, slope2(this, this._t0), this._lastDefined1 !== false && this._lastDefined2 !== false, this.lastPoint1);
|
|
8540
8540
|
break;
|
|
8541
8541
|
}
|
|
8542
8542
|
if (this._line || (this._line !== 0 && this._point === 1)) {
|
|
@@ -40548,7 +40548,7 @@
|
|
|
40548
40548
|
}
|
|
40549
40549
|
const Fragment = Group;
|
|
40550
40550
|
|
|
40551
|
-
const version = "0.15.
|
|
40551
|
+
const version = "0.15.7";
|
|
40552
40552
|
|
|
40553
40553
|
exports.ACustomAnimate = ACustomAnimate;
|
|
40554
40554
|
exports.ARC3D_NUMBER_TYPE = ARC3D_NUMBER_TYPE;
|