spin up and cleanup belong to animation
All checks were successful
build rgb-board / build (push) Successful in 2m10s
All checks were successful
build rgb-board / build (push) Successful in 2m10s
This commit is contained in:
@@ -13,6 +13,16 @@ type Doorbell struct {
|
|||||||
image image.Image
|
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 loadImage(imgType string, img string, a *Animation) {
|
func loadImage(imgType string, img string, a *Animation) {
|
||||||
baseImage, _ := b64.StdEncoding.DecodeString(img)
|
baseImage, _ := b64.StdEncoding.DecodeString(img)
|
||||||
bigImage, _, _ := image.Decode(bytes.NewReader(baseImage))
|
bigImage, _, _ := image.Decode(bytes.NewReader(baseImage))
|
||||||
|
|||||||
9
board.go
9
board.go
@@ -48,14 +48,7 @@ func (a *Animation) Next() (image.Image, <-chan time.Time, error) {
|
|||||||
var incoming incomingMessage
|
var incoming incomingMessage
|
||||||
switch {
|
switch {
|
||||||
case a.doorbell != (Doorbell{}):
|
case a.doorbell != (Doorbell{}):
|
||||||
if a.countDown > 0 {
|
a.animateDoorbell()
|
||||||
a.ctx.DrawImageAnchored(a.doorbell.image, 0, 0, 0, 0)
|
|
||||||
a.countDown -= 50
|
|
||||||
} else {
|
|
||||||
a.doorbell = Doorbell{}
|
|
||||||
a.countDown = 5000
|
|
||||||
a.ctx.Pop()
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
a.animateMario()
|
a.animateMario()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user