2016-04-21 22:14:22 +02:00
|
|
|
import Shape from 'Doodle3D/clipper-js';
|
2016-03-29 00:26:58 +02:00
|
|
|
|
|
|
|
export default function getFillTemplate(bounds, size, even, uneven) {
|
2016-04-21 22:14:22 +02:00
|
|
|
var shape = new Shape([], false);
|
2016-03-29 00:26:58 +02:00
|
|
|
|
|
|
|
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([
|
2016-03-29 00:26:58 +02:00
|
|
|
{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([
|
2016-03-29 00:26:58 +02:00
|
|
|
{X: left, Y: y},
|
|
|
|
{X: right, Y: y + width}
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-21 22:14:22 +02:00
|
|
|
return shape;
|
2016-03-29 00:26:58 +02:00
|
|
|
}
|