examples/mandelbrot: Refactoring

This commit is contained in:
Hajime Hoshi 2017-12-16 21:17:53 +09:00
parent 8c1cafd6ae
commit 3d65f92040

View File

@ -58,14 +58,13 @@ func updateOffscreen(centerX, centerY, size float64) {
x := float64(i)*size/screenWidth - size/2 + centerX x := float64(i)*size/screenWidth - size/2 + centerX
y := (screenHeight-float64(j))*size/screenHeight - size/2 + centerY y := (screenHeight-float64(j))*size/screenHeight - size/2 + centerY
c := complex(x, y) c := complex(x, y)
z := c z := complex(0, 0)
it := 0 it := 0
for ; it < maxIt; it++ { for ; it < maxIt; it++ {
nz := z*z + c z = z*z + c
if real(nz)*real(nz)+imag(nz)*imag(nz) > 4 { if real(z)*real(z)+imag(z)*imag(z) > 4 {
break break
} }
z = nz
} }
r, g, b := color(it) r, g, b := color(it)
p := 4 * (i + j*screenWidth) p := 4 * (i + j*screenWidth)