func main() { const maxIter = 1024 var d = mandel.NewData(320, 200, -0.7435669, 0.1314023, 0.0022878) m := make(map[int]int) var maxV = 0 for y := 0; y < d.MaxY; y++ { for x := 0; x < d.MaxX; x++ { dx := float64(x) * d.StepX dy := float64(y) * d.StepY iter := mandel.Iterate(d.UpperLeftRe+dx, d.UpperLeftIm+dy, maxIter) m[iter] = m[iter] + 1 if m[iter] > maxV { maxV = m[iter] } fmt.Println(x, d.MaxY-y, iter) } } for x := 1; x <= maxV; x++ { for k, v := range m { if x == v { fmt.Println("iter", k, " -> count", v) } } } }
func main() { d := mandel.NewData(1024, 800, -0.7435669, 0.1314023, 0.0022878) pi := pngimage.NewPngimage(d.MaxX, d.MaxY, "mandel.png") it := task.IterateTasks(d, pi) for t := range it { iter := mandel.Iterate(t.CRe, t.CIm, 1024) c := getColor(iter) pi.Img.Set(t.X, d.MaxY-t.Y, c) } pi.Save() }
func iterateSubPixelTasks(d *mandel.Data, pi *pngimage.Pngimage, subPixel int) { spX := d.StepX / float64(subPixel) spY := d.StepY / float64(subPixel) b := pi.Img.Bounds() for y := b.Min.Y; y < b.Max.Y; y++ { for x := b.Min.X; x < b.Max.X; x++ { sumIter := 0 for sx := 1; sx <= subPixel; sx++ { for sy := 1; sy <= subPixel; sy++ { cRe := d.UpperLeftRe + float64(x)*d.StepX + float64(sx)*spX cIm := d.UpperLeftIm + float64(y)*d.StepY + float64(sy)*spY iter := mandel.Iterate(cRe, cIm, maxIter) sumIter += iter } } fIter := float64(sumIter) / float64(subPixel*subPixel) pi.Img.Set(x, d.MaxY-y, getColor(fIter)) } } }
func main() { var maxIter = 10 * 360 var d = mandel.NewData(640, 400, -0.7435669, 0.1314023, 0.0022878) for colScale := 30; colScale < 360; colScale += 30 { for colShift := 0; colShift < colScale; colShift += 6 { n := fmt.Sprintf("mandel-scale-%04d-shift-%03d.png", colScale, colShift) fmt.Println("Render:", n) pi := pngimage.NewPngimage(d.MaxX, d.MaxY, n) it := task.IterateTasks(d, pi) for t := range it { iter := mandel.Iterate(t.CRe, t.CIm, maxIter) pi.Img.Set(t.X, d.MaxY-t.Y, getColor(iter, colScale, colShift)) } pi.Save() } } }
func main() { const maxIter = 10 * 360 var d = mandel.NewData(640, 400, -0.7435669, 0.1314023, 0.0022878) var iteration [640][400]int fmt.Println("Iterate") for y := 0; y < d.MaxY; y++ { for x := 0; x < d.MaxX; x++ { dx := float64(x) * d.StepX dy := float64(y) * d.StepY iteration[x][y] = mandel.Iterate(d.UpperLeftRe+dx, d.UpperLeftIm+dy, maxIter) } } var err error var c color.Color for colorShift := 0; colorShift < 36; colorShift++ { n := fmt.Sprintf("mandel-hue-colorshift-%02d.png", colorShift) pi := pngimage.NewPngimage(d.MaxX, d.MaxY, n) for y := 0; y < d.MaxY; y++ { for x := 0; x < d.MaxX; x++ { iter := iteration[x][y] h := float64((iter+colorShift*10)%360) / 360.0 if c, err = hue.Color(h); err != nil { panic(err) } pi.Img.Set(x, d.MaxY-y, c) } } fmt.Println("write file", n) pi.Save() } }