fix get fill template

This commit is contained in:
casperlamboo 2016-04-22 19:37:34 +02:00
parent 00c94f5d67
commit 09bd688b88

View File

@ -1,31 +1,31 @@
import Shape from 'Doodle3D/clipper-js'; import Shape from 'Doodle3D/clipper-js';
export default function getFillTemplate(bounds, size, even, uneven) { export default function getFillTemplate(bounds, size, even, uneven) {
var shape = new Shape([], false); const paths = [];
var left = Math.floor(bounds.left / size) * size; const left = Math.floor(bounds.left / size) * size;
var right = Math.ceil(bounds.right / size) * size; const right = Math.ceil(bounds.right / size) * size;
var top = Math.floor(bounds.top / size) * size; const top = Math.floor(bounds.top / size) * size;
var bottom = Math.ceil(bounds.bottom / size) * size; const bottom = Math.ceil(bounds.bottom / size) * size;
var width = right - left; const width = right - left;
if (even) { if (even) {
for (var y = top; y <= bottom + width; y += size) { for (let y = top; y <= bottom + width; y += size) {
shape.paths.push([ paths.push([
{X: left, Y: y}, { x: left, y },
{X: right, Y: y - width} { x: right, y: y - width }
]); ]);
} }
} }
if (uneven) { if (uneven) {
for (var y = top - width; y <= bottom; y += size) { for (let y = top - width; y <= bottom; y += size) {
shape.paths.push([ paths.push([
{X: left, Y: y}, { x: left, y },
{X: right, Y: y + width} { x: right, y: y + width }
]); ]);
} }
} }
return shape; return new Shape(paths, false, true);
} }