title: Resize a raster background image using Paper.js
body: <p>I am trying to add a background image to a canvas element with a script tag in the bottom of my HTML.</p>
  
  <p>The output of this code is a small version, like a single tile, of the larger image. In the inspector, the canvas has been processed already so there is no way to control the image size with css.</p>
  
  <p>Here is the javascript:</p>
  
  <pre><code>    window.onload = function() {
          // plain image coming server side 
          var crag_image = $('#last-upload').attr('src');
          var canvas = document.getElementById('myCanvas');
          paper.setup(canvas);
  
          // Let's get layers working
          var img = document.createElement('img');
          img.src =  crag_image;
          img.id = "background-crag";
          var layer = new paper.Layer();
          var raster = new paper.Raster(img);
  
          // End Layers
  
          var secondLayer = new paper.Layer();
          secondLayer.activate();
  
          var myPath = new paper.Path();
          myPath.strokeColor = 'red';
          myPath.strokeWidth = 2.5;
  
  
          // Draw the view:
          paper.view.draw();
  
          var tool = new paper.Tool();
  
          tool.onMouseDown = function(event) {
              myPath.add(event.point);
          }
  
          tool.onMouseDrag = function(event) {
            myPath.add(event.point);
            // Update the content of the text item to show how many
            textItem.content = 'Segment count: ' + myPath.segments.length;
          }
  
          // When the mouse is released, simplify the path:
          function onMouseUp(event) {
            var segmentCount = path.segments.length;
            myPath.simplify(10);
            myPath.fullySelected = true;
            var newSegmentCount = myPath.segments.length;
            var difference = segmentCount - newSegmentCount;
            var percentage = 100 - Math.round(newSegmentCount / segmentCount * 100);
          }
     }
  </code></pre>
  
  <p>An update:</p>
  
  <pre><code>var raster = new paper.Raster(img); //works
  </code></pre>
  
  <p>If I try to expand the constructor as per the reference it then fails on what the view is.</p>
  
  <pre><code>var raster = new paper.Raster({
    source: img.src,
    position: view.center
  });
  </code></pre>