Skip to content

Instantly share code, notes, and snippets.

@edoardoc
Created September 7, 2023 10:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edoardoc/5809cd4d5e298a8fba1928af10358644 to your computer and use it in GitHub Desktop.
Save edoardoc/5809cd4d5e298a8fba1928af10358644 to your computer and use it in GitHub Desktop.
fyne v2 free drawing example
package main
import (
"image/color"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
)
func main() {
myApp := app.New()
myWindow := myApp.NewWindow("Canvas")
myCanvas := myWindow.Canvas()
myWidget := container.NewWithoutLayout()
blue := color.NRGBA{R: 0, G: 0, B: 180, A: 255}
rect := canvas.NewRectangle(blue)
myWidget.Add(rect)
rect.Resize(fyne.NewSize(100, 100))
line := canvas.NewLine(color.Black)
line.Position1 = fyne.NewPos(0, 0)
line.Position2 = fyne.NewPos(100, 100)
line.StrokeWidth = 5
myWidget.Add(line)
myCanvas.SetContent(myWidget)
myWindow.Resize(fyne.NewSize(100, 100))
myWindow.ShowAndRun()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment