Improve animation GIF color

This commit is contained in:
Hajime Hoshi 2014-12-29 01:57:39 +09:00
parent 2810161cdb
commit 47214fb572
5 changed files with 14 additions and 11 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 561 KiB

After

Width:  |  Height:  |  Size: 638 KiB

View File

@ -244,7 +244,7 @@ func update(screen *ebiten.Image) error {
count++ count++
w, h := gophersImage.Size() w, h := gophersImage.Size()
geo := ebiten.TranslateGeo(-float64(w)/2, -float64(h)/2) geo := ebiten.TranslateGeo(-float64(w)/2, -float64(h)/2)
geo.Concat(ebiten.RotateGeo(float64(count%720) * 2 * math.Pi / 720)) geo.Concat(ebiten.RotateGeo(float64(count%360) * 2 * math.Pi / 360))
geo.Concat(ebiten.TranslateGeo(screenWidth/2, screenHeight/2)) geo.Concat(ebiten.TranslateGeo(screenWidth/2, screenHeight/2))
if err := screen.DrawImage(gophersImage, &ebiten.DrawImageOptions{ if err := screen.DrawImage(gophersImage, &ebiten.DrawImageOptions{
GeoM: geo, GeoM: geo,

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 691 KiB

View File

@ -35,15 +35,18 @@ type recorder struct {
wg sync.WaitGroup wg sync.WaitGroup
} }
var cheapPalette = color.Palette{ var cheapPalette color.Palette
color.RGBA{0x00, 0x00, 0x00, 0xff},
color.RGBA{0xff, 0x00, 0x00, 0xff}, func init() {
color.RGBA{0x00, 0xff, 0x00, 0xff}, cs := []color.Color{}
color.RGBA{0x00, 0x00, 0xff, 0xff}, for _, r := range []uint8{0x00, 0x80, 0xff} {
color.RGBA{0xff, 0xff, 0x00, 0xff}, for _, g := range []uint8{0x00, 0x80, 0xff} {
color.RGBA{0xff, 0x00, 0xff, 0xff}, for _, b := range []uint8{0x00, 0x80, 0xff} {
color.RGBA{0x00, 0xff, 0xff, 0xff}, cs = append(cs, color.RGBA{r, g, b, 0xff})
color.RGBA{0xff, 0xff, 0xff, 0xff}, }
}
}
cheapPalette = color.Palette(cs)
} }
func (r *recorder) delay() int { func (r *recorder) delay() int {

View File

@ -36,7 +36,7 @@ func update(screen *ebiten.Image) error {
count++ count++
w, h := gophersImage.Size() w, h := gophersImage.Size()
geo := ebiten.TranslateGeo(-float64(w)/2, -float64(h)/2) geo := ebiten.TranslateGeo(-float64(w)/2, -float64(h)/2)
geo.Concat(ebiten.RotateGeo(float64(count%720) * 2 * math.Pi / 720)) geo.Concat(ebiten.RotateGeo(float64(count%360) * 2 * math.Pi / 360))
geo.Concat(ebiten.TranslateGeo(screenWidth/2, screenHeight/2)) geo.Concat(ebiten.TranslateGeo(screenWidth/2, screenHeight/2))
if err := screen.DrawImage(gophersImage, &ebiten.DrawImageOptions{ if err := screen.DrawImage(gophersImage, &ebiten.DrawImageOptions{
GeoM: geo, GeoM: geo,