init = { time = 0 } type Msg = Tick Float GetKeyState update msg model = case msg of Tick t _ -> { model | time = t } makePoint3D t x = let angle = 0.1 * t * x * 2 * pi / (toFloat numPoints) in (50 * sin angle,50 * cos angle, x - 0.5 * (toFloat numPoints)) project2D t (x,y,z) = let scale = (toFloat numPoints - (y * sin t - z * cos t) ) / (toFloat numPoints) in (scale * x, scale * (y * cos t + z * sin t)) depth t (x,y,z) = y * sin t - z * cos t makeLine : Float -> Float -> (Float,Float,Float) -> (Float,Float,Float) -> (Float,Shape Msg) makeLine t number (x1,y1,z1) (x2,y2,z2) = ( depth t (x1,y1,z1) , line (project2D t (x1,y1,z1)) (project2D t (x2,y2,z2)) |> outlined (solid 3) (hsl (number * 2 * pi / (toFloat numPoints)) 1 0.5) ) numPoints : Int numPoints = 500 myShapes model = let numbers = List.range 0 numPoints -- make list 0,1,2,... |> List.map toFloat -- convert to Floats points = numbers |> List.map (makePoint3D model.time) -- convert to point followers = List.drop 1 points depthLines : List (Float,Shape Msg) depthLines = List.map3 (makeLine model.time) numbers points followers lines = depthLines |> List.sortBy ( \ (d,_) -> -d) |> List.map Tuple.second in (rect 192 128 |> filled black) :: lines