Skip to content

Commit

Permalink
chore: bump v3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoiver committed Jun 19, 2022
1 parent 594d9aa commit a273ca2
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 1 deletion.
38 changes: 38 additions & 0 deletions __tests__/unit/path/path-2-absolute.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,42 @@ describe('path to absolute', () => {
['V', 130],
]);
});

it('camera path', () => {
const arr = path2Absolute(
'M2 4a2 2 0 0 0 -2 2v6a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-6a2 2 0 0 0 -2 -2h-1.172a2 2 0 0 1 -1.414 -0.586l-0.828 -0.828a2 2 0 0 0 -1.414 -0.586h-2.344a2 2 0 0 0 -1.414 0.586l-0.828 0.828a2 2 0 0 1 -1.414 0.586h-1.172zM10.5 8.5a2.5 2.5 0 0 0 -5 0a2.5 2.5 0 1 0 5 0zM2.5 6a0.5 0.5 0 0 1 0 -1a0.5 0.5 0 1 1 0 1zM11.5 8.5a3.5 3.5 0 1 1 -7 0a3.5 3.5 0 0 1 7 0z',
);
expect(arr).toEqual([
['M', 2, 4],
['A', 2, 2, 0, 0, 0, 0, 6],
['V', 12],
['A', 2, 2, 0, 0, 0, 2, 14],
['H', 14],
['A', 2, 2, 0, 0, 0, 16, 12],
['V', 6],
['A', 2, 2, 0, 0, 0, 14, 4],
['H', 12.828],
['A', 2, 2, 0, 0, 1, 11.414, 3.414],
['L', 10.586, 2.5860000000000003],
['A', 2, 2, 0, 0, 0, 9.172, 2.0000000000000004],
['H', 6.828000000000001],
['A', 2, 2, 0, 0, 0, 5.4140000000000015, 2.5860000000000003],
['L', 4.586000000000001, 3.414],
['A', 2, 2, 0, 0, 1, 3.1720000000000015, 4],
['H', 2.0000000000000018],
['Z'],
['M', 10.5, 8.5],
['A', 2.5, 2.5, 0, 0, 0, 5.5, 8.5],
['A', 2.5, 2.5, 0, 1, 0, 10.5, 8.5],
['Z'],
['M', 2.5, 6],
['A', 0.5, 0.5, 0, 0, 1, 2.5, 5],
['A', 0.5, 0.5, 0, 1, 1, 2.5, 6],
['Z'],
['M', 11.5, 8.5],
['A', 3.5, 3.5, 0, 1, 1, 4.5, 8.5],
['A', 3.5, 3.5, 0, 0, 1, 11.5, 8.5],
['Z'],
]);
});
});
40 changes: 40 additions & 0 deletions __tests__/unit/path/path-2-string.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,46 @@ describe('path to string', () => {
expect(path2String(getCirclePath(0, 0, 100, 100))).toEqual(
'M-100 100A100 100 0 1 0 100 100A100 100 0 1 0 -100 100Z',
);

expect(
path2String(
[
['M', 2, 4],
['A', 2, 2, 0, 0, 0, 0, 6],
['V', 12],
['A', 2, 2, 0, 0, 0, 2, 14],
['H', 14],
['A', 2, 2, 0, 0, 0, 16, 12],
['V', 6],
['A', 2, 2, 0, 0, 0, 14, 4],
['H', 12.828],
['A', 2, 2, 0, 0, 1, 11.414, 3.414],
['L', 10.586, 2.5860000000000003],
['A', 2, 2, 0, 0, 0, 9.172, 2.0000000000000004],
['H', 6.828000000000001],
['A', 2, 2, 0, 0, 0, 5.4140000000000015, 2.5860000000000003],
['L', 4.586000000000001, 3.414],
['A', 2, 2, 0, 0, 1, 3.1720000000000015, 4],
['H', 2.0000000000000018],
['Z'],
['M', 10.5, 8.5],
['A', 2.5, 2.5, 0, 0, 0, 5.5, 8.5],
['A', 2.5, 2.5, 0, 1, 0, 10.5, 8.5],
['Z'],
['M', 2.5, 6],
['A', 0.5, 0.5, 0, 0, 1, 2.5, 5],
['A', 0.5, 0.5, 0, 1, 1, 2.5, 6],
['Z'],
['M', 11.5, 8.5],
['A', 3.5, 3.5, 0, 1, 1, 4.5, 8.5],
['A', 3.5, 3.5, 0, 0, 1, 11.5, 8.5],
['Z'],
],
3,
),
).toEqual(
'M2 4A2 2 0 0 0 0 6V12A2 2 0 0 0 2 14H14A2 2 0 0 0 16 12V6A2 2 0 0 0 14 4H12.828A2 2 0 0 1 11.414 3.414L10.586 2.586A2 2 0 0 0 9.172 2H6.828A2 2 0 0 0 5.414 2.586L4.586 3.414A2 2 0 0 1 3.172 4H2ZM10.5 8.5A2.5 2.5 0 0 0 5.5 8.5A2.5 2.5 0 1 0 10.5 8.5ZM2.5 6A0.5 0.5 0 0 1 2.5 5A0.5 0.5 0 1 1 2.5 6ZM11.5 8.5A3.5 3.5 0 1 1 4.5 8.5A3.5 3.5 0 0 1 11.5 8.5Z',
);
});

it('should stringify path with precision correctly.', () => {
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.0.2",
"version": "3.1.0",
"license": "MIT",
"sideEffects": false,
"main": "lib/index.js",
Expand Down

0 comments on commit a273ca2

Please sign in to comment.