unicornpaint

A web-based painting app for raspberry PI and pimoroni Unicorn Hat HD
Log | Files | Refs | README

TestGif.go (540B)


      1 // +build ignore
      2 
      3 package main
      4 
      5 import (
      6 	"bytes"
      7 	"image/gif"
      8 	"log"
      9 
     10 	"github.com/MFAshby/unicornpaint/unicorn"
     11 )
     12 
     13 func main() {
     14 	un, err := unicorn.NewUnicorn2()
     15 	if err != nil {
     16 		log.Fatalf("Error getting a unicorn :( %v", err)
     17 	}
     18 
     19 	data, err := unicorn.Asset("data/sample2.gif")
     20 	if err != nil {
     21 		log.Fatalf("Error getting rain %v", err)
     22 	}
     23 
     24 	g, err := gif.DecodeAll(bytes.NewReader(data))
     25 	if err != nil {
     26 		log.Fatalf("Error decoding gif %v", err)
     27 	}
     28 
     29 	un.SetGif(g)
     30 	stopChan := un.StartRender()
     31 	un.MainLoop()
     32 	stopChan <- true
     33 }