Slowly adding basic functionality
This commit is contained in:
parent
03758163f3
commit
572116ba4a
2 changed files with 22 additions and 4 deletions
BIN
mandelbrot
Executable file
BIN
mandelbrot
Executable file
Binary file not shown.
|
|
@ -1,8 +1,26 @@
|
||||||
import complex, colors
|
import math, complex, colors
|
||||||
|
|
||||||
|
proc getComplexValueForPixel(x:int, y:int, height:int, width:int, zoom:float64): Complex[float64] =
|
||||||
proc getComplexValueForPixel(x:int, y:int, height:int, width:int, zoom:float): Complex =
|
complex.complex64((x.float64-width.float64/2.0'f64)/zoom, (y.float64-height.float64/2.0'f64)/zoom)
|
||||||
(re: (x-width/2.0)/zoom, im: (y-height/2.0)/zoom)
|
|
||||||
|
|
||||||
proc colorMap(i:int, nMax:int): Color =
|
proc colorMap(i:int, nMax:int): Color =
|
||||||
rgb(0, 0, 0)
|
rgb(0, 0, 0)
|
||||||
|
|
||||||
|
proc generatePixel(x:int, y:int, height:int, width:int, zoom:float64,
|
||||||
|
rMax: int, maxIter:int) : Color =
|
||||||
|
let c = getComplexValueForPixel(x, y, height, width, zoom)
|
||||||
|
|
||||||
|
var
|
||||||
|
n = 0
|
||||||
|
z = complex64(0'f64, 0'f64)
|
||||||
|
|
||||||
|
for i in 0..maxIter:
|
||||||
|
if z.abs >= rMax.float64:
|
||||||
|
n = i
|
||||||
|
break
|
||||||
|
z = c + z * z
|
||||||
|
|
||||||
|
result = colorMap(n, maxIter)
|
||||||
|
|
||||||
|
proc generateImage(width:int, height:int, zoom:float64, rMax:int, maxIter:int) =
|
||||||
|
discard nil
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue