Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
10
Task/Julia-set/F-Sharp/julia-set-1.fs
Normal file
10
Task/Julia-set/F-Sharp/julia-set-1.fs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
let getJuliaValues width height centerX centerY zoom maxIter =
|
||||
let initzx x = 1.5 * float(x - width/2) / (0.5 * zoom * float(width))
|
||||
let initzy y = 1.0 * float(y - height/2) / (0.5 * zoom * float(height))
|
||||
let calc y x =
|
||||
let rec loop i zx zy =
|
||||
if i=maxIter then 0
|
||||
elif zx*zx + zy*zy >= 4.0 then i
|
||||
else loop (i + 1) (zx*zx - zy*zy + centerX) (2.0*zx*zy + centerY)
|
||||
loop 0 (initzx x) (initzy y)
|
||||
[0..height-1] |> List.map(fun y->[0..width-1] |> List.map (calc y))
|
||||
3
Task/Julia-set/F-Sharp/julia-set-2.fs
Normal file
3
Task/Julia-set/F-Sharp/julia-set-2.fs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
getJuliaValues 80 25 -0.7 0.27015 1.0 50
|
||||
|> List.map(fun row-> row |> List.map (function | 0 ->" " |_->".") |> String.concat "")
|
||||
|> List.iter (printfn "%s")
|
||||
20
Task/Julia-set/F-Sharp/julia-set-3.fs
Normal file
20
Task/Julia-set/F-Sharp/julia-set-3.fs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
open System.Drawing
|
||||
open System.Windows.Forms
|
||||
|
||||
let showGraphic (colorForIter: int -> Color) width height centerX centerY zoom maxIter =
|
||||
new Form()
|
||||
|> fun frm ->
|
||||
frm.Width <- width
|
||||
frm.Height <- height
|
||||
frm.BackgroundImage <-
|
||||
new Bitmap(width,height)
|
||||
|> fun bmp ->
|
||||
getJuliaValues width height centerX centerY zoom maxIter
|
||||
|> List.mapi (fun y row->row |> List.mapi (fun x v->((x,y),v))) |> List.collect id
|
||||
|> List.iter (fun ((x,y),v) -> bmp.SetPixel(x,y,(colorForIter v)))
|
||||
bmp
|
||||
frm.Show()
|
||||
|
||||
let toColor = (function | 0 -> (0,0,0) | n -> ((31 &&& n) |> fun x->(0, 18 + x * 5, 36 + x * 7))) >> Color.FromArgb
|
||||
|
||||
showGraphic toColor 640 480 -0.7 0.27015 1.0 5000
|
||||
Loading…
Add table
Add a link
Reference in a new issue