Sha256: 9dae29a43c34c9306f97ddde7bc1752bded04e80b4448e9d4a44cf7437416ce3

Contents?: true

Size: 690 Bytes

Versions: 4

Compression:

Stored size: 690 Bytes

Contents

require 'ruby-processing'

class ImageSpriteSketch < Processing::App

  def setup
    @head = load_image("face.jpg")  # variable for the image file
    @x, @y = 0, width/2             # variables for image location
    @rot = 0.0                      # variable for image rotation
  end

  def draw
    background 255

    translate @x, @y
    rotate @rot

    # Images can be animated just like regular shapes using variables, translate, rotate, and so on.
    image @head, 0, 0
    # Adjust variables for animation
    @x += 1.0
    @rot += 0.02
    @x = -@head.width if @x > width + @head.width
  end

end

ImageSpriteSketch.new :title => "Image Sprite", :width => 200, :height => 200


Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ruby-processing-1.0.1 samples/learning_processing/chapter_15/02_image_sprite.rb
ruby-processing-1.0.2 samples/learning_processing/chapter_15/02_image_sprite.rb
ruby-processing-1.0.4 samples/learning_processing/chapter_15/02_image_sprite.rb
ruby-processing-1.0.3 samples/learning_processing/chapter_15/02_image_sprite.rb