context attempt
build rgb-board / build (push) Successful in 7m57s Details

main
Nathan Wagner 9 months ago
parent 81e7607d53
commit 6eec19644e

@ -6,18 +6,17 @@ import (
"image"
"github.com/disintegration/imaging"
"github.com/fogleman/gg"
)
type Doorbell struct {
image image.Image
}
func (a *Animation) clearDoorbell() {
var door Doorbell
a.doorbell = door
}
func loadImage(imgType string, img string, a *Animation) {
baseImage, _ := b64.StdEncoding.DecodeString(img)
bigImage, _, _ := image.Decode(bytes.NewReader(baseImage))
a.doorbell.image = imaging.Resize(bigImage, 64, 64, imaging.Lanczos)
a.ctx.Push()
a.ctx = gg.NewContext(64, 128)
}

@ -39,8 +39,7 @@ func initialMap() map[string]image.Image {
// initializes the struct for the an play animation function, this could all be dumped into function that's wrapping go routine if I wanted
// what happens each frame, at an interval of 50 milliseconds
// this assumes mario context is up
func (a *Animation) animateMario() {
defer a.updateMarioPosition()
a.ctx.SetColor(color.Black)

@ -46,17 +46,18 @@ func animate(sz image.Point, mqMessages chan mqtt.Message) *Animation {
}
func (a *Animation) Next() (image.Image, <-chan time.Time, error) {
var incoming incomingMessage
a.animateMario()
if a.doorbell != (Doorbell{}) {
switch {
case a.doorbell != (Doorbell{}):
if a.countDown > 0 {
a.ctx.DrawImageAnchored(a.doorbell.image, 0, 0, 0, 0)
a.countDown -= 50
} else {
//a.image = a.image[:len(a.image)-1]
a.doorbell = Doorbell{}
a.countDown = 5000
}
default:
a.ctx.Pop()
a.animateMario()
}
a.ctx.SetColor(color.White)
select {

Loading…
Cancel
Save