twitchapon-anim

Basic Twitchapon Receiver/Visuals
git clone git://bsandro.tech/twitchapon-anim
Log | Files | Refs | README | LICENSE

init.go (778B)


      1 package main
      2 
      3 import (
      4 	"bytes"
      5 	"fmt"
      6 	"github.com/hajimehoshi/ebiten/v2"
      7 	_ "golang.org/x/image/webp"
      8 	"image"
      9 	_ "image/gif"
     10 	_ "image/jpeg"
     11 	_ "image/png"
     12 	"log"
     13 )
     14 
     15 //go:generate go run generate/embed.go
     16 
     17 func getImage(name string) (*ebiten.Image, error) {
     18 	rawImage, format, err := image.Decode(bytes.NewReader(Assets[name]))
     19 	log.Printf("%s detected format: %s\n", name, format)
     20 	return ebiten.NewImageFromImage(rawImage), err
     21 }
     22 
     23 func init() {
     24 	fmt.Println("init()")
     25 	for fname, raw := range Assets {
     26 		fmt.Printf("Loaded '%s' - %d bytes\n", fname, len(raw))
     27 	}
     28 
     29 	for name, _ := range Assets {
     30 		img, err := getImage(name)
     31 		if err != nil {
     32 			log.Fatal(err)
     33 		}
     34 		// some global memory storage
     35 		Images[name] = img
     36 	}
     37 
     38 	ScreenSize.width = 1280
     39 	ScreenSize.height = 720
     40 }