func (c *ctx) addFrame(img image.Image) error {
opts := gif.Options{
NumColors: 256,
Drawer: draw.FloydSteinberg,
}
b := img.Bounds()
// More or less taken from the image/gif package
pimg := image.NewPaletted(b, palette.Plan9[:opts.NumColors])
if opts.Quantizer != nil {
pimg.Palette = opts.Quantizer.Quantize(make(color.Palette, 0, opts.NumColors), img)
}
opts.Drawer.Draw(pimg, b, img, image.ZP)
spf := 1 / float64(c.fps)
c.g.Image = append(c.g.Image, pimg)
c.g.Delay = append(c.g.Delay, int(spf*100))
return nil
}myPalette := append(palette.WebSafe, image.Transparent)