1
0
Fork 0
freesewing/packages/rendertest/src/text.js

40 lines
1 KiB
JavaScript
Raw Normal View History

2019-05-07 12:50:49 +02:00
export default function(part) {
2019-08-03 15:03:33 +02:00
let { Point, Path, points, paths, store } = part.shorthand()
2019-05-07 12:50:49 +02:00
2019-08-03 15:03:33 +02:00
let y = store.get('y')
let w = store.get('w')
let text = ['xs', 'sm', '', 'l', 'xl', 'xxl']
y += 10
points.tl = new Point(0, y)
points.tr = new Point(w, y)
2019-05-07 12:50:49 +02:00
paths.text = new Path()
.move(points.tl)
.line(points.tr)
2019-08-03 15:03:33 +02:00
.attr('data-text', 'text')
y += 10
points.tlc = new Point(0, y)
points.trc = new Point(w, y)
2019-05-07 12:50:49 +02:00
paths.textc = new Path()
.move(points.tlc)
.line(points.trc)
2019-08-03 15:03:33 +02:00
.attr('data-text', 'text.center')
.attr('data-text-class', 'center')
y += 10
points.tlr = new Point(0, y)
points.trr = new Point(w, y)
2019-05-07 12:50:49 +02:00
paths.textr = new Path()
.move(points.tlr)
.line(points.trr)
2019-08-03 15:03:33 +02:00
.attr('data-text', 'text.right')
.attr('data-text-class', 'right')
for (let i = 0; i < text.length; i++) {
2019-08-03 15:03:33 +02:00
y += 15
points['t' + i] = new Point(0, y)
.attr('data-text', 'text' + (text[i] === '' ? '' : '.text-' + text[i]))
.attr('data-text-class', 'text-' + text[i])
2019-05-07 12:50:49 +02:00
}
2019-08-03 15:03:33 +02:00
store.set('y', y)
2019-05-07 12:50:49 +02:00
2019-08-03 15:03:33 +02:00
return part
2019-05-07 12:50:49 +02:00
}