mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-11-30 01:14:57 +01:00
32 lines
770 B
JavaScript
32 lines
770 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, true);
|
|
}
|