Skip to content

Commit

Permalink
fix: convert L segment to C (#83)
Browse files Browse the repository at this point in the history
Co-authored-by: yuqi.pyq <[email protected]>
  • Loading branch information
xiaoiver and xiaoiver authored Jun 21, 2022
1 parent cc2d9cc commit d588057
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions __tests__/unit/path/path-2-curve.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ describe('test path to curve', () => {
const [pathArray, zCommandIndexes] = path2Curve('M 10,10 L -10,0 L 10,-10 Z M 10,10 L -10,0 L 10,-10 Z', true);
expect(pathArray).toEqual([
['M', 10, 10],
['C', 12.23606797749979, 11.118033988749895, 1.3471359549995796, 5.67356797749979, -10, 0],
['C', 10, 10, -3.125, 3.4375, -10, 0],
['C', -7.76393202250021, -1.118033988749895, 3.75, -6.875, 10, -10],
['C', 10, 0, 10, 3.75, 10, 10],
['M', 10, 10],
['C', 12.23606797749979, 11.118033988749895, 1.3471359549995796, 5.67356797749979, -10, 0],
['C', 10, 10, -3.125, 3.4375, -10, 0],
['C', -7.76393202250021, -1.118033988749895, 3.75, -6.875, 10, -10],
['C', 10, 0, 10, 3.75, 10, 10],
]);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/util",
"version": "3.1.0",
"version": "3.1.1",
"license": "MIT",
"sideEffects": false,
"main": "lib/index.js",
Expand Down
3 changes: 1 addition & 2 deletions src/path/util/segment-line-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ export function segmentLineFactory(x1: number, y1: number, x2: number, y2: numbe
const length = distanceSquareRoot([x1, y1], [x2, y2]);
let point = { x: 0, y: 0 };

/* istanbul ignore else */
if (typeof distance === 'number') {
if (distance === 0) {
if (distance <= 0) {
point = { x: x1, y: y1 };
} else if (distance >= length) {
point = { x: x2, y: y2 };
Expand Down

0 comments on commit d588057

Please sign in to comment.