aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/term/draw.go
blob: c6f297ff668ef2598b977ed2b0d36f0c7f52d563 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package term

import (
	"github.com/gdamore/tcell/v2"
)

type Style tcell.Style;

var (
	BgStyle Style
	FgStyle Style
)

func init() {
	BgStyle = Style(tcell.StyleDefault.Background(tcell.ColorReset).Foreground(tcell.ColorReset))
	FgStyle = Style(tcell.StyleDefault.Foreground(tcell.ColorWhite).Background(tcell.ColorOlive))
}

func DrawSquare(scr *Screen, xOffset, yOffset, w, h int, style Style) {
	for dx := 0; dx < w; dx++ {
		x := xOffset + dx
		for dy := 0; dy < h; dy++ {
			y := yOffset + dy
			scr.scr.SetContent(x, y, ' ', nil, tcell.Style(style))
		}
	}
}

func DrawNumber(scr *Screen, n, xOffset, yOffset, squareW, squareH int, style Style) {
	defs := [...][15]bool{
		{
			true, true, true,
			true, false, true,
			true, false, true,
			true, false, true,
			true, true, true,
		},
		{
			false, false, true,
			false, false, true,
			false, false, true,
			false, false, true,
			false, false, true,
		},
		{
			true, true, true,
			false, false, true,
			true, true, true,
			true, false, false,
			true, true, true,
		},
		{
			true, true, true,
			false, false, true,
			true, true, true,
			false, false, true,
			true, true, true,
		},
		{
			true, false, true,
			true, false, true,
			true, true, true,
			false, false, true,
			false, false, true,
		},
		{
			true, true, true,
			true, false, false,
			true, true, true,
			false, false, true,
			true, true, true,
		},
		{
			true, true, true,
			true, false, false,
			true, true, true,
			true, false, true,
			true, true, true,
		},
		{
			true, true, true,
			false, false, true,
			false, false, true,
			false, false, true,
			false, false, true,
		},
		{
			true, true, true,
			true, false, true,
			true, true, true,
			true, false, true,
			true, true, true,
		},
		{
			true, true, true,
			true, false, true,
			true, true, true,
			false, false, true,
			true, true, true,
		},
	}

	squares := defs[n]
	for i, draw := range squares {
		if !draw {
			continue
		}
		x := i % 3
		y := i / 3
		DrawSquare(scr, xOffset+squareW*x, yOffset+squareH*y, squareW, squareH, style)
	}
}