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

57 lines
1.5 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, options } = part.shorthand()
2019-05-21 20:24:14 +02:00
const textClasses = label =>
2019-08-03 15:03:33 +02:00
options.focus === label ? 'center text-xs fill-note' : 'center text-xs'
2019-01-27 12:54:18 +01:00
points.A = new Point(10, 10)
2019-08-03 15:03:33 +02:00
.attr('data-text', 'Path.move()')
.attr('data-text-class', textClasses('move'))
points.B = new Point(70, 30)
points.BCp2 = new Point(40, 10)
points.C = new Point(90, -50)
points.CCp1 = new Point(125, -30)
points.D = new Point(20, -50)
points.DCp = new Point(40, 0)
points.E = new Point(-20, -20)
points.ECp = new Point(-20, -50)
2019-01-27 12:54:18 +01:00
paths.line = new Path()
2019-01-27 12:54:18 +01:00
.move(points.A)
.line(points.B)
2019-08-03 15:03:33 +02:00
.attr('data-text', 'Path.line()')
.attr('data-text-class', textClasses('line'))
2019-01-27 12:54:18 +01:00
paths.curve = new Path()
2019-01-27 12:54:18 +01:00
.move(points.B)
.curve(points.BCp2, points.CCp1, points.C)
2019-08-03 15:03:33 +02:00
.attr('data-text', 'Path.curve()')
.attr('data-text-class', textClasses('curve'))
2019-01-27 12:54:18 +01:00
paths._curve = new Path()
.move(points.C)
._curve(points.DCp, points.D)
2019-08-03 15:03:33 +02:00
.attr('data-text', 'Path._curve()')
.attr('data-text-class', textClasses('_curve'))
2019-01-27 12:54:18 +01:00
paths.curve_ = new Path()
.move(points.D)
.curve_(points.ECp, points.E)
2019-08-03 15:03:33 +02:00
.attr('data-text', 'Path.curve_()')
.attr('data-text-class', textClasses('curve_'))
2019-01-27 12:54:18 +01:00
paths.close = new Path()
.move(points.E)
.line(points.A)
2019-08-03 15:03:33 +02:00
.attr('data-text', 'Path.close()')
.attr('data-text-class', textClasses('close'))
2019-01-27 12:54:18 +01:00
paths.example = paths.line
.join(paths.curve)
.join(paths._curve)
.join(paths.curve_)
2019-08-03 15:03:33 +02:00
.close()
2019-08-03 15:03:33 +02:00
return part
}