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:
Jürg Lehni 2016-02-10 14:58:40 +01:00
parent ed4347714b
commit 9e8fcee8cd
5 changed files with 108 additions and 91 deletions

View file

@ -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);