le-michael / ElmJrMetalEdition

2 stars 0 forks source link

Support list concat (++) and push left (::) operators #115

Closed WyattWismer closed 3 years ago

WyattWismer commented 3 years ago

With this change we support the ++ and :: operators. That means we now have everything we need to generate recursive fractals!

You can try out the following code as an example:

bs h = (sphere
        |> color (rgb (1/(h/6+1)) 0 (1-1/(h/6+1)))
        |> move ((h/10), (h/10), 0)
        |> scaleAll (0.5 - (0.5/25)*h))

gen x = (if x == 0 then [bs 0] else (bs x) :: (gen (x-1)))

myShapes : Float -> List Shape
myShapes time = (gen 20)

lights =
    [ DirectionalLight (RGB 0.6 0.6 0.6) (1, 2, 2) (RGB 0.1 0.1 0.1)
    , AmbientLight (RGB 1 1 1) 0.5
    ]

scene = viewWithTimeAndCamera (ArcballCamera 5 (0, -1, 0) Nothing Nothing) (RGB 1 1 1) lights myShapes

It produces the following image:

Screen Shot 2021-02-09 at 11 24 13 AM