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
Nice work! I like your function, I was thinking of asking everyone to do this and here you have already done it!
You can take this concept up a notch by also passing the ctx into your function as a parameter. Why? As it is your code replies on a variable outside with specific name. Passing ctx into the function injects this dependancy which makes the function work anywhere.
function draw(ctx, x, y) { ... }
Now you can call draw from anywhere with a context of any name.
constcontext=document.getElementById('canvas')draw(context,100,400)// or draw(document.getElementById('canvas'),100,400)
Make this change, test your work, then submit another pull request.
The text was updated successfully, but these errors were encountered:
shared-canvas/chao.js
Line 6 in e393e3c
Nice work! I like your function, I was thinking of asking everyone to do this and here you have already done it!
You can take this concept up a notch by also passing the
ctx
into your function as a parameter. Why? As it is your code replies on a variable outside with specific name. Passingctx
into the function injects this dependancy which makes the function work anywhere.function draw(ctx, x, y) { ... }
Now you can call draw from anywhere with a context of any name.
Make this change, test your work, then submit another pull request.
The text was updated successfully, but these errors were encountered: