Slowly adding basic functionality

This commit is contained in:
joachimschmidt557 2019-03-05 19:38:29 +01:00
parent 03758163f3
commit 572116ba4a
2 changed files with 22 additions and 4 deletions

View file

@ -1,8 +1,26 @@
import complex, colors
import math, complex, colors
proc getComplexValueForPixel(x:int, y:int, height:int, width:int, zoom:float): Complex =
(re: (x-width/2.0)/zoom, im: (y-height/2.0)/zoom)
proc getComplexValueForPixel(x:int, y:int, height:int, width:int, zoom:float64): Complex[float64] =
complex.complex64((x.float64-width.float64/2.0'f64)/zoom, (y.float64-height.float64/2.0'f64)/zoom)
proc colorMap(i:int, nMax:int): Color =
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