0
나는 guide by Alan Donovan을 따라 gif를 만들려고합니다. 그러나 출력에 항상 읽을 수없는 GIF 이미지가 있습니다. Windows 8.0을 사용 중일 때이 예제를 쉽게 다시 만들 수 있다는 것을 기억합니다. 그러나 오늘 Ubuntu16.04에서 내 오류는 어디에 있으며 어떻게 수정해야합니까. 내 코드 :gif 오류를 디버깅하는 방법
package main
import (
"image/color"
"os"
"io"
"math/rand"
"time"
"image/gif"
"image"
"math"
)
var palette = []color.Color{color.White, color.Black}
const (
whiteIndex = 0
blackIndex = 1
)
func main() {
lissajous(os.Stdout)
}
func lissajous(out io.Writer) {
const (
cycles = 5
res = 0.001
size = 100
nframes = 64
delay = 8
)
rand.Seed(time.Now().UTC().UnixNano())
freq := rand.Float64()*3.0
anim := gif.GIF{LoopCount:nframes}
phase := 0.0
for i := 0; i < nframes; i++ {
rect := image.Rect(0, 0, 2*size+1, 2*size+1)
img := image.NewPaletted(rect, palette)
for t:=0.0; t< cycles*2*math.Pi; t+= res {
x:= math.Sin(t)
y:= math.Sin(t*freq + phase)
img.SetColorIndex(size+int(x*size+0.5), size+int(y*size+0.5), blackIndex)
}
phase += 0.2
anim.Delay = append(anim.Delay, delay)
anim.Image = append(anim.Image, img)
}
gif.EncodeAll(out, &anim)
}
그냥 책에서 복사했습니다. '~/go/src/learning /'에있는 소스 파일
읽을 수없는 gif임을 어떻게 알 수 있습니까? 어떻게 시험하고 있습니까? 정확한 오류 메시지는 무엇입니까? – Flimzy
내 문제는 웹 브라우저에서 열어야한다는 것이었고 Mirage와 같은 프로그램을 시작했습니다 ... T_T –
댓글이 내 질문에 답변이되지 않습니다. 정확한 오류 메시지는 무엇입니까? – Flimzy