Skip to content

Circle

This example demonstrates how to draw a simple circle shape using Fyne’s canvas package.

Show 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"
"fyne.io/fyne/v2/widget"
)
func main() {
myApp := app.New()
myWindow := myApp.NewWindow("Circle")
// Create a blue circle
circle := canvas.NewCircle(color.RGBA{R: 0, G: 0, B: 255, A: 255})
circle.StrokeColor = color.Gray{Y: 0x99}
circle.StrokeWidth = 5
// Create centered text
label := widget.NewLabel("Go!")
label.Alignment = fyne.TextAlignCenter
// Stack text on circle
content := container.NewStack(
circle, // background
container.NewCenter(label), // centered label
)
myWindow.SetContent(content)
myWindow.Resize(fyne.NewSize(250, 200))
myWindow.ShowAndRun()
}