예제 #1
0
파일: example.go 프로젝트: Voker57/termbox
//---------------------------------------------------------------------------
// drawing "rainbow" box around the terminal screen
//---------------------------------------------------------------------------
func drawBox(seed uint16) {
	w := termbox.Width()
	h := termbox.Height()

	color := uint16(seed)
	var x, x2, y, y2 uint
	x2 = w - 1
	y2 = h - 1

	// horizontal
	for x = 0; x < w; x++ {
		termbox.ChangeCell(x, y, ' ', termbox.BLACK, color)
		termbox.ChangeCell(x, y2, ' ', termbox.BLACK, color)

		color++
		if color > 7 {
			color = 0
		}
	}
	x = 0

	// overdrawing corners here, but it's ok
	// vertical
	for y = 0; y < h; y++ {
		termbox.ChangeCell(x, y, ' ', termbox.BLACK, color)
		termbox.ChangeCell(x2, y, ' ', termbox.BLACK, color)

		color++
		if color > 7 {
			color = 0
		}
	}
}
예제 #2
0
파일: example.go 프로젝트: Voker57/termbox
//---------------------------------------------------------------------------
// utility function for drawing strings
//---------------------------------------------------------------------------
func drawString(x uint, y uint, s string, fg uint16, bg uint16) {
	for _, r := range s {
		termbox.ChangeCell(x, y, r, fg, bg)
		x++
	}
}