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

29 lines
787 B
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, Snippet, snippets, utils } = part.shorthand()
2019-01-27 12:54:18 +01:00
2019-08-03 15:03:33 +02:00
points.start = new Point(10, 10)
points.cp1 = new Point(90, 10)
points.cp2 = new Point(10, 60)
points.end = new Point(90, 60)
2019-01-27 12:54:18 +01:00
2019-08-03 15:03:33 +02:00
let scatter = []
2019-01-27 12:54:18 +01:00
for (let i = 1; i < 19; i++) {
for (let j = 1; j < 14; j++) {
2019-08-03 15:03:33 +02:00
scatter.push(new Point(i * 10, j * 10))
2019-01-27 12:54:18 +01:00
}
}
2019-08-03 15:03:33 +02:00
let snippet
2019-01-27 12:54:18 +01:00
for (let point of scatter) {
2019-08-03 15:03:33 +02:00
if (utils.pointOnCurve(points.start, points.cp1, points.cp2, points.end, point)) {
snippet = 'notch'
} else snippet = 'bnotch'
snippets[part.getId()] = new Snippet(snippet, point)
2019-01-27 12:54:18 +01:00
}
paths.curve = new Path()
.move(points.start)
.curve(points.cp1, points.cp2, points.end)
2019-08-03 15:03:33 +02:00
.attr('class', 'fabric stroke-lg')
2019-01-27 12:54:18 +01:00
2019-08-03 15:03:33 +02:00
return part
}