A
A
Alexey Babiev2022-02-08 09:55:30
go
Alexey Babiev, 2022-02-08 09:55:30

How to draw a dot on fyne (go) canvas?

application on go. fyne.io

is used as GUI

package main

import (
  "image/color"
  "fyne.io/fyne/v2/app"
  "fyne.io/fyne/v2/canvas"
)

func main() {
  a := app.New()
  w := a.NewWindow("The dots")
  cnvs := w.Canvas()

  red := color.NRGBA{255, 0, 0, 128}
  // blue := color.NRGBA{0, 0, 255, 128}
  rect := canvas.NewRectangle(red)
  cnvs.SetContent(rect)

  // Здесь хочется перекрасить пиксель в координатах х=50; у=80 в синий цвет
  // cnvs.SetPixel(blue, 50, 80)

  w.ShowAndRun()
}


In the code, I commented out the pseudo-method in search of which I turned to you

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WinPooh32, 2022-02-08
@WinPooh32

See the canvas.Raster part :

raster := canvas.NewRasterWithPixels(
    func(_, _, w, h int) color.Color {
      return color.RGBA{uint8(rand.Intn(255)),
        uint8(rand.Intn(255)),
        uint8(rand.Intn(255)), 0xff}
    })

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question