Join stroke ends when they coincide

This commit is contained in:
Taco de Wolff 2017-05-21 20:59:03 +02:00
parent bcfeb16b74
commit 4976a25b5e

View file

@ -438,12 +438,19 @@ func (k *stroker) stroke(q Path) {
if len(k.r) == 0 {
return
}
// TODO(nigeltao): if q is a closed curve then we should join the first and
// last segments instead of capping them.
k.cr.Cap(k.p, k.u, q.lastPoint(), pNeg(k.anorm))
closed := q.firstPoint() == q.lastPoint()
if !closed {
k.cr.Cap(k.p, k.u, q.lastPoint(), pNeg(k.anorm))
} else {
pivot := q.firstPoint()
k.jr.Join(k.p, &k.r, k.u, pivot, k.anorm, pivot.Sub(fixed.Point26_6{k.r[1], k.r[2]}))
}
addPathReversed(k.p, k.r)
pivot := q.firstPoint()
k.cr.Cap(k.p, k.u, pivot, pivot.Sub(fixed.Point26_6{k.r[1], k.r[2]}))
if !closed {
pivot := q.firstPoint()
k.cr.Cap(k.p, k.u, pivot, pivot.Sub(fixed.Point26_6{k.r[1], k.r[2]}))
}
}
// Stroke adds q stroked with the given width to p. The result is typically