title: Add new canvas context method
body: <p>I use the following code to make sure <code>resetTrasform</code> method is available for canvas.</p>
  
  <pre><code>if (!CanvasRenderingContext2D.prototype.resetTransform) {
      CanvasRenderingContext2D.prototype.resetTransform = function() {
          CanvasRenderingContext2D.prototype.setTransform(1, 0, 0, 1, 0, 0);
      };
  }
  </code></pre>
  
  <p>Formerly, I used to use </p>
  
  <pre><code>var canvas      = document.getElementById("canvas");
  var context     = canvas.getContext("2d");
  
  if (!context.resetTransform) {
      context.resetTransform = function() {
          context.setTransform(1, 0, 0, 1, 0, 0);
      };
  }
  </code></pre>
  
  <p>but this depends on the variable <code>context</code>. If I were to name it differently, the following code wouldn't work, or I'd have to modify the if statement. </p>
  
  <p>Anyway, using the prototype approach I want to define another method. I tried the following</p>
  
  <pre><code>CanvasRenderingContext2D.prototype.newBlankFrame = function() {
      CanvasRenderingContext2D.prototype.resetTransform();
      CanvasRenderingContext2D.clearRect(0, 0, canvas.width, canvas.height);
  };
  </code></pre>
  
  <p>but it doesn't work. It throws this error</p>
  
  <pre><code>Uncaught TypeError: Illegal invocation
  </code></pre>
  
  <p>at <code>CanvasRenderingContext2D.prototype.resetTransform();</code></p>
  
  <p>Also if I remove <code>CanvasRenderingContext2D.prototype.resetTransform();</code> and just use <code>CanvasRenderingContext2D.clearRect(0, 0, canvas.width, canvas.height);</code>, it still throws error: <code>Uncaught TypeError: CanvasRenderingContext2D.clearRect is not a function</code>.</p>
  
  <p>I just want to have a method that'll remove any transform and clear the canvas. I could make it like this</p>
  
  <pre><code>var canvas      = document.getElementById("canvas");
  var context     = canvas.getContext("2d");
  
  context.newBlankFrame = function() {
      context.resetTransform();
      context.clearRect(0, 0, canvas.width, canvas.height);
  };
  </code></pre>
  
  <p>but this, like I said before, is dependent on the variable name. Is there a way to make this work using prototype? I want the method to be available for any canvas context.</p>