title: Canvas rectangle background image
body: <p>I want to set background image to my rectangle in the canvas.
  So far i've done this.</p>
  
  <pre><code>var img = new Image()
      img.src = //Source of an image.
  var newPattern = ctx.createPattern(img, "no-repeat");
  ctx.fillStyle = newPattern;
  </code></pre>
  
  <p>And it works, but the problem is, that it applies the image to the canvas, not to the rectangle.</p>
  
  <p>And whenever I change the position of the rectangle, the image remains in the same position.</p>
  
  <p>Can anybody suggest how to fix this, so the image'd be attached to the rectangle.</p>