-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfont.go
More file actions
58 lines (56 loc) · 1.54 KB
/
Copy pathfont.go
File metadata and controls
58 lines (56 loc) · 1.54 KB
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
package main
var font3x5 = map[rune][5]uint8{
' ': {0x0, 0x0, 0x0, 0x0, 0x0},
':': {0x0, 0x2, 0x0, 0x2, 0x0},
'-': {0x0, 0x0, 0x7, 0x0, 0x0},
'0': {0x7, 0x5, 0x5, 0x5, 0x7},
'1': {0x2, 0x6, 0x2, 0x2, 0x7},
'2': {0x7, 0x1, 0x7, 0x4, 0x7},
'3': {0x7, 0x1, 0x7, 0x1, 0x7},
'4': {0x5, 0x5, 0x7, 0x1, 0x1},
'5': {0x7, 0x4, 0x7, 0x1, 0x7},
'6': {0x7, 0x4, 0x7, 0x5, 0x7},
'7': {0x7, 0x1, 0x2, 0x2, 0x2},
'8': {0x7, 0x5, 0x7, 0x5, 0x7},
'9': {0x7, 0x5, 0x7, 0x1, 0x7},
'A': {0x7, 0x5, 0x7, 0x5, 0x5},
'B': {0x6, 0x5, 0x6, 0x5, 0x6},
'C': {0x7, 0x4, 0x4, 0x4, 0x7},
'D': {0x6, 0x5, 0x5, 0x5, 0x6},
'E': {0x7, 0x4, 0x7, 0x4, 0x7},
'F': {0x7, 0x4, 0x7, 0x4, 0x4},
'G': {0x7, 0x4, 0x5, 0x5, 0x7},
'H': {0x5, 0x5, 0x7, 0x5, 0x5},
'I': {0x7, 0x2, 0x2, 0x2, 0x7},
'L': {0x4, 0x4, 0x4, 0x4, 0x7},
'M': {0x5, 0x7, 0x7, 0x5, 0x5},
'N': {0x5, 0x7, 0x7, 0x7, 0x5},
'O': {0x7, 0x5, 0x5, 0x5, 0x7},
'P': {0x7, 0x5, 0x7, 0x4, 0x4},
'R': {0x7, 0x5, 0x7, 0x6, 0x5},
'S': {0x7, 0x4, 0x7, 0x1, 0x7},
'T': {0x7, 0x2, 0x2, 0x2, 0x2},
'U': {0x5, 0x5, 0x5, 0x5, 0x7},
'V': {0x5, 0x5, 0x5, 0x5, 0x2},
'X': {0x5, 0x5, 0x2, 0x5, 0x5},
}
func drawText(ren *Renderer, text string, x, y, scale int, r, g, b uint8) {
ren.SetDrawColor(r, g, b, 255)
cx := x
for _, ch := range text {
glyph, ok := font3x5[ch]
if !ok {
cx += 4 * scale
continue
}
for row := 0; row < 5; row++ {
bits := glyph[row]
for col := 0; col < 3; col++ {
if bits&(1<<(2-col)) != 0 {
ren.FillRect(cx+col*scale, y+row*scale, scale, scale)
}
}
}
cx += 4 * scale
}
}