toEntities : { a | width : WebGL.Shape2d.Render.Width, height : WebGL.Shape2d.Render.Height } -> List SolidShape -> List WebGL.Entity
Converts List SolidShape
to WebGL entities
main : Program () () a
main =
Browser.sandbox
{ init = ()
, view = view
, update = \_ model -> model
}
view : model -> Html msg
view _ =
let
screen =
Game2d.toScreen 100 100
in
{ entities =
[ rectangle (rgb 239 41 41) 20 20 ]
|> SolidShape.toEntities screen
, screen = screen
}
|> Game2d.view
shape : WebGL.Shape2d.Render.Width -> WebGL.Shape2d.Render.Height -> WebGL.Shape2d.Render.Render -> SolidShape
Create SolidShape
from Render
rectangle : Color -> Width -> Height -> SolidShape
rectangle color w h =
Render.rect color |> SolidShape.shape w h
group : List SolidShape -> SolidShape
Put shapes together so you can move
and rotate
them as a group. Maybe you want to put a bunch of stars in the sky:
shapes =
[ star
|> move 100 100
|> rotate 5
, star
|> move -120 40
|> rotate 20
, star
|> move 80 -150
|> rotate 32
, star
|> move -90 -30
|> rotate -16
]
star =
group
[ triangle yellow 20
, triangle yellow 20
|> rotate 180
]
WebGL.Shape2d.Shape.Shape Form