From: AceVest Date: Sun, 18 Jun 2017 15:27:33 +0000 (+0800) Subject: .... X-Git-Url: http://zhaoyanbai.com/repos/man.named.html?a=commitdiff_plain;h=e79b092e3ef52922308b46026c880f80e429db2d;p=acecode.git .... --- diff --git a/learn/go/exercise/1.5.go b/learn/go/exercise/1.5.go new file mode 100644 index 0000000..8a4df42 --- /dev/null +++ b/learn/go/exercise/1.5.go @@ -0,0 +1,107 @@ +/* + * ------------------------------------------------------------------------ + * File Name: 1.5.go + * Author: Zhao Yanbai + * 2017-06-11 16:09:11 Sunday CST + * Description: none + * ------------------------------------------------------------------------ + */ +package main +import ( +// "fmt" + "image" + "image/color" + "image/gif" + "io" + "math" + "math/rand" + "os" +) + +var palette = []color.Color { + color.White, + color.Black, + color.RGBA{0xFF, 0x00, 0x00, 0xFF}, + color.RGBA{0x00, 0xFF, 0x00, 0xFF}, + color.RGBA{0x00, 0x00, 0xFF, 0xFF}, +} + +const ( + lineColorIndex = 3 +) + + +func lissajous(out io.Writer) { + const ( + cycles = 5 + res = 0.001 + size = 100 + nframes = 128 + delay = 8 // 80ms + ) + + freq := rand.Float64() * 3.0 + anim := gif.GIF{LoopCount: nframes} + phase := 0.0 + + for i := 0; i