How to reference canvas inside a function's scope?
I get error with this code, it seems like ctx is not known inside the function. How can I reference the canvas from within the function?
Code:
var c = document.getElementById("canvas1");
var ctx = c.getContext("2d");
var isDrawing = false;
var mX, mY, rX, rY;
function InitThis() {
c.onmousedown = function(e) {
isDrawing = true;
mX = e.clientX;
Leave a comment: