Files
rgb-led-board/animateDoorbell.go
nathan wagner c64a6bfe42
All checks were successful
build rgb-board / build (push) Successful in 2m11s
fully removing context stuff.
2024-02-16 15:47:08 +00:00

32 lines
654 B
Go

package main
import (
"bytes"
b64 "encoding/base64"
"image"
"image/color"
"github.com/disintegration/imaging"
)
type Doorbell struct {
image image.Image
}
func (a *Animation) animateDoorbell() {
if a.countDown > 0 {
a.ctx.SetColor(color.Black)
a.ctx.Clear()
a.ctx.DrawImageAnchored(a.doorbell.image, 0, 0, 0, 0)
a.countDown -= 50
} else {
a.doorbell = Doorbell{}
a.countDown = 5000
}
}
func (a *Animation) loadImage(imgType string, img string) {
baseImage, _ := b64.StdEncoding.DecodeString(img)
bigImage, _, _ := image.Decode(bytes.NewReader(baseImage))
a.doorbell.image = imaging.Resize(bigImage, 64, 64, imaging.Lanczos)
}