forked from stathissideris/ditaa
-
Notifications
You must be signed in to change notification settings - Fork 5
/
abstractcell.go
42 lines (36 loc) · 1.09 KB
/
abstractcell.go
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
// WIP
package main
type AbstractCell [9]bool
func (c *AbstractCell) Get(x, y int) bool {
return (*c)[y*3+x]
}
func abpix(source, mask int32) bool {
switch source & mask {
case 0:
return false
case mask:
return true
}
panic("bad abstract pixel")
}
func PaintAbCell(hextop, hexmid, hexbot int32) AbstractCell {
return AbstractCell{
abpix(hextop, 0x100), abpix(hextop, 0x010), abpix(hextop, 0x001),
abpix(hexmid, 0x100), abpix(hexmid, 0x010), abpix(hexmid, 0x001),
abpix(hexbot, 0x100), abpix(hexbot, 0x010), abpix(hexbot, 0x001),
}
}
var (
abHLine = PaintAbCell(0x000, 0x111, 0x000)
abVLine = PaintAbCell(0x010, 0x010, 0x010)
abCorner1 = PaintAbCell(0x000, 0x011, 0x010)
abCorner2 = PaintAbCell(0x000, 0x110, 0x010)
abCorner3 = PaintAbCell(0x010, 0x110, 0x000)
abCorner4 = PaintAbCell(0x010, 0x011, 0x000)
abT = PaintAbCell(0x000, 0x111, 0x010)
abInvT = PaintAbCell(0x010, 0x111, 0x000)
abK = PaintAbCell(0x010, 0x011, 0x010)
abInvK = PaintAbCell(0x010, 0x110, 0x010)
abCross = PaintAbCell(0x010, 0x111, 0x010)
abStar = PaintAbCell(0x111, 0x111, 0x111)
)