Sha256: d0ffe7916ec9febf52b6bf874e4266e54724ba5f70932b07a7448dd1a6e44354

Contents?: true

Size: 833 Bytes

Versions: 9

Compression:

Stored size: 833 Bytes

Contents

require 'ruby-processing'

# Integers and floats are two different kinds of numerical data. 
# An integer (more commonly called an int) is a number without 
# a decimal point. A float is a floating-point number, which means 
# it is a number that has a decimal place. Floats are used when
# more precision is needed. 

class IntegersFloats < Processing::App

  def setup
    stroke 255
    frame_rate 30
    
    @a = 0		# Create an instance variable "a" of class Integer
    @b = 0.0	# Create an instance variable "b" of class Float (because of "0.0")
  end
  
  def draw
  	background 51
  	
  	@a += 1
  	@b += 0.2
  	
  	line @a, 0,        @a, height/2
  	line @b, height/2, @b, height
  	
  	@a = 0 if @a > width
  	@b = 0 if @b > width
  end
  
end

IntegersFloats.new :title => "Integers Floats", :width => 200, :height => 200

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ruby-processing-1.0.11 samples/processing_app/basics/data/integers_floats.rb
ruby-processing-1.0.10.1 samples/processing_app/basics/data/integers_floats.rb
ruby-processing-1.0.9 samples/processing_app/basics/data/integers_floats.rb
ruby-processing-1.0.4 samples/processing_app/basics/data/integers_floats.rb
ruby-processing-1.0.3 samples/processing_app/basics/data/integers_floats.rb
ruby-processing-1.0.5 samples/processing_app/basics/data/integers_floats.rb
ruby-processing-1.0.6 samples/processing_app/basics/data/integers_floats.rb
ruby-processing-1.0.7 samples/processing_app/basics/data/integers_floats.rb
ruby-processing-1.0.8 samples/processing_app/basics/data/integers_floats.rb