mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-11 19:48:54 +01:00
examples/mandelbrot: Refactoring
This commit is contained in:
parent
8c1cafd6ae
commit
3d65f92040
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user