1
0
Fork 0
freesewing/packages/carlton/src/belt.js

86 lines
2.3 KiB
JavaScript
Raw Normal View History

2019-03-25 18:20:15 +01:00
export default function(part) {
2019-03-30 14:54:30 +01:00
let { paperless, sa, snippets, Snippet, store, complete, points, measurements, options, macro, Point, paths, Path } = part.shorthand();
2019-03-25 18:20:15 +01:00
let length = 1.6 * (store.get("cbToDart") + store.get("dartToSide"));
let width = measurements.centerBackNeckToWaist * options.beltWidth;
points.topLeft = new Point(0, 0);
points.topRight = new Point(length, 0);
points.bottomLeft = new Point(0, width);
points.bottomRight = new Point(length, width);
points.button = new Point(width/2, width/2);
macro("round", {
from: points.topRight,
to: points.bottomLeft,
via: points.topLeft,
prefix: "roundTop",
radius: width/4,
render: true
});
macro("round", {
from: points.topLeft,
to: points.bottomRight,
via: points.bottomLeft,
prefix: "roundBottom",
radius: width/4,
render: true
});
// Paths
paths.seam = new Path()
.move(points.roundTopStart)
.curve(points.roundTopCp1, points.roundTopCp2, points.roundTopEnd)
.line(points.roundBottomStart)
.curve(points.roundBottomCp1, points.roundBottomCp2, points.roundBottomEnd)
.line(points.bottomRight)
.line(points.topRight)
.line(points.roundTopStart)
.close()
.attr("class", "fabric");
if (complete) {
snippets.button = new Snippet("button", points.button).attr("data-scale", 2);
points.title = new Point(
points.bottomRight.x/2,
points.bottomRight.y/2
);
macro("title", {
at: points.title,
nr: 6,
title: "belt"
});
points.logo = new Point(
points.bottomRight.x * 0.75,
points.bottomRight.y * 0.65
);
snippets.logo = new Snippet("logo", points.logo);
if (sa) paths.sa = paths.seam.offset(sa).attr("class", "fabric sa");
if (paperless) {
macro("hd", {
from: points.roundBottomStart,
to: points.roundBottomEnd,
y: points.roundBottomEnd.y + sa + 15
});
macro("hd", {
from: points.roundBottomStart,
to: points.button,
y: points.roundBottomEnd.y + sa + 30
});
macro("hd", {
from: points.roundBottomStart,
to: points.bottomRight,
y: points.roundBottomEnd.y + sa + 45
});
macro("vd", {
from: points.bottomRight,
to: points.topRight,
x: points.topRight.x + sa + 15
});
}
2019-03-25 18:20:15 +01:00
}
return part;
}