You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
rgb-led-board/animateDoorbell.go

35 lines
709 B
Go

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