Guest User

Untitled

a guest
Jan 23rd, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4. "fmt"
  5. "image"
  6. "log"
  7.  
  8. "github.com/peterhellberg/gfx"
  9. "golang.org/x/image/colornames"
  10. )
  11.  
  12. func main() {
  13.  
  14. img, err := gfx.OpenPNG("Full-Background.png")
  15. if err != nil {
  16. log.Fatal(err)
  17. }
  18.  
  19. r := gfx.R(20, 20, 180, 180)
  20. pts := []gfx.Vec{r.Min, r.Min.Add(gfx.V(0, r.H())), r.Max, r.Min.Add(gfx.V(r.W(), 0))}
  21.  
  22. anim := gfx.Animation{}
  23. for i := 0.0; i < 3; i++ {
  24. tmp := gfx.NewPaletted(200, 200, gfx.PaletteSplendor128)
  25. gfx.DrawSrc(tmp, image.Rect(0, 0, 200, 200), img, image.ZP)
  26. offset := gfx.V(i*10, 0)
  27. for j := range pts {
  28. p1, p2 := pts[j], pts[(j+1)%len(pts)]
  29. gfx.DrawLine(tmp, p1.Add(offset), p2.Add(offset), 1, colornames.Red)
  30. }
  31. // anim.AddPalettedImage(tmp.SubImage(r.Bounds()).(*gfx.Paletted))
  32. anim.AddPalettedImage(tmp.SubImage(r.Bounds().Add(image.Pt(int(i)*10, 0))).(*gfx.Paletted)) // GIF
  33. gfx.SavePNG(fmt.Sprintf("test_%0.0f.png", i), tmp.SubImage(r.Bounds().Add(image.Pt(int(i)*10, 0)))) // PNG
  34.  
  35. }
  36. anim.Delay = 10
  37. anim.SaveGIF("out.gif")
  38. }
Add Comment
Please, Sign In to add comment