Sha256: cb7b6acac54f32c29d454f70dec21d3459d604d086448cd7f549b8e8568c5787

Contents?: true

Size: 680 Bytes

Versions: 2

Compression:

Stored size: 680 Bytes

Contents

# Translate. 
# 
# The translate() function allows objects to be moved
# to any location within the window. The first parameter
# sets the x-axis offset and the second parameter sets the
# y-axis offset. 
 
class Translate < Processing::App

  def setup
    
    size 200, 200
    no_stroke
    frame_rate 30
    
    @x, @y = 0.0, 0.0
    @size = 40.0
  end
  
  def draw
  
  	background 102
  	
  	@x += 0.8
  	
  	@x = -@size if @x > width + @size
  	
  	translate @x, height/2 - @size/2
  	
  	fill 255
  	rect -@size/2, -@size/2, @size, @size
  	
  	translate @x, @size
  	
  	fill 0
  	rect -@size/2, -@size/2, @size, @size
  end
  
end

Translate.new :title => "Translate"

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruby-processing-1.0.11 samples/processing_app/basics/transform/translate.rb
ruby-processing-1.0.10.1 samples/processing_app/basics/transform/translate.rb