0

I'm new to web development and am trying to add a clear canvas feature to a drawing application. The app's in HTML5 with Firebase as a backend.

Right now I have this in JS:

function clearCanvas() {
  // clear the canvas
  myCanvas.clearRect(0, 0, myCanvas.width, myCanvas.height);
  // removes the pixel data from firebase
  pixelRefData.remove();
}

And this in HTML5:

<button onclick= "clearCanvas()"> Clear <button>

Yet whenever I click the "clear" button when I test, nothing is ever cleared. Help?

André Kool
  • 4,880
  • 12
  • 34
  • 44
Sky
  • 1
  • 1
  • Are you sure it is not working, try the example here https://www.firebase.com/how-it-works-drawing-demo.html – Risto Novik Jun 25 '15 at 07:49
  • Yeah that one works, but I can't find anything in their inspect element. They don't seem to be clearing their canvas using JS – Sky Jun 25 '15 at 07:58
  • possible duplicate of [How to clear the canvas for redrawing](http://stackoverflow.com/questions/2142535/how-to-clear-the-canvas-for-redrawing) – André Kool Jun 25 '15 at 08:19
  • I'm not sure what the exact problem is here. Clearing canvas has already been answered in this question: http://stackoverflow.com/questions/2142535/how-to-clear-the-canvas-for-redrawing – André Kool Jun 25 '15 at 08:22
  • Oh when you look at the first link I posted, there you can see the clearing method: ```$('#drawing-canvas').get(0).getContext('2d').clearRect(0, 0, 100, 150);```. Make sure you have the canvas context. – Risto Novik Jun 26 '15 at 09:44

0 Answers0