1 people like it.
Like the snippet!
Hanoi test
just a test of fun3d
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
|
// This snippet has been shared from Fun3D web site.
// You can run it in your web browser at: www.fun3d.net!
let countOfDisks = 64
let initialState = [for x in 1..countOfDisks do yield x], List.empty, List.empty
let bottDiskSize = 4.
let cylHeight = 4.0
let diskSize size = size * bottDiskSize / float(countOfDisks)
let diskHeight = cylHeight / float(countOfDisks)
let diskPosition pos = pos * diskHeight
let cyl =
Fun.cylinder
|> Fun.scale (0.2, 0.2, cylHeight)
|> Fun.move (0.0, 0.0, cylHeight / 2.)
|> Fun.color 0xffff00
let bottDisk =
// Fun.empty
Fun.cylinder
|> Fun.scale (bottDiskSize, bottDiskSize, 0.1)
|> Fun.move (0.0, 0.0, - 0.05)
|> Fun.color 0xff00ff
let disk pos size =
let size = float(size)
Fun.cylinder
|> Fun.scale (diskSize size, diskSize size, diskHeight)
|> Fun.move (0.0, 0.0, diskPosition pos + (diskHeight/2.))
let tower towerState position =
towerState
|> List.rev
|> List.mapi (fun i v -> float(i),v)
|> List.fold (fun s (pos,size) -> s $ disk pos size ) (bottDisk $ cyl)
|> Fun.move (position, 0.0, 0.0)
let renderState state =
let tower1,tower2, tower3 = state
let towers = tower tower1 (-bottDiskSize - 0.1) $
tower tower2 0. $
tower tower3 (bottDiskSize + 0.1)
towers |> Fun.rotate (-90.0,0.0,0.0)
|> Fun.move (0.0, -cylHeight/2., 0.0)
renderState initialState
|
val countOfDisks : int
Full name: Script.countOfDisks
val initialState : int list * int list * int list
Full name: Script.initialState
val x : int
Multiple items
module List
from Microsoft.FSharp.Collections
--------------------
type List<'T> =
| ( [] )
| ( :: ) of Head: 'T * Tail: 'T list
interface IEnumerable
interface IEnumerable<'T>
member Head : 'T
member IsEmpty : bool
member Item : index:int -> 'T with get
member Length : int
member Tail : 'T list
static member Cons : head:'T * tail:'T list -> 'T list
static member Empty : 'T list
Full name: Microsoft.FSharp.Collections.List<_>
val empty<'T> : 'T list
Full name: Microsoft.FSharp.Collections.List.empty
val bottDiskSize : float
Full name: Script.bottDiskSize
val cylHeight : float
Full name: Script.cylHeight
val diskSize : size:float -> float
Full name: Script.diskSize
val size : float
Multiple items
val float : value:'T -> float (requires member op_Explicit)
Full name: Microsoft.FSharp.Core.Operators.float
--------------------
type float = System.Double
Full name: Microsoft.FSharp.Core.float
--------------------
type float<'Measure> = float
Full name: Microsoft.FSharp.Core.float<_>
val diskHeight : float
Full name: Script.diskHeight
val diskPosition : pos:float -> float
Full name: Script.diskPosition
val pos : float
val cyl : obj
Full name: Script.cyl
val bottDisk : obj
Full name: Script.bottDisk
val disk : pos:'a -> size:int -> 'b
Full name: Script.disk
val pos : 'a
val size : int
val tower : towerState:int list -> position:'a -> 'b
Full name: Script.tower
val towerState : int list
val position : 'a
val rev : list:'T list -> 'T list
Full name: Microsoft.FSharp.Collections.List.rev
val mapi : mapping:(int -> 'T -> 'U) -> list:'T list -> 'U list
Full name: Microsoft.FSharp.Collections.List.mapi
val i : int
val v : int
val fold : folder:('State -> 'T -> 'State) -> state:'State -> list:'T list -> 'State
Full name: Microsoft.FSharp.Collections.List.fold
val s : obj
val renderState : int list * int list * int list -> 'a
Full name: Script.renderState
val state : int list * int list * int list
val tower1 : int list
val tower2 : int list
val tower3 : int list
val towers : '_arg3
More information