mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-08-28 22:08:54 -04:00
Change implementation of PathItem#flatten(flatness)
- flatness parameter specifies maximum allowed error instead of maximum allowed distance between point - Parts that are already flat are not further flattened - Corners are preserved Closes #618
This commit is contained in:
parent
ed4347714b
commit
9e8fcee8cd
5 changed files with 108 additions and 91 deletions
|
@ -370,8 +370,12 @@ test('path.curves on closed paths', function() {
|
|||
test('path.flatten(maxDistance)', function() {
|
||||
var path = new Path.Circle(new Size(80, 50), 35);
|
||||
|
||||
// Convert its curves to points, with a max distance of 20:
|
||||
path.flatten(20);
|
||||
// Convert its curves to points, with a flatness of 5:
|
||||
path.flatten(5);
|
||||
|
||||
equals(function() {
|
||||
return path.segments.length;
|
||||
}, 8, 'Using a flatness of 10, we should end up with 8 segments.');
|
||||
|
||||
equals(function() {
|
||||
return path.lastSegment.point.equals(path.firstSegment.point);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue