Drawing on Canvas

Good evening everyone,

I have tried to create my own little "Drawing on Canvas" tool. Unfortunately it already fails when drawing the lines. I have assigned the inner html and created a javascript. Is there a javascript / hype pro who can tell me what I'm doing wrong? Sorry I am a javascript beginner. I am grateful for any help.

Drawing on Canvas Test.zip (16,0 KB)

There are two things wrong:

  • you are making your code run using the window.onload event, but this event has already taken place by the time the code is called on scene load (because hype itself can't load your scene until after the window has loaded). You can just remove the window.onload = function() { line 6 and the closing }; line 29.

  • You have set a unique element ID in Hype's identity inspector, but also set the canvas id in the inner html. You should get rid of the one in hype's inspector since this applies to the div that contains your html, which isn't a canvas. You can also get rid of the class name while you're at it, since that's incorrect.

Then it will work.

1 Like

Thank you Jonathan!

Like you said, it's working now. Thanks for your quick answer!
I hope I can now expand my tool a little.

1 Like