-
My app is used for voice speech recognition, I want to show the speech text directly on the screen. I found a transparent My code: package main
import (
"image/color"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/driver/desktop"
"fyne.io/fyne/v2/theme"
"github.com/go-gl/glfw/v3.3/glfw"
)
type myTheme struct{}
// Set canvas bg color to transparent
func (m myTheme) Color(name fyne.ThemeColorName, variant fyne.ThemeVariant) color.Color {
transparent := color.NRGBA{R: 0, G: 0, B: 0, A: 0}
return transparent
}
// Just use default font
func (m myTheme) Icon(name fyne.ThemeIconName) fyne.Resource {
return theme.DefaultTheme().Icon(name)
}
// Just use default font
func (m myTheme) Font(style fyne.TextStyle) fyne.Resource {
return theme.DefaultTheme().Font(style)
}
func (m myTheme) Size(name fyne.ThemeSizeName) float32 {
return theme.DefaultTheme().Size(name)
}
var blue = color.NRGBA{R: 0x0d, G: 0x93, B: 0xb4, A: 224}
func newText(text string) *canvas.Text {
t := canvas.NewText(text, blue)
t.TextSize = 40
return t
}
func main() {
a := app.New()
// these two lines are for transparent splash window
a.Settings().SetTheme(&myTheme{})
if glfw.Init() == nil {
glfw.WindowHint(glfw.TransparentFramebuffer, glfw.True)
}
if drv, ok := a.Driver().(desktop.Driver); ok {
w := drv.CreateSplashWindow()
w.SetContent(newText("aaaaaa"))
w.Show()
}
a.Run()
} |
Beta Was this translation helpful? Give feedback.
Answered by
Jacalz
Oct 20, 2022
Replies: 1 comment 2 replies
-
I believe that #3156 is the issue related to what you want to do. I don't think there is much to do until that is implemented, unfortunately. Similar to #3237 as well. |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
aj3423
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I believe that #3156 is the issue related to what you want to do. I don't think there is much to do until that is implemented, unfortunately. Similar to #3237 as well.