simplify getOutline function

This commit is contained in:
casperlamboo 2017-05-16 10:44:48 +02:00 committed by Simon Voordouw
parent 0c1c47c0c1
commit e1336581dc

View File

@ -5,17 +5,10 @@ export default class {
this.parts = [];
}
getOutline() {
const outLines = new Shape([], true);
for (let i = 0; i < this.parts.length; i ++) {
const part = this.parts[i];
if (part.shape.closed) {
outLines.join(this.parts[i].outerLine);
}
}
return outLines;
return this.parts.reduce((shape, part) => {
if (part.outerLine) shape.join(part.outerLine);
return shape;
}, new Shape([], true));
}
add(shape) {
const part = { shape };