       secondary: opts.secondaryColor or '#fff'
       background: opts.backgroundColor or 'transparent'
 
-    @containerEl.style['background-color'] = @colors.background
-
     @watermarkImage = opts.watermarkImage
     @watermarkScale = opts.watermarkScale or 1
 
     @backgroundCanvas = document.createElement('canvas')
     @backgroundCtx = @backgroundCanvas.getContext('2d')
-    @containerEl.appendChild(@backgroundCanvas)
-    @backgroundShapes = opts.backgroundShapes || []
-
-    @_shapesInProgress = []
 
     @canvas = document.createElement('canvas')
     @canvas.style['background-color'] = 'transparent'
-    @containerEl.appendChild(@canvas)
 
     @buffer = document.createElement('canvas')
     @buffer.style['background-color'] = 'transparent'


module.exports = class LiterallyCanvas

  constructor: (@containerEl, opts) ->
    @_unsubscribeEvents = bindEvents(this, @containerEl, opts.keyboardShortcuts)

    @opts = opts

    @config =

    # that all layers are repainted.
    @setZoom(@scale)

    @loadSnapshot(opts.snapshot) if opts.snapshot

    @isBound = false
    @bindToElement(containerEl)

  bindToElement: (containerEl) ->
    if @containerEl
      console.warn("Trying to bind Literally Canvas to a DOM element more than once is unsupported.")
      return

    @containerEl = containerEl
    @_unsubscribeEvents = bindEvents(this, @containerEl, @opts.keyboardShortcuts)
    @containerEl.style['background-color'] = @colors.background
    @containerEl.appendChild(@backgroundCanvas)
    @containerEl.appendChild(@canvas)

    @isBound = true

    repaintAll = =>
        @keepPanInImageBounds()
        @repaintAllLayers()

    util.matchElementSize(
      @containerEl, [@backgroundCanvas, @canvas], @backingScale, repaintAll)

    if @watermarkImage
      @watermarkImage.onload = => @repaintLayer('background')

    repaintAll()

  _teardown: ->
    @tool.willBecomeInactive(this)
    @tool = null
    @_unsubscribeEvents?()

  trigger: (name, data) ->
    @canvas.dispatchEvent(new CustomEvent(name, detail: data))
