Slide 1

Slide 1 text

2D & 3D Graphics 
 in Elm What we have now and what we may do with this… by @shamansir, 2017

Slide 2

Slide 2 text

Write Art

Slide 3

Slide 3 text

What we have now…

Slide 4

Slide 4 text

Elm Time-Travelling Debugger (R.I.P. …?)

Slide 5

Slide 5 text

2D: elm-lang/svg view : Model -> Html Msg view model = let angle = turns (Time.inMinutes model) handX = toString (50 + 40 * cos angle) handY = toString (50 + 40 * sin angle) in svg [ viewBox "0 0 100 100", width "300px" ] [ circle [ cx "50", cy "50", r "45", fill "#0B79CE" ] [] , line [ x1 "50", y1 "50", x2 handX, y2 handY , stroke "#023963" ] [] ]

Slide 6

Slide 6 text

2D: evancz/elm-graphics main : Element main = collage 300 300 (star blue) triangle color size angle = ngon 3 size |> filled color |> rotate (degrees angle) star color = map2 (triangle color) [100, 100] [30, 90]

Slide 7

Slide 7 text

3D: elm-community/webgl https://ellie-app.com/3wmPk4PGf8Ja1/0

Slide 8

Slide 8 text

3D: elm-community/webgl https://github.com/elm-community/webgl/blob/master/examples/first-person.elm

Slide 9

Slide 9 text

3D: TheSeamau5/GraphicsEngine import Engine (render, cube, pyramid, scene) import Math.Vector3 (vec3) myCube = { cube | position <- vec3 0 0 0, rotation <- vec3 45 0 45, scale <- vec3 1.5 1.5 1.5 } myPyramid = { pyramid | position <- vec3 2 0 0, scale <- vec3 0.5 1 0.5 } myScene = { scene | objects <- [myCube, myPyramid] } main = render myScene

Slide 10

Slide 10 text

What we may do with this…

Slide 11

Slide 11 text

fluxus https://github.com/zzkt/fluxus

Slide 12

Slide 12 text

shamansir/elm-fluxus https://github.com/shamansir/elm-fluxus https://vimeo.com/202176855

Slide 13

Slide 13 text

shamansir/elm-fluxus https://github.com/shamansir/elm-fluxus https://vimeo.com/202176855 import Math.Vector3 as Vec3 exposing (Vec3, vec3) import Fluxus.Program as Fx import Fluxus.State exposing ( ..) import Fluxus.Primitive as Primitive exposing ( ..) drawRow : Int -> State -> State drawRow count state = if (count > 0) then state |> translate (vec3 4 0 0) |> drawCube |> rotate (vec3 (10 * (sin (time state))) 0 0) |> withState (\state -> state |> rotate (vec3 0 25 0) |> drawRow (count - 1) ) |> withState (\state -> state |> rotate (vec3 0 -25 0) |> drawRow (count - 1) ) else state main : Fx.FluxusProgram main = Fx.everyFrame (drawRow 10)

Slide 14

Slide 14 text

shamansir/elm-fluxus https://github.com/shamansir/elm-fluxus https://vimeo.com/202176855 drawRow count state = if (count > 0) then state |> translate (vec3 4 0 0) |> drawCube |> rotate (vec3 (10 * (sin (time state))) 0 0) |> withState (\state -> state |> rotate (vec3 0 25 0) |> drawRow (count - 1) ) |> withState (\state -> state |> rotate (vec3 0 -25 0) |> drawRow (count - 1) ) else state main = Fx.everyFrame (drawRow 10)

Slide 15

Slide 15 text

Pict3D from DrRacket

Slide 16

Slide 16 text

Pict3D from DrRacket

Slide 17

Slide 17 text

Pict3D from DrRacket http://docs.racket-lang.org/pict3d/constructors.html

Slide 18

Slide 18 text

So… Why bother?

Slide 19

Slide 19 text

3D REPL?

Slide 20

Slide 20 text

Playgrounds?

Slide 21

Slide 21 text

EVE by Chris Granger https://www.youtube.com/watch?v=5V1ynVyud4M

Slide 22

Slide 22 text

Chris Granger: In Search of Tomorrow https://www.youtube.com/watch? v=VZQoAKJPbh8&t=1047

Slide 23

Slide 23 text

Chris Granger: Aurora (2013)

Slide 24

Slide 24 text

Chris Granger: Aurora https://www.youtube.com/watch?v=L6iUm_Cqx2s

Slide 25

Slide 25 text

Apparatus http://aprt.us/

Slide 26

Slide 26 text

So… Why Elm?

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

Strict. Minimal. Functional. Web.

Slide 29

Slide 29 text

Bring functionaλ!

Slide 30

Slide 30 text

Bring fun!

Slide 31

Slide 31 text

Thanks. Yours, @shamansir