Sha256: a172c9df8d263ff193220d83fc8995389cbf2a850a9bc9fde76822e66cb3a76f

Contents?: true

Size: 911 Bytes

Versions: 4

Compression:

Stored size: 911 Bytes

Contents

#
# ParticleSystemPShape
# A particle system optimized for drawing using PShape
# For guts of implementation see 'particle' library
#
load_library :vecmath
load_library :particle

# Particle System object and image
attr_reader :ps 

def setup
  size(640, 360, P2D)
  # Load the image
  sprite = loadImage("sprite.png")
  # A new particle system with 10,000 particles
  @ps = ParticleSystem.new(width, height, sprite, 10000)
  # Writing to the depth buffer is disabled to avoid rendering
  # artifacts due to the fact that the particles are semi-transparent
  # but not z-sorted.
  hint(DISABLE_DEPTH_MASK)
end 

def draw 
  background(0)
  # Update and display system
  ps.update
  ps.display
  # Set the particle system's emitter location to the mouse
  ps.set_emitter(mouse_x, mouse_y)
  
  # Display frame rate
  fill(255, 0, 255)
  text_size(16)
  text("Frame rate: #{frame_rate.round(1)}", 10, 20)
  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ruby-processing-2.4.4 samples/processing_app/library/vecmath/particle_system_pshape.rb
ruby-processing-2.4.3 samples/processing_app/library/vecmath/particle_system_pshape.rb
ruby-processing-2.4.2 samples/processing_app/library/vecmath/particle_system_pshape.rb
ruby-processing-2.4.1 samples/processing_app/library/vecmath/particle_system_pshape.rb