Fyne Golang – Change line position horizontal & vertical
Fyne Golang – Change line position horizontal & vertical
Source Code
package main import ( "image/color" "fyne.io/fyne/v2" "fyne.io/fyne/v2/app" "fyne.io/fyne/v2/canvas" "fyne.io/fyne/v2/container" ) // main func func main() { // New app a := app.New() // new window w := a.NewWindow("Change position of line horizontal & vertical") // set windows size w.Resize(fyne.NewSize(400, 400)) // lets create our first line line1 := canvas.NewLine(color.RGBA{R: 255, G: 0, B: 0, A: 255}) // lets setup line positions line1.Position1 = fyne.NewPos(20, 40) // x= 20, y= 40 line1.Position2 = fyne.NewPos(120, 40) // x= 20, y= 140 // change the values and make it horizontal // lets make it thick line1.StrokeWidth = 5 // without using container you can't change orientation // lets create a container c := container.NewWithoutLayout(line1) // container will hold the widget // set content // now put container in the content w.SetContent(c) // we will place widgets here // show and run my app w.ShowAndRun() }