fyne-widgets/examples/audiospectrum/main.go

45 lines
1.4 KiB
Go
Raw Normal View History

2022-02-11 18:32:22 +00:00
package main
import (
"image/color"
"math/rand"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/theme"
"git.martyn.berlin/martyn/fyne-widgets/pkg/audiospectrum"
"git.martyn.berlin/martyn/fyne-widgets/pkg/layouts"
)
func main() {
a := app.New()
w := a.NewWindow("VUMeter")
randomAudioData := make([]int32, 1200)
for i := 0; i < 1200; i++ {
randomAudioData[i] = rand.Int31()
}
as := audiospectrum.NewAudioSpectrum(randomAudioData)
as2 := audiospectrum.NewAudioSpectrum(randomAudioData)
as2.OverrideBackground = true
as2.OverrideBackgroundColor = color.RGBA{0, 0, 0xff, 0xff} // no effect because of the next line
as2.TransparentBackground = true
as2.SetMinSize(fyne.NewSize(1200, 64))
as3 := audiospectrum.NewAudioSpectrum(randomAudioData)
as3.StretchSamples = true
as3.SetMinSize(fyne.NewSize(100, 64))
as3.OverrideForeground = true
as3.OverrideForegroundColor = color.RGBA{0xff, 0, 0, 0xff}
as3.TransparentBackground = false
layout := layouts.NewFloatingControlsLayout()
layout.FloatingControlsLocation = layouts.FloatingControlsCenter
image := canvas.NewImageFromResource(theme.FyneLogo())
image.SetMinSize(fyne.NewSize(200, 64*3))
contain := container.New(&layout, container.NewBorder(image, as, nil, nil, as3), container.NewBorder(nil, nil, nil, nil, as2))
w.SetContent(contain)
w.ShowAndRun()
}