Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "time"
- "github.com/google/gxui"
- "github.com/google/gxui/drivers/gl"
- "github.com/google/gxui/gxfont"
- "github.com/google/gxui/math"
- "github.com/google/gxui/samples/flags"
- )
- var hello = []string {"Hi", "Ave", "Привет", "Salam", "Hola", "Shalom"}
- func appMain(driver gxui.Driver) {
- theme := flags.CreateTheme(driver)
- font, err := driver.CreateFont(gxfont.Default, 75)
- if err != nil {
- panic(err)
- }
- window := theme.CreateWindow(380, 100, "Hi")
- window.SetBackgroundBrush(gxui.CreateBrush(gxui.Gray50))
- label := theme.CreateLabel()
- label.SetFont(font)
- label.SetText("Hello world")
- window.AddChild(label)
- tickerSecond := time.NewTicker(time.Millisecond * 30)
- go func() {
- phase := float32(0)
- i := 0
- for range tickerSecond.C {
- a := 0.50 + 0.50*math.Cosf(phase * 10)
- c := gxui.Color{
- R: 0.75 + 0.25*math.Cosf((phase+0.000)*math.TwoPi),
- G: 0.75 + 0.25*math.Cosf((phase+0.333)*math.TwoPi),
- B: 0.75 + 0.25*math.Cosf((phase+0.666)*math.TwoPi),
- A: a,
- }
- if(a < 0.001){
- driver.Call(func() {
- label.SetText(hello[i])
- })
- i++
- if(i == len(hello)){
- i = 0
- }
- }
- phase += 0.01
- driver.Call(func() {
- label.SetColor(c)
- })
- }
- }()
- window.OnClose(tickerSecond.Stop)
- window.OnClose(driver.Terminate)
- }
- func main() {
- gl.StartDriver(appMain)
- }
Advertisement
Add Comment
Please, Sign In to add comment