Skip to content

Commit

Permalink
op/clip: prevent no-op path segments
Browse files Browse the repository at this point in the history
This commit prevents the insertion of LineTo and QuadTo path segments that have
no visible effect on the path (because the path's pen is already at their end state).
This eliminates whisker artifacts from some stroked paths. Thanks to Morlay for the
bug report leading to this fix.

Fixes: https://todo.sr.ht/~eliasnaur/gio/535
Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
  • Loading branch information
whereswaldon authored and eliasnaur committed Sep 18, 2023
1 parent 313c488 commit 27193ae
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions op/clip/clip.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ func (p *Path) Line(delta f32.Point) {

// LineTo moves the pen to the absolute point specified, recording a line.
func (p *Path) LineTo(to f32.Point) {
if to == p.pen {
return
}
data := ops.WriteMulti(p.ops, scene.CommandSize+4)
bo := binary.LittleEndian
bo.PutUint32(data[0:], uint32(p.contour))
Expand Down Expand Up @@ -250,6 +253,9 @@ func (p *Path) Quad(ctrl, to f32.Point) {
// QuadTo records a quadratic Bézier from the pen to end
// with the control point ctrl, with absolute coordinates.
func (p *Path) QuadTo(ctrl, to f32.Point) {
if ctrl == p.pen && to == p.pen {
return
}
data := ops.WriteMulti(p.ops, scene.CommandSize+4)
bo := binary.LittleEndian
bo.PutUint32(data[0:], uint32(p.contour))
Expand Down

0 comments on commit 27193ae

Please sign in to comment.