joakin / elm-canvas

A canvas drawing library for Elm
https://package.elm-lang.org/packages/joakin/elm-canvas/latest/
BSD 3-Clause "New" or "Revised" License
163 stars 30 forks source link

I'm having a strange problem with the canvas rendering properly everywhere #4

Closed HappMacDonald closed 5 years ago

HappMacDonald commented 5 years ago

Namely: If I serve the canvas through reactor or through a compiled Html file, it's always just a transparent rectangle no matter what I put into it. I've tested this on up to date Opera, Chrome, and Firefox on Windows 10.

OTOH when I try the same thing (exact same code) with Ellie it seems to work fine in those same browsers: https://ellie-app.com/38zhvnLGCKMa1 :o

Do you reproduce the same, and/or is this a known issue at present? Or is what I describe difficult for others to reproduce?

joakin commented 5 years ago

Hi Jesse 👋

Because of Elm’s choices regarding interoperability, this library makes use of a web component to be able to access and interact with the canvas.

When compiling to HTML or serving through reactor the HTML is generated through the elm compiler, and you don’t have a chance to include the web component script. With those two methods it happens the same with ports or any other thing that requires a custom HTML file.

That is the situation right now. 😔

On Sun, 2 Dec 2018 at 04:11, Jesse Thompson notifications@github.com wrote:

Namely: If I serve the canvas through reactor or through a compiled Html file, it's always just a transparent rectangle no matter what I put into it. I've tested this on up to date Opera, Chrome, and Firefox on Windows 10.

OTOH when I try the same thing (exact same code) with Ellie it seems to work fine in those same browsers: https://ellie-app.com/38zhvnLGCKMa1 :o

Do you reproduce the same, and/or is this a known issue at present? Or is what I describe difficult for others to reproduce?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/joakin/elm-canvas/issues/4, or mute the thread https://github.com/notifications/unsubscribe-auth/AAoJr7LA_Jq7ieQGk68EoPi0Nqlq3n3bks5u00TrgaJpZM4Y9NqA .

HappMacDonald commented 5 years ago

Yay, that seems to work great.

1: Thank you!

2: thanks for being so polite despite my completely borking that being described right in the front page of the docs. 😅

3: I wonder how Ellie makes it work then? Did you make a deal with the Ellie folks to get your component script into the output or something? :B

4: Since you mention "Elm’s choices regarding interoperability", does using this strategy with the web component lead to Elm functions having side effects? EG: do the canvas commands in your module communicate with the outside world (including the canvas) only through a watershed of return values that terminate at TEA (and maybe web component takes over during TEA's watch which would be ideal), and do we maintain the guarantee that every call to a function in your module with input set X always produces an identical output set Y?

joakin commented 5 years ago

3: I wonder how Ellie makes it work then? Did you make a deal with the Ellie folks to get your component script into the output or something? :B

Ellie has a pane for the HTML of the page, in which I set up the web component script in the example from the docs.

4: Since you mention "Elm’s choices regarding interoperability", does using this strategy with the web component lead to Elm functions having side effects? EG: do the canvas commands in your module communicate with the outside world (including the canvas) only through a watershed of return values that terminate at TEA (and maybe web component takes over during TEA's watch which would be ideal), and do we maintain the guarantee that every call to a function in your module with input set X always produces an identical output set Y?

This library behaves exactly like the HTML one, so when running the functions there is no implicit side effects, until the HTML gets handled by the Elm runtime 👍