Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Canvas
- constructor: (w, h) ->
- @cnv = document.createElement 'canvas'
- @cnv.width = w
- @cnv.height = h
- @ctx = @cnv.getContext '2d'
- @drawLayers = []
- @running = false
- start: ->
- @running = true
- render = =>
- if @running
- requestAnimationFrame =>
- i(@cnv) for i in @drawLayers
- @render()
- stop: -> @running = false
- addLayer: (cb) ->
- @drawLayers.push cb
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement