| 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 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 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 |
} |