Sha256: 9dd5f378a6cd0f43750a22799a6da183def5f0f5a228a7a4804541edc93c8c21

Contents?: true

Size: 1.57 KB

Versions: 1

Compression:

Stored size: 1.57 KB

Contents

<%= javascript_object %> = new Processing.Sketch (__processing) ->
  for __sym of __processing when eval("typeof #{__sym} === 'undefined'")
    if typeof __processing[__sym] == 'function'
      eval "var #{__sym} = function() { return __processing.#{__sym}.apply(__processing, arguments) }"
    else
      eval "var #{__sym} = function() { return __processing.#{__sym} }"

  for __const of __processing.PConstants
    eval "var #{__const} = __processing.PConstants.#{__const}"

  for __sym in ['ArrayList', 'HashMap', 'PVector', 'ObjectIterator', 'PConstants']
    eval "var #{__sym} = __processing.#{__sym}"

  processing = __processing

  <%= code %>

  __inject = ->
    for callback in [
      'setup',
      'draw',
      'mouseClicked',
      'mouseDragged',
      'mouseMoved',
      'mouseOut',
      'mouseOver',
      'mousePressed',
      'mouseReleased',
      'keyPressed',
      'keyReleased',
      'keyTyped'
    ] when !eval("typeof #{__sym} === 'undefined'")
      eval "__processing.#{callback} = #{callback}"

  __polling = ->
    interval = 100
    if __processing.externals.sketch.imageCache.pending or __processing.PFont.preloading.pending(interval)
      window.setTimeout __polling, interval
    else
      __inject()
      setup() if (typeof setup)?

  if preload?
    if preload.fonts?
      for __font in preload.fonts
        __processing.PFont.preloading.add __font
    if preload.images?
      for __image in preload.images
        __processing.externals.sketch.imageCache.add __image

    __processing.setup = -> __polling()
    __processing.draw = -> null
  else
    __inject()

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
coffee-processing-0.0.5 lib/coffee-processing/boilerplate.coffee.erb