Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elm 0.19 - No more Native support #77

Open
JordyMoos opened this issue Aug 23, 2018 · 3 comments
Open

Elm 0.19 - No more Native support #77

JordyMoos opened this issue Aug 23, 2018 · 3 comments

Comments

@JordyMoos
Copy link
Contributor

Since 0.19 the ability to freely use native modules has been removed.
Apparently projects in Elm Explorations are allowed to use native code.

My question is: Is there a plan to move this canvas project to elm explorations?

At the moment I use elm-canvas as the render for my little pixel game and I need to know if I should change to webgl or if there is a future in the library.

Maybe there is a way for me to help?

@Chadtech
Copy link
Collaborator

Chadtech commented Aug 23, 2018

I sent a message to Evan and Luke asking if Elm-Canvas could move to Elm-Explorations. They just didnt reply. I've also asked about how I can do my Elm-Canvas projects with ports or web components, and I got a few answers, but none that really seemed like a better alternative to Elm-Canvas.

I've poked around in the Elm compiler, and built it locally. I'm sure theres a way to hack the Elm compiler and make a build that enables kernel code. That sounds like a really horrible option, but I dont see another way so long as Elm-Canvas remains the best way to do what I need to do.

Thanks for offering to help. If you want you could message Evan or Luke or another Elm higher-up about it yourself (maybe in a week when the commotion of 0.19 dies down). I think more voices means the more likely they are to take the idea seriously, and you wouldnt be the first person to mention the idea of Elm-Canvas joining Elm-Explorations either.

@Pablorious
Copy link

Any chance of this happening after it has been five years? I'm questioning whether it's better to create a web component to edit pixels on a canvas at this point -- but something about requiring js interop for something like this strikes me as wrong

@Chadtech
Copy link
Collaborator

No I don't think this repo is going anywhere. Sorry. Thanks for following up.

In the last 5 years I have done some canvas stuff through ports and it seemed to work fine. I recall writing a JS module called a CanvasManager that keeps track of canvases by id, and listens for Elm commands to manipulate canvases in the way Elm is asking. It worked. I don't recall any problems. If I were to work on that stuff today maybe I would do something more fancy by putting it in a web component and pass the Canvas commands in through html attributes.

Also, in the last 5 years, Joakin came out with his own elm-canvas that works differently: https://github.com/joakin/elm-canvas

Whether a CanvasManager or Joakin's Elm-Canvas are right for you, I think it depends on your use case. Joakin's Elm-Canvas is probably better for most use-cases. My elm-canvas would make changes to a specific canvas and that canvas would persist between view cycles. So it was stateful but also efficient regarding draws. Joakin's elm-canvas works by executing every canvas drawing operation on a new canvas every view cycle. My interest in canvas stuff was to do a pixel art program, which means a large number of individual pixel edits over a long user session. For my project, Joakin's elm-canvas would not work, because the number of drawing operations would get too long to execute every view cycle.

But my use case was pretty unusual. If you are trying to draw something artistic, or a finite list of shapes, it seems like Joakin's Elm canvas would work well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants