package main import "os" import "fmt" import "image" import _ "image/png" import "git.tebibyte.media/sashakoshka/stone" import _ "git.tebibyte.media/sashakoshka/stone/backends/x" var application = &stone.Application { } func main () { application.SetTitle("color demo") application.SetSize(12, 7) iconFile16, err := os.Open("assets/scaffold16.png") if err != nil { panic(err) } icon16, _, err := image.Decode(iconFile16) if err != nil { panic(err) } iconFile16.Close() iconFile32, err := os.Open("assets/scaffold32.png") if err != nil { panic(err) } icon32, _, err := image.Decode(iconFile32) if err != nil { panic(err) } iconFile16.Close() application.SetIcon([]image.Image { icon16, icon32 }) application.OnStart(onStart) application.OnResize(onResize) err = application.Run() if err != nil { panic(err) } } func onStart () { redraw() } func onResize () { redraw() } func redraw () { text := "RAINBOW :D" width, height := application.Size() application.SetDot((width - len(text)) / 2, height / 2) fmt.Fprintln(application, text) application.SetColor(0, 0, stone.ColorYellow) application.SetColor(width - 1, 0, stone.ColorYellow) application.SetColor(width - 1, height - 1, stone.ColorYellow) application.SetColor(0, height - 1, stone.ColorYellow) application.SetRune(0, 0, '+') application.SetRune(width - 1, 0, '+') application.SetRune(width - 1, height - 1, '+') application.SetRune(0, height - 1, '+') for x := 0; x < width; x ++ { application.SetColor(x, height / 2, stone.Color(x % 6 + 2)) } for x := 1; x < width - 1; x ++ { application.SetRune(x, 0, '=') application.SetColor(x, 0, stone.ColorRed) application.SetRune(x, height - 1, '=') application.SetColor(x, height - 1, stone.ColorRed) } }