~eliasnaur/gio#444: 
Drawing stroke to same point twice causes whisker

The following program calls LineTo to the same point twice, which causes a thin whisker going straight down to appear.

This is probably similar to https://todo.sr.ht/~eliasnaur/gio/331 and would probably be superseded by https://todo.sr.ht/~eliasnaur/gio/379.

package main

import (
	"image/color"
	"os"
	
	"gioui.org/app"
	"gioui.org/f32"
	"gioui.org/io/system"
	"gioui.org/op"
	"gioui.org/op/clip"
	"gioui.org/op/paint"
)
	
func main() {
	go func() {
		win := app.NewWindow()
		var ops op.Ops
		for e := range win.Events() {
			switch ev := e.(type) {
			case system.DestroyEvent:
				os.Exit(0)
			case system.FrameEvent:
				ops.Reset()
	
				var p clip.Path
				p.Begin(&ops)
				p.MoveTo(f32.Pt(30, 120))
				p.LineTo(f32.Pt(300, 30))
				p.LineTo(f32.Pt(300, 30)) // this line causes the bug
	
				o := clip.Stroke{
					Path:  p.End(),
					Width: 6,
				}.Op()
	
				paint.FillShape(&ops, color.NRGBA{0, 0, 0, 0xFF}, o)
	
				ev.Frame(&ops)
			}
		}
	}()
	app.Main()
}

I've also attached a screenshot (hoping that Sourcehut won't eat it.

Status
REPORTED
Submitter
Dominik Honnef
Assigned to
No-one
Submitted
3 months ago
Updated
5 days ago
Labels
No labels applied.

~famex 23 days ago*


~lotodore 5 days ago

This seems to be the same issue as https://todo.sr.ht/~eliasnaur/gio/451 Workaround is to call MoveTo every time before LineTo.

Register here or Log in to comment, or comment via email.