Debian Codegraph @

_demos/256ramp.go

raw symbols SCIP
1 package main
2
3 import (
4 _ "unicode/utf8"
5
6 _ "github.com/mattn/go-runewidth"
7 "github.com/nsf/termbox-go"
8
9 "fmt"
10 )
11
12 // This gives a table of the 256-color-set,
13 // both the foreground and background variants.
14 // It is ordered to produce many color ramps.
15 // Quit with ESC
16
17 func draw_ramp() {
18 var i int
19 for i = 0; i < 256; i++ {
20 row := ((i + 2) / 6) + 3
21 col := ((i + 2) % 6) * 4
22 var text string = fmt.Sprintf("%03d", i)
23 for j := 0; j < 3; j++ {
24 termbox.SetCell(col+j, row, []rune(text)[j],
25 termbox.Attribute(i+1), termbox.ColorDefault)
26 termbox.SetCell(col+j+30, row, []rune(text)[j],
27 termbox.ColorDefault, termbox.Attribute(i+1))
28 }
29 }
30 termbox.Flush()
31 }
32
33 func main() {
34 err := termbox.Init()
35 if err != nil {
36 panic(err)
37 }
38 termbox.SetInputMode(termbox.InputEsc)
39 termbox.SetOutputMode(termbox.Output256)
40
41 draw_ramp()
42
43 termbox.PollEvent()
44 termbox.Close()
45 }