Polyspiral: Difference between revisions

→‎{{header|Go}}: Added code to create GIF file directly from program.
m (Moved Go entry into correct alphabetical order.)
(→‎{{header|Go}}: Added code to create GIF file directly from program.)
Line 666:
 
=={{header|Go}}==
This uses Go's 'image' packages in its standard library to create an animated GIF. The file itself can be created from the terminal as follows:
 
<pre>
$ go build polyspiral.go
$ ./polyspiral > polyspiral.gif
</pre>
When played this is similar to the Java entry but much quicker. The whole animation completes in 72 seconds and repeats indefinitely.
 
Line 684 ⟶ 681:
"image/color"
"image/gif"
"log"
"math"
"os"
Line 781 ⟶ 779:
anim.Image = append(anim.Image, img)
}
file, err := os.Create("polyspiral.gif")
gif.EncodeAll(os.Stdout, &anim)
if err != nil {
log.Fatal(err)
}
defer file.Close()
if err2 := gif.EncodeAll(os.Stdoutfile, &anim); err != nil {
log.Fatal(err2)
}
}</lang>
 
9,488

edits