Doodle3D-Slicer/src/sliceActions/getFillTemplate.js

32 lines
756 B
JavaScript
Raw Normal View History

2016-04-21 22:14:22 +02:00
import Shape from 'Doodle3D/clipper-js';
export default function getFillTemplate(bounds, size, even, uneven) {
2016-04-21 22:14:22 +02:00
var shape = new Shape([], false);
var left = Math.floor(bounds.left / size) * size;
var right = Math.ceil(bounds.right / size) * size;
var top = Math.floor(bounds.top / size) * size;
var bottom = Math.ceil(bounds.bottom / size) * size;
var width = right - left;
if (even) {
for (var y = top; y <= bottom + width; y += size) {
2016-04-21 22:14:22 +02:00
shape.paths.push([
{X: left, Y: y},
{X: right, Y: y - width}
]);
}
}
if (uneven) {
for (var y = top - width; y <= bottom; y += size) {
2016-04-21 22:14:22 +02:00
shape.paths.push([
{X: left, Y: y},
{X: right, Y: y + width}
]);
}
}
2016-04-21 22:14:22 +02:00
return shape;
}