-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(g-canvas): bbox calculation for path is incorrect when angle is 0…
… and π, close antvis#254
- Loading branch information
1 parent
992e2bc
commit d526886
Showing
2 changed files
with
33 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const expect = require('chai').expect; | ||
import Canvas from '../../src/canvas'; | ||
|
||
const dom = document.createElement('div'); | ||
document.body.appendChild(dom); | ||
dom.id = 'c1'; | ||
|
||
describe('#254', () => { | ||
const canvas = new Canvas({ | ||
container: dom, | ||
width: 600, | ||
height: 600, | ||
}); | ||
|
||
it('bbox calculation for path should consider angle of 0 and PI', () => { | ||
const shape = canvas.addShape({ | ||
type: 'path', | ||
attrs: { | ||
path: [['M', 300, 500], ['L', 300, 375], ['L', 300, 500], ['Z']], | ||
lineWidth: 5, | ||
stroke: 'red', | ||
}, | ||
}); | ||
const bbox = shape.getBBox(); | ||
expect(bbox.minX).eqls(297.5); | ||
expect(bbox.minY).eqls(372.5); | ||
expect(bbox.maxX).eqls(302.5); | ||
expect(bbox.maxY).eqls(502.5); | ||
}); | ||
}); |