Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "image"
- "log"
- "github.com/peterhellberg/gfx"
- "golang.org/x/image/colornames"
- )
- func main() {
- img, err := gfx.OpenPNG("Full-Background.png")
- if err != nil {
- log.Fatal(err)
- }
- r := gfx.R(20, 20, 180, 180)
- pts := []gfx.Vec{r.Min, r.Min.Add(gfx.V(0, r.H())), r.Max, r.Min.Add(gfx.V(r.W(), 0))}
- anim := gfx.Animation{}
- for i := 0.0; i < 3; i++ {
- tmp := gfx.NewPaletted(200, 200, gfx.PaletteSplendor128)
- gfx.DrawSrc(tmp, image.Rect(0, 0, 200, 200), img, image.ZP)
- offset := gfx.V(i*10, 0)
- for j := range pts {
- p1, p2 := pts[j], pts[(j+1)%len(pts)]
- gfx.DrawLine(tmp, p1.Add(offset), p2.Add(offset), 1, colornames.Red)
- }
- // anim.AddPalettedImage(tmp.SubImage(r.Bounds()).(*gfx.Paletted))
- anim.AddPalettedImage(tmp.SubImage(r.Bounds().Add(image.Pt(int(i)*10, 0))).(*gfx.Paletted)) // GIF
- gfx.SavePNG(fmt.Sprintf("test_%0.0f.png", i), tmp.SubImage(r.Bounds().Add(image.Pt(int(i)*10, 0)))) // PNG
- }
- anim.Delay = 10
- anim.SaveGIF("out.gif")
- }
Add Comment
Please, Sign In to add comment