168 lines
3.1 KiB
Go
168 lines
3.1 KiB
Go
package drawer
|
|
|
|
// Simple glyphs like signal or service status that are too simple to be whole image
|
|
|
|
const (
|
|
SignalStatusGlyphI = 0 // first of 5
|
|
ServiceStatusGlyphI = 5 // first of 5
|
|
)
|
|
|
|
type Image struct {
|
|
W int
|
|
H int
|
|
Bits []byte
|
|
}
|
|
|
|
var CommonGlyphs = []Image{
|
|
{ // Signal 0/0
|
|
W: 7,
|
|
H: 7,
|
|
Bits: []byte{
|
|
1, 0, 0, 0, 1, 0, 0,
|
|
0, 1, 0, 1, 0, 0, 0,
|
|
0, 0, 1, 0, 0, 0, 0,
|
|
0, 1, 0, 1, 0, 0, 1,
|
|
1, 0, 0, 0, 1, 0, 1,
|
|
0, 0, 1, 0, 0, 0, 1,
|
|
1, 0, 1, 0, 1, 0, 1,
|
|
},
|
|
},
|
|
{ // Signal 1/4
|
|
W: 7,
|
|
H: 7,
|
|
Bits: []byte{
|
|
0, 0, 0, 0, 0, 0, 0,
|
|
0, 0, 0, 0, 0, 0, 0,
|
|
0, 0, 0, 0, 0, 0, 0,
|
|
0, 0, 0, 0, 0, 0, 0,
|
|
0, 0, 0, 0, 0, 0, 0,
|
|
0, 0, 0, 0, 0, 0, 0,
|
|
1, 0, 0, 0, 0, 0, 0,
|
|
},
|
|
},
|
|
{ // Signal 2/4
|
|
W: 7,
|
|
H: 7,
|
|
Bits: []byte{
|
|
0, 0, 0, 0, 0, 0, 0,
|
|
0, 0, 0, 0, 0, 0, 0,
|
|
0, 0, 0, 0, 0, 0, 0,
|
|
0, 0, 0, 0, 0, 0, 0,
|
|
0, 0, 1, 0, 0, 0, 0,
|
|
0, 0, 1, 0, 0, 0, 0,
|
|
1, 0, 1, 0, 0, 0, 0,
|
|
},
|
|
},
|
|
{ // Signal 3/4
|
|
W: 7,
|
|
H: 7,
|
|
Bits: []byte{
|
|
0, 0, 0, 0, 0, 0, 0,
|
|
0, 0, 0, 0, 0, 0, 0,
|
|
0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
0, 0, 0, 1, 1, 1, 0, 0, 0,
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
0, 0, 0, 0, 1, 0, 0, 0, 0,
|
|
},
|
|
},
|
|
{ // Service 3/4
|
|
W: 9,
|
|
H: 7,
|
|
Bits: []byte{
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
0, 0, 1, 1, 1, 1, 1, 0, 0,
|
|
0, 1, 0, 0, 0, 0, 0, 1, 0,
|
|
0, 0, 0, 1, 1, 1, 0, 0, 0,
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
0, 0, 0, 0, 1, 0, 0, 0, 0,
|
|
},
|
|
},
|
|
{ // Service 4/4
|
|
W: 9,
|
|
H: 7,
|
|
Bits: []byte{
|
|
0, 1, 1, 1, 1, 1, 1, 1, 0,
|
|
1, 0, 0, 0, 0, 0, 0, 0, 1,
|
|
0, 0, 1, 1, 1, 1, 1, 0, 0,
|
|
0, 1, 0, 0, 0, 0, 0, 1, 0,
|
|
0, 0, 0, 1, 1, 1, 0, 0, 0,
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
0, 0, 0, 0, 1, 0, 0, 0, 0,
|
|
},
|
|
},
|
|
}
|
|
|
|
func (d *drawer) CopyImg(x0, y0 int, img Image) {
|
|
d.dev.LockImg()
|
|
defer d.dev.UnlockImg()
|
|
|
|
// Coords in img coord space
|
|
|
|
minX := IntMax(x0, 0) - x0
|
|
minY := IntMax(y0, 0) - y0
|
|
maxX := IntMin(x0+img.W, d.img.Rect.Dx()) - x0
|
|
maxY := IntMin(y0+img.H, d.img.Rect.Dy()) - y0
|
|
|
|
w := maxX - minX
|
|
if w <= 0 {
|
|
return
|
|
}
|
|
for yi := minY; yi < maxY; yi++ {
|
|
copy(d.img.Pix[(y0+yi)*d.img.Stride+x0:], img.Bits[yi*img.W:yi*img.W+w])
|
|
}
|
|
}
|