1
0
Fork 0
freesewing/packages/examples/src/path_trim.js

37 lines
1.2 KiB
JavaScript
Raw Normal View History

2019-01-27 12:54:18 +01:00
export default part => {
2019-08-03 15:03:33 +02:00
let { Point, points, Path, paths } = part.shorthand()
2019-01-27 12:54:18 +01:00
2019-08-03 15:03:33 +02:00
points.center = new Point(0, 0)
points.base = new Point(0, 10)
points.tip = new Point(0, 50)
points.tipCpRight = new Point(30, 50)
points.tipCpLeft = new Point(-30, 50)
paths.example = new Path().move(points.base)
2019-01-27 12:54:18 +01:00
for (let i = 0; i < 4; i++) {
2019-08-03 15:03:33 +02:00
points['base' + i] = points.base.rotate(60 * i, points.center)
points['tip' + i] = points.tip.rotate(60 * i, points.center)
points['tipCpRight' + i] = points.tipCpRight.rotate(60 * i, points.center)
points['tipCpLeft' + i] = points.tipCpLeft.rotate(60 * i, points.center)
2019-01-27 12:54:18 +01:00
if (i < 2) {
paths.example
2019-08-03 15:03:33 +02:00
.line(points['base' + i])
.curve(points['base' + i], points['tipCpLeft' + i], points['tip' + i])
.curve(points['tipCpRight' + i], points['base' + i], points['base' + i])
2019-01-27 12:54:18 +01:00
} else {
paths.example
2019-08-03 15:03:33 +02:00
.line(points['base' + i])
.line(points['tip' + i])
.line(points['tipCpRight' + i])
.line(points['base' + i])
2019-01-27 12:54:18 +01:00
}
}
2019-08-03 15:03:33 +02:00
paths.offset = paths.example.offset(10).attr('class', 'lining dotted stroke-sm')
2019-01-27 12:54:18 +01:00
paths.trimmed = paths.offset
.trim()
2019-08-03 15:03:33 +02:00
.attr('class', 'various stroke-xl')
.attr('style', 'stroke-opacity: 0.5;')
return part
}