WIP
This commit is contained in:
parent
8cc11ea130
commit
4b94f8c089
12 changed files with 24 additions and 4 deletions
5
Fractal.fs
Normal file
5
Fractal.fs
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
/// Common functions for fractals
|
||||||
|
module Fractal
|
||||||
|
|
||||||
|
open System
|
||||||
|
|
||||||
12
Julia.fs
12
Julia.fs
|
|
@ -4,6 +4,16 @@ open System
|
||||||
open System.Numerics
|
open System.Numerics
|
||||||
open System.Drawing
|
open System.Drawing
|
||||||
|
|
||||||
|
let colorMap i nMax =
|
||||||
|
let h =
|
||||||
|
if ((float (i % 256)) / 255.0) <= 1.0 then
|
||||||
|
((float (i % 256)) / 255.0) * 360.0
|
||||||
|
else 360.0
|
||||||
|
let s = 0.6
|
||||||
|
let v = if i < nMax then 1.0 else 0.0
|
||||||
|
|
||||||
|
MandelBrot.hsbToRgb h s v
|
||||||
|
|
||||||
let generatePixel x y height width zoom rMax maxIter =
|
let generatePixel x y height width zoom rMax maxIter =
|
||||||
let c = MandelBrot.getComplexValueForPixel (float x) (float y) (float height) (float width) zoom
|
let c = MandelBrot.getComplexValueForPixel (float x) (float y) (float height) (float width) zoom
|
||||||
let z = Complex(-0.8, 0.156)
|
let z = Complex(-0.8, 0.156)
|
||||||
|
|
@ -16,7 +26,7 @@ let generatePixel x y height width zoom rMax maxIter =
|
||||||
let newIm = 2.0 * c.Real * c.Imaginary
|
let newIm = 2.0 * c.Real * c.Imaginary
|
||||||
findI (i+1) (Complex(newRe, newIm)+z)
|
findI (i+1) (Complex(newRe, newIm)+z)
|
||||||
|
|
||||||
MandelBrot.colorMap (findI 0 c) maxIter
|
colorMap (findI 0 c) maxIter
|
||||||
|
|
||||||
let generate (width:int) height zoom rMax maxIter =
|
let generate (width:int) height zoom rMax maxIter =
|
||||||
let result = new Bitmap(width, height)
|
let result = new Bitmap(width, height)
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,10 @@ let getComplexValueForPixel x y height width zoom =
|
||||||
Complex ((x-width/2.0)/zoom, (y-height/2.0)/zoom)
|
Complex ((x-width/2.0)/zoom, (y-height/2.0)/zoom)
|
||||||
|
|
||||||
let colorMap i nMax =
|
let colorMap i nMax =
|
||||||
let h = ((float i) / 100.0) * 360.0
|
let h =
|
||||||
|
if ((float i) / 100.0) <= 1.0 then
|
||||||
|
((float i) / 100.0) * 360.0
|
||||||
|
else 360.0
|
||||||
let s = 1.0
|
let s = 1.0
|
||||||
let v = if i < nMax then 1.0 else 0.0
|
let v = if i < nMax then 1.0 else 0.0
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ let main argv =
|
||||||
let resultMandelbrot = MandelBrot.generate 800 600 150.0 32 570
|
let resultMandelbrot = MandelBrot.generate 800 600 150.0 32 570
|
||||||
resultMandelbrot.Save("mandelbrot.bmp")
|
resultMandelbrot.Save("mandelbrot.bmp")
|
||||||
|
|
||||||
|
printfn "Julia!"
|
||||||
let resultJulia = Julia.generate 800 600 150.0 32 570
|
let resultJulia = Julia.generate 800 600 150.0 32 570
|
||||||
resultJulia.Save("julia.bmp")
|
resultJulia.Save("julia.bmp")
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
|
|
@ -5,6 +5,7 @@
|
||||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Fractal.fs" />
|
||||||
<Compile Include="MandelBrot.fs" />
|
<Compile Include="MandelBrot.fs" />
|
||||||
<Compile Include="Julia.fs" />
|
<Compile Include="Julia.fs" />
|
||||||
<Compile Include="Program.fs" />
|
<Compile Include="Program.fs" />
|
||||||
|
|
|
||||||
BIN
julia.bmp
BIN
julia.bmp
Binary file not shown.
|
Before Width: | Height: | Size: 101 KiB After Width: | Height: | Size: 103 KiB |
BIN
mandelbrot.bmp
BIN
mandelbrot.bmp
Binary file not shown.
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 40 KiB |
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue