You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @joakin! Thanks for all the great work you've done on this package.
Recently I've been playing with elm-canvas and elm-geometry. They work really nicely together. elm-geometry has a lot of useful functions that help you do things like find the center of a rectangle, or work with vectors. And of course, elm-canvas has a great API for drawing shapes.
My one problem is that it requires a lot of code to convert elm-geometry types to elm-canvas types.
For example, elm-canvas's, Canvas.circle gets called like this:
center =(100,100)radius =25Canvas.circle center radius
But if I want to use elm-geometry types, I have to do this:
-- Define a helper function to convert elm-geometry types to something that elm-canvas understands.circle:QuantityIntPixels->Point2dPixelsCanvasCoordinates->Canvas.Shapecircle radius center =let-- Convert our Point2d [1] to a tuple like ( x, y ).
centerTuple =Point2d.toTuple Pixels.inPixels center
-- Now convert radius to a Float. It starts as an instance of the `Quantity Pixels`-- type [2], which is how elm-geometry does type-safe math and unit conversions.
radiusInPixels =
radius
|>Pixels.toInt
|> toFloat
inCanvas.circle
centerTuple
radiusInPixels
[1]: Here are the Point2d docs.
[2]: And here are the Quantity docs.
Thanks again for all your hard work! I really like using this library, and I think that adding support for elm-geometry types would make it even more fun and enjoyable.
The text was updated successfully, but these errors were encountered:
I think that would be wonderful, but usually that kind of library mixins happen as a new package in the Elm ecosystem. So for example you could create the package elm-canvas-geometry or the other way around, and publish an elm-geometry friendly interface to use this drawing lib.
Due to this library needing some manual JS installation it would be a bit clunkier than with others like elm-css or elm-accesible-html etc, but it is definitely something that is often done.
For this library I'd rather keep the barrier to entry lower, elm-geometry is awesome, but it definitely creates some more ceremony and boilerplate when dealing with numbers (because it forces you to think about what they are and how to mix them, which is a good thing, but also adds cognitive cost to the drawing).
Hi @joakin! Thanks for all the great work you've done on this package.
Recently I've been playing with elm-canvas and elm-geometry. They work really nicely together. elm-geometry has a lot of useful functions that help you do things like find the center of a rectangle, or work with vectors. And of course, elm-canvas has a great API for drawing shapes.
My one problem is that it requires a lot of code to convert elm-geometry types to elm-canvas types.
For example, elm-canvas's,
Canvas.circle
gets called like this:But if I want to use elm-geometry types, I have to do this:
[1]: Here are the Point2d docs.
[2]: And here are the Quantity docs.
Thanks again for all your hard work! I really like using this library, and I think that adding support for elm-geometry types would make it even more fun and enjoyable.
The text was updated successfully, but these errors were encountered: