Image Translucency – Fyne Golang GUI Tutorial 77

This is fyne series tutorial.

in this tutorial, we are going to learn about translucency in fyne , Golang GUI.

To declear image we normally use :

[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”]

img := canvas.NewImageFromFile("bg.jpg")
[/sourcecode]

To modify translucency we can use values from 0 to 0.9
[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”]

img.Translucency = 0.9 // you can use 0 to 0.99

[/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

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

func main() {
// new app
a := app.New()
// new window
w := a.NewWindow("Image Translucency-Alpha")
w.Resize(fyne.NewSize(400, 400))
img := canvas.NewImageFromFile("bg.jpg")
img.Translucency = 0.9 // you can use 0.1 to 0.99
// set content
w.SetContent(img) // we will create image variable
w.ShowAndRun()
}
[/sourcecode] [easy_media_download url=”http://blogvali.com/wp-content/uploads/fyne-golang-downloads/main13.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: