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

54 lines
1.2 KiB
JavaScript
Raw Normal View History

2019-05-30 21:19:06 +02:00
export default function(part) {
2019-08-03 15:03:33 +02:00
let { points, Path, paths, macro } = part.shorthand()
2019-05-30 21:19:06 +02:00
let rotateThese = [
2019-08-03 15:03:33 +02:00
'edgeTopLeftCp',
'edgeTop',
'tipRight',
'tipRightTop',
'tipRightTopStart',
'tipRightTopCp1',
'tipRightTopCp2',
'tipRightTopEnd',
'tipRightBottomStart',
'tipRightBottomCp1',
'tipRightBottomCp2',
'tipRightBottomEnd',
'tipRightBottom',
'top',
'topCp2'
]
2019-05-30 21:19:06 +02:00
while (points.tipRightBottomStart.x > -1) {
2019-08-03 15:03:33 +02:00
for (let p of rotateThese) points[p] = points[p].rotate(1, points.edgeLeft)
2019-05-30 21:19:06 +02:00
}
2019-08-03 15:03:33 +02:00
points.snapLeft = points.top.shiftFractionTowards(points.edgeTop, 0.5)
2019-05-30 21:19:06 +02:00
2019-08-03 15:03:33 +02:00
macro('round', {
2019-05-30 21:19:06 +02:00
from: points.edgeTop,
to: points.tipRight,
via: points.tipRightTop,
2019-08-03 15:03:33 +02:00
prefix: 'tipRightTop',
2019-05-30 21:19:06 +02:00
render: true
2019-08-03 15:03:33 +02:00
})
macro('round', {
2019-05-30 21:19:06 +02:00
from: points.tipRight,
to: points.top,
via: points.tipRightBottom,
2019-08-03 15:03:33 +02:00
prefix: 'tipRightBottom',
2019-05-30 21:19:06 +02:00
render: true
2019-08-03 15:03:33 +02:00
})
2019-05-30 21:19:06 +02:00
paths.rect = new Path()
.move(points.edgeTop)
.curve(points.edgeTopLeftCp, points.edgeLeftCp, points.edgeLeft)
.line(points.bottomLeft)
.line(points.bottomRight)
.line(points.edgeRight)
.curve(points.edgeRightCp, points.edgeTopRightCp, points.edgeTop)
2019-08-03 15:03:33 +02:00
.close()
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
}