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

30 lines
870 B
JavaScript
Raw Normal View History

2021-01-31 09:22:15 +01:00
export default (part) => {
2019-08-03 15:03:33 +02:00
let { Point, points, Path, paths, utils, snippets, Snippet } = part.shorthand()
2019-02-19 18:38:22 +01:00
2019-08-03 15:03:33 +02:00
points.start = new Point(10, 15)
points.cp1 = new Point(80, 10)
points.cp2 = new Point(-50, 80)
points.end = new Point(110, 70)
2019-02-19 18:38:22 +01:00
2019-08-03 15:03:33 +02:00
paths.curve = new Path().move(points.start).curve(points.cp1, points.cp2, points.end)
2019-02-19 18:38:22 +01:00
for (let x of [30, 40]) {
2019-08-03 15:03:33 +02:00
points['from' + x] = new Point(x, 10)
points['to' + x] = new Point(x, 80)
paths['line' + x] = new Path()
.move(points['from' + x])
.line(points['to' + x])
.attr('class', 'lining dashed')
2019-02-19 18:38:22 +01:00
}
snippets.i40 = new Snippet(
2019-08-03 15:03:33 +02:00
'notch',
2019-02-19 18:38:22 +01:00
utils.curveIntersectsX(points.start, points.cp1, points.cp2, points.end, 40)
2019-08-03 15:03:33 +02:00
)
2019-02-19 18:38:22 +01:00
2019-08-03 15:03:33 +02:00
for (let p of utils.curveIntersectsX(points.start, points.cp1, points.cp2, points.end, 30))
snippets[p.y] = new Snippet('notch', p)
2019-02-19 18:38:22 +01:00
2019-08-03 15:03:33 +02:00
return part
}