Sha256: 6037b7d957b2c832cb886f96ac8735da7319e472edbd0ab0323be2331244d8d6

Contents?: true

Size: 776 Bytes

Versions: 6

Compression:

Stored size: 776 Bytes

Contents

# GLSL version of Conway's game of life, ported from GLSL sandbox:
# http://glsl.heroku.com/e/207.3
# Exemplifies the use of the ppixels uniform in the shader, that gives
# access to the pixels of the previous frame.
attr_accessor :pg, :conway

def setup
  size(400, 400, P3D)    
  @pg = createGraphics(400, 400, P2D)
  pg.no_smooth
  @conway = load_shader('data/conway.glsl')
  conway.set('resolution', width.to_f, height.to_f)  
end

def draw
  conway.set('time', millis / 1000.0)  
  xm = map(mouse_x, 0, width, 0, 1)       # NB: processings map function
  ym = map(mouse_y, 0, height, 1, 0)
  conway.set('mouse', xm, ym) 
  pg.begin_draw
  pg.background(0)
  pg.shader(conway)
  pg.rect(0, 0, pg.width, pg.height)  
  pg.end_draw  
  image(pg, 0, 0, width, height)  
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ruby-processing-2.6.3 samples/processing_app/topics/shaders/conway.rb
ruby-processing-2.6.2 samples/processing_app/topics/shaders/conway.rb
ruby-processing-2.6.1 samples/processing_app/topics/shaders/conway.rb
ruby-processing-2.6.0 samples/processing_app/topics/shaders/conway.rb
ruby-processing-2.5.1 samples/processing_app/topics/shaders/conway.rb
ruby-processing-2.5.0 samples/processing_app/topics/shaders/conway.rb