Sha256: f6e1e7053d44530121a752ef1d7308a918f0b00b308c8e867971f80a2e799b6b

Contents?: true

Size: 1.14 KB

Versions: 6

Compression:

Stored size: 1.14 KB

Contents

#
# Sequential
# by James Paterson.  
# 
# Displaying a sequence of images creates the illusion of motion. 
# Twelve images are loaded and each is displayed individually in a loop. 
#

NUM_FRAMES = 12  # The number of frames in the animation
attr_reader :frame, :images

def setup
  size(640, 360)
  frame_rate(24)
  @frame = 0
  @images = []
  images << load_image('PT_anim0000.gif')
  images << load_image('PT_anim0001.gif')
  images << load_image('PT_anim0002.gif')
  images << load_image('PT_anim0003.gif')
  images << load_image('PT_anim0004.gif')
  images << load_image('PT_anim0005.gif')
  images << load_image('PT_anim0006.gif')
  images << load_image('PT_anim0007.gif')
  images << load_image('PT_anim0008.gif')
  images << load_image('PT_anim0009.gif')
  images << load_image('PT_anim0010.gif')
  images << load_image('PT_anim0011.gif')
end

def draw
  background(0)
  @frame = (frame + 1) % NUM_FRAMES  # Use % to cycle through frames
  offset = 0
  (-100 ... width).step(images[0].width) do |i|
    image(images[(frame + offset) % NUM_FRAMES], i, -20)
    offset += 2
    image(images[(frame + offset) % NUM_FRAMES], i, height / 2)
    offset += 2
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

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