fsharp-mandelbrot/Julia.fs
joachimschmidt557 8cc11ea130 Finish julia
2019-02-09 22:11:26 +01:00

29 lines
No EOL
886 B
FSharp

module Julia
open System
open System.Numerics
open System.Drawing
let generatePixel x y height width zoom rMax maxIter =
let c = MandelBrot.getComplexValueForPixel (float x) (float y) (float height) (float width) zoom
let z = Complex(-0.8, 0.156)
let rec findI i c =
if i >= maxIter then i
else if Complex.Abs(c) >= (float rMax) then i
else
let newRe = c.Real*c.Real - c.Imaginary*c.Imaginary
let newIm = 2.0 * c.Real * c.Imaginary
findI (i+1) (Complex(newRe, newIm)+z)
MandelBrot.colorMap (findI 0 c) maxIter
let generate (width:int) height zoom rMax maxIter =
let result = new Bitmap(width, height)
for y in 0 .. height-1 do
for x in 0 .. width-1 do
generatePixel x y height width zoom rMax maxIter
|> (fun color -> result.SetPixel(x, y, color))
result