1
0
Fork 0

fix(plugin-bartack): Small fixes in fractional bartack

This commit is contained in:
Joost De Cock 2022-01-16 17:33:48 +01:00
parent c421a485e1
commit a8fc17e453
2 changed files with 21 additions and 8 deletions

View file

@ -34,6 +34,7 @@ const getPoints = (path, so) => {
points.path2.push(path2.shiftFractionAlong((1 / steps) * i))
}
console.log(points, path.length(), path)
return points
}
@ -70,17 +71,21 @@ export default function bartack(so, self) {
// Along path
let start = false
let end = false
if (so.bartackAlong) {
if (so.start > 0) start = so.path.shiftAlong(so.start)
end = so.path.shiftAlong(so.end)
} else if (so.bartackFractionAlong) {
if (so.bartackAlong) guide = so.path.clone()
else if (so.bartackFractionAlong) {
if (so.start === so.end) return null
if (so.start > so.end) {
const newEnd = so.start
so.start = so.end
so.end = newEnd
}
if (so.start > 0) start = so.path.shiftFractionAlong(so.start)
if (so.end < 1) end = so.path.shiftFractionAlong(so.end)
if (start && end) guide = so.path.split(start).pop().split(end).shift()
else if (start) guide = so.path.split(start).pop()
else if (end) guide = so.path.split(end).shift()
else guide = so.path.clone()
}
if (start && end) guide = so.path.split(start).pop().split(end).shift()
else if (start) guide = so.path.split(start).pop()
else if (end) guide = so.path.split(end).shift()
else guide = so.path.clone()
}
self.paths[name('bartack', so)] = bartackPath(guide, so, self).attr('class', 'stroke-sm stroke-mark')