Layer = require './Layer.coffee'

# Layer that features a back-buffer that is created/maintained that is then
# drawn onto the main canvas. Useful e.g. particles, complicated but static
# scenes
module.exports = class BufferedLayer extends Layer

  constructor: (opts = {}) ->
    super

    # Internal canvas buffer
    @buffer = document.createElement 'canvas'
    @buffer.width = opts.width if opts.width?
    @buffer.height = opts.width if opts.height?
    @ctx = @buffer.getContext '2d'
    return

  # Normal evolve of the scene
  update: (dt) ->

  # Draw the back buffer onto the scene
  render: (ctx) ->
    ctx.drawImage @buffer, 0, 0


