Greetings,
But I found some of the canvas APIs are not available, which is why I'm currently interested in creating an alternative to elm-graphics, focusing on implementing a low-level interface to the HTML5 Canvas, which could then be used to recreate the higher-level API elm-graphics offers.
I've come to ask help about API design, I can see a few ways of doing it:
One being somewhat similar to elm-graphics, which would be passing instructions to the render function
view model =
Html.div []
[ Canvas.draw2D ( 200, 300 )
[ Canvas.fillStyleColor <| Color.rgb 0 255 0
, Canvas.fillRect 10 10 100 100
]
]
or even pipeline-style
view model =
Html.div []
[ Canvas.draw2D ( 200, 300 )
|> Canvas.fillStyleColor (Color.rgb 0 255 0)
|> Canvas.fillRect 10 10 100 100
]
or instead through Messages and in the style of The Elm Architecture, the Canvas would be its own component
update msg model =
case msg of
Alert message color ->
model
! List.map MsgCanvas
[ Canvas.fillStyleColor color
, Canvas.fillText 10 10 message
]
MsgCanvas msg ->
{ model | canvas = Canvas.update msg model.canvas } ! []
view model =
Html.div [] [ Canvas.draw2D ( 200, 300 ) model.canvas ]
How do you feel about them? What else should I know about canvas, interfacing with JS, etc?
Thanks