Class 11 fyne GoLang GUI Canvas Line

I this tutorial we are going to create a basic LINE in fyne & golang.
Here is single line code to create a LINE.

[sourcecode lang=”go”] lineX := canvas.NewLine(color.Black)
[/sourcecode] You can change color of LINE.

[sourcecode lang=”go”] //fill color
lineX.FillColor = color.NRGBA{R: 255, G: 255, B: 0, A: 255}
[/sourcecode] You can change stroke of LINE.

[sourcecode lang=”go”] // Add Stroke
lineX.StrokeColor = color.NRGBA{R: 0, G: 255, B: 0, A: 255}
[/sourcecode]

You can change stroke width of LINE.
[sourcecode lang=”go”] //Change stroke width

lineX.StrokeWidth = 12.0
[/sourcecode] [sourcecode lang=”go” autolinks=”false” classname=”myclass” collapse=”false” firstline=”1″ gutter=”true” highlight=”1-3,6,9″ htmlscript=”false” light=”false” padlinenumbers=”false” smarttabs=”true” tabsize=”4″ toolbar=”false” title=”Source Code main.go”]

package main

// importing fyne
import (
"image/color"

"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/canvas"
)

func main() {
// creating new app
a := app.New()
// creating new window and title
w := a.NewWindow("Line : Canvas tutorial")
// resizing my windows
w.Resize(fyne.NewSize(400, 400))
// creating line
lineX := canvas.NewLine(color.Black)
lineX.StrokeColor = color.NRGBA{R: 0, G: 255, B: 0, A: 255}
lineX.StrokeWidth = 12.0
//setup content
w.SetContent(lineX)

// Running app
w.ShowAndRun()
}

[/sourcecode] [easy_media_download url=”http://blogvali.com/wp-content/uploads/fyne-golang-downloads/main11.go” text=”Download Code” color=”red_darker”]

Fyne GoLang GUI Course

 

Tony BB
 

TonyBB is a Coach , marketer, hypnotist and a founder of RSKVF Production who specializes in providing simple, affordable, and easy to use solutions for Life.

Click Here to Leave a Comment Below 0 comments

Leave a Reply: