|
|
|
@ -39,6 +39,7 @@ type Animation struct {
|
|
|
|
|
updown int
|
|
|
|
|
mqmsg chan mqtt.Message
|
|
|
|
|
msg string
|
|
|
|
|
countDown int
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//flags from cmd line
|
|
|
|
@ -135,6 +136,7 @@ func NewAnimation(sz image.Point, mqMessages chan mqtt.Message) *Animation {
|
|
|
|
|
image: images,
|
|
|
|
|
updown: 0,
|
|
|
|
|
mqmsg: mqMessages,
|
|
|
|
|
countDown: 5000,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -149,6 +151,15 @@ func (a *Animation) Next() (image.Image, <-chan time.Time, error) {
|
|
|
|
|
} else {
|
|
|
|
|
a.ctx.DrawImageAnchored(imaging.FlipH(a.image[a.updown]), a.position.X, a.position.Y, 0.5, 0.5)
|
|
|
|
|
}
|
|
|
|
|
if a.image[3] != nil {
|
|
|
|
|
if a.countDown > 0 {
|
|
|
|
|
a.ctx.DrawImageAnchored(a.image[3], 0, 0, 0, 0)
|
|
|
|
|
a.countDown -= 50
|
|
|
|
|
} else {
|
|
|
|
|
a.image[3] = nil
|
|
|
|
|
a.countDown = 5000
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
a.ctx.SetColor(color.White)
|
|
|
|
|
select {
|
|
|
|
|
case msg := <-a.mqmsg:
|
|
|
|
@ -159,8 +170,8 @@ func (a *Animation) Next() (image.Image, <-chan time.Time, error) {
|
|
|
|
|
} else {
|
|
|
|
|
baseImage, _ := b64.StdEncoding.DecodeString(incoming.Image)
|
|
|
|
|
bigImage, _, _ := image.Decode(bytes.NewReader(baseImage))
|
|
|
|
|
littleImage := imaging.Resize(bigImage, 32, 32, imaging.Lanczos)
|
|
|
|
|
a.ctx.DrawImageAnchored(littleImage, 0, 0, 0, 0)
|
|
|
|
|
a.image[3] = imaging.Resize(bigImage, 32, 32, imaging.Lanczos)
|
|
|
|
|
a.ctx.DrawImageAnchored(a.image[3], 0, 0, 0, 0)
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
}
|
|
|
|
|