     @ctx.clearRect(0, 0, @canvas.width, @canvas.height)
     if @canvas.width > 0 and @canvas.height > 0
       @ctx.drawImage @buffer, 0, 0
+    @trigger('repaint', null)
 
   # Redraws the back buffer to the screen in its current state
   # then draws the given shape translated and scaled on top of that.

      @position.y, @canvas.height, oldScale, @scale)

    @repaint()

  # Repaints the canvas.
  # If dirty is true then all saved shapes are completely redrawn,


  saveShape: (shape) ->
    @execute(new LC.AddShapeAction(this, shape))
    @trigger('saveShape', {shape: shape})

  pan: (x, y) ->
    # Subtract because we are moving the viewport
    @position.x = @position.x - x
    @position.y = @position.y - y
    @trigger('pan', {x: @position.x, y: @position.y})

  zoom: (factor) ->
    oldScale = @scale
