-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix(label): only consider interaction between valid box when layouting * fix(label): fix NaN return for coline points when cal centroid * test(label): add test case for isInteract and getPolygonCentroid * refactor(util): tidy code of graphics * fix(collision-detect): fix -Infinity
- Loading branch information
Showing
4 changed files
with
95 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { getPolygonCentroid } from '../../../src/util/graphics'; | ||
|
||
describe('test getPolygonCentroid', () => { | ||
test('getPolygonCentroid can handle colline points', () => { | ||
const x1 = [1, 1, 1, 1]; | ||
const y1 = [0, 3, 4, 2]; | ||
|
||
expect(getPolygonCentroid(x1, y1)).toEqual([1, 2]); | ||
|
||
const x2 = y1; | ||
const y2 = x1; | ||
expect(getPolygonCentroid(x2, y2)).toEqual([2, 1]); | ||
|
||
const x3 = x1; | ||
const y3 = x1; | ||
expect(getPolygonCentroid(x3, y3)).toEqual([1, 1]); | ||
}); | ||
}); |