mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-12-23 19:43:48 +01:00
fix get fill template
This commit is contained in:
parent
3f43477ef6
commit
9e6dcf08f9
@ -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);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user