Files
beatglow/hardware/display/sprite.go
T
2026-10-29 17:29:41 +01:00

20 lines
394 B
Go

package display
import (
"image/color"
"image/draw"
)
func DrawSprite(p draw.Image, x, y int, sprite []uint8, c color.Color) {
w, h, data := sprite[0], sprite[1], sprite[2:]
for dy := 0; dy < int(h); dy++ {
for dx := 0; dx < int(w); dx++ {
byteOffset := int(dy/8)*int(w) + dx
bitOffset := dy % 8
if data[byteOffset]&(1<<bitOffset) != 0 {
p.Set(x+dx, y+dy, c)
}
}
}
}