76 lines
1.8 KiB
Go
76 lines
1.8 KiB
Go
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("hellorld")
|
|
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 })
|
|
|
|
channel, err := application.Run()
|
|
if err != nil { panic(err) }
|
|
|
|
redraw()
|
|
|
|
for {
|
|
event := <- channel
|
|
switch event.(type) {
|
|
case stone.EventQuit:
|
|
os.Exit(0)
|
|
|
|
case stone.EventResize:
|
|
redraw()
|
|
}
|
|
}
|
|
}
|
|
|
|
func redraw () {
|
|
text :="RAINBOW :D"
|
|
width, height := application.Size()
|
|
|
|
application.Dot.X = (width - len(text)) / 2
|
|
application.Dot.Y = 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)
|
|
}
|
|
|
|
application.Draw()
|
|
}
|