1
0
Fork 0
freesewing/packages/tutorial/src/step1.js

61 lines
1.2 KiB
JavaScript
Raw Normal View History

2019-05-30 21:19:06 +02:00
export default function(part) {
let {
options,
Point,
Path,
points,
paths,
Snippet,
snippets,
complete,
sa,
paperless,
macro
2019-08-03 15:03:33 +02:00
} = part.shorthand()
2019-05-30 21:19:06 +02:00
2019-08-03 15:03:33 +02:00
let w = 500 * options.size
points.topLeft = new Point(0, 0)
points.topRight = new Point(w, 0)
points.bottomLeft = new Point(0, w / 2)
points.bottomRight = new Point(w, w / 2)
2019-05-30 21:19:06 +02:00
paths.seam = new Path()
.move(points.topLeft)
.line(points.bottomLeft)
.line(points.bottomRight)
.line(points.topRight)
.line(points.topLeft)
.close()
2019-08-03 15:03:33 +02:00
.attr('class', 'fabric')
2019-05-30 21:19:06 +02:00
// Complete?
if (complete) {
2019-08-03 15:03:33 +02:00
points.logo = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5)
snippets.logo = new Snippet('logo', points.logo)
2019-05-30 21:19:06 +02:00
points.text = points.logo
.shift(-90, w / 8)
2019-08-03 15:03:33 +02:00
.attr('data-text', 'hello')
.attr('data-text-class', 'center')
2019-05-30 21:19:06 +02:00
if (sa) {
2019-08-03 15:03:33 +02:00
paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa')
2019-05-30 21:19:06 +02:00
}
}
// Paperless?
if (paperless) {
2019-08-03 15:03:33 +02:00
macro('hd', {
2019-05-30 21:19:06 +02:00
from: points.bottomLeft,
to: points.bottomRight,
y: points.bottomLeft.y + sa + 15
2019-08-03 15:03:33 +02:00
})
macro('vd', {
2019-05-30 21:19:06 +02:00
from: points.bottomRight,
to: points.topRight,
x: points.topRight.x + sa + 15
2019-08-03 15:03:33 +02:00
})
2019-05-30 21:19:06 +02:00
}
2019-08-03 15:03:33 +02:00
return part
2019-05-30 21:19:06 +02:00
}