Created a style test (that does nothing as of now)
This commit is contained in:
parent
5ea5a302bf
commit
2fa4cc8da4
62
examples/style/main.go
Normal file
62
examples/style/main.go
Normal file
@ -0,0 +1,62 @@
|
||||
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("style demo")
|
||||
application.SetSize(9, 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(redraw)
|
||||
application.OnResize(redraw)
|
||||
|
||||
err = application.Run()
|
||||
if err != nil { panic(err) }
|
||||
}
|
||||
|
||||
func redraw () {
|
||||
width, _ := application.Size()
|
||||
application.SetDot(0, 0)
|
||||
fmt.Fprint (
|
||||
application,
|
||||
"normal\n",
|
||||
"bold\n",
|
||||
"italic\n",
|
||||
"underline\n",
|
||||
"all 3\n",
|
||||
"highlighted\n",
|
||||
"all 4\n")
|
||||
fillStyle(0, width, stone.StyleNormal)
|
||||
fillStyle(1, width, stone.StyleBold)
|
||||
fillStyle(2, width, stone.StyleItalic)
|
||||
fillStyle(3, width, stone.StyleUnderline)
|
||||
fillStyle(4, width, stone.StyleBoldItalic | stone.StyleUnderline)
|
||||
fillStyle(5, width, stone.StyleHighlight)
|
||||
fillStyle(6, width, stone.StyleBoldItalic | stone.StyleUnderline |
|
||||
stone.StyleHighlight)
|
||||
}
|
||||
|
||||
func fillStyle (yOffset, width int, style stone.Style) {
|
||||
for x := 0; x < width; x ++ {
|
||||
application.SetStyle(x, yOffset, style)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user