Last active
January 1, 2018 15:27
-
-
Save kasari/1c9a76fec790e6540a065b76ac13c327 to your computer and use it in GitHub Desktop.
Print colors map in Output216 mode of termbox-go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"strconv" | |
"strings" | |
termbox "github.com/nsf/termbox-go" | |
) | |
func main() { | |
if err := termbox.Init(); err != nil { | |
panic(err) | |
} | |
defer termbox.Close() | |
termbox.SetOutputMode(termbox.Output216) | |
for y := 0; y < 6; y++ { | |
for x := 1; x <= 36; x++ { | |
var fg termbox.Attribute | |
if x <= 18 { | |
fg = 216 | |
} else { | |
fg = 1 | |
} | |
code := y*36 + x | |
codeStr := rightPad(strconv.Itoa(code), 3) | |
for i, r := range codeStr { | |
termbox.SetCell((x-1)*3+i, y, r, fg, termbox.Attribute(code)) | |
} | |
} | |
} | |
termbox.Flush() | |
var c byte | |
fmt.Scan(&c) | |
} | |
func rightPad(s string, n int) string { | |
return s + strings.Repeat(" ", n-len(s)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment