Skip to content
← Back to Community
creating a canvas
Profile icon
h
has Hacker Plan
Nanowrimoijk

https://repl.it/@Nanowrimoijk/IllfatedImmaculateRuntime

im trying to create a canvas but i cant figure out how to get the context
if you have any suggestions please comment down below.

Answered by Vandesm14 [earned 5 cycles]
View Answer
Voters
Profile icon
Miguel-CholoCho
Profile icon
Nanowrimoijk
Comments
hotnewtop
Profile icon
Vandesm14

You'd either want to change the id of the canvas html to "canvas" or change the javascript parameter on line 1 from "canvas" to "gamescreen". Also, if you are a beginner, it would be better to change the let statements to var statements.
What that does is allows you to access the variables easier, instead of just on that script link.

Please upvote if this comment was helpful in any way. Thanks!

Profile icon
Nanowrimoijk

@Vandesm14 if you look in line 2 of my .js file it wont take getContext

Profile icon
Vandesm14

@Nanowrimoijk Oops. I forgot to clarift: The ID of an html element is case sensitive and and directly corresponds to the Javascript call. So you should put the Javascript parameter as "Gamescreen"

This was a fault on my end. A simple typo makes a big difference.

Profile icon
Nanowrimoijk

@Vandesm14 thankyou, now my getContext is working!

Profile icon
John_WardWard

@Nanowrimoijk I may not know much about HTML (I only know python and a tiny bit of HTML and Ruby) I am definitely seeing a canvas here:
This file cannot be displayed: https://storage.googleapis.com/replit/images/1543440638872_df76c2c13be75a7ba319d4774d2fc990.pn

If I have misinterpreted the question, I am sorry.

Profile icon
Nanowrimoijk

@John_WardWard i am trying to get the context so i can draw things to the canvas

Profile icon
finnegan

Your blog has piqued a lot of real interest. I can see why since you have done such a good job of making it interesting. I appreciate your efforts very much.ambbet wallet