Doodle3D-Slicer/src/getFillTemplate.js
casperlamboo dd71c872d4 move file
2017-06-22 13:21:18 +02:00

32 lines
764 B
JavaScript

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