Sha256: e823bb58af64a3bf6bef996a3011b46b7a5b3b82adb01cd1843f0d44baf3bdca

Contents?: true

Size: 756 Bytes

Versions: 9

Compression:

Stored size: 756 Bytes

Contents

require 'ruby-processing'

# Variables are used for storing values. In this example, changing 
# the values of variables @one and @two significantly changes the composition. 

class Variables < Processing::App
  
  load_library :control_panel
  
  def setup
    stroke 153
    
    @one = 20 # Change these with the sliders
    @two = 50
    
    control_panel do |c|
      c.slider :one, -20..100
      c.slider :two, -20..100
    end
  end


  def draw
    background 0
    
    c = @one * 8
    d = @one * 9
    e = @two - @one
    f = @two * 2
    g = f  + e
    
    line @one, f, @two,  g
    line @two, e, @two,  g
    line @two, e, d,     c
    line @one, e, d-e,   c
  end
  
end

Variables.new :title => "Variables", :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/variables.rb
ruby-processing-1.0.10.1 samples/processing_app/basics/data/variables.rb
ruby-processing-1.0.9 samples/processing_app/basics/data/variables.rb
ruby-processing-1.0.3 samples/processing_app/basics/data/variables.rb
ruby-processing-1.0.4 samples/processing_app/basics/data/variables.rb
ruby-processing-1.0.5 samples/processing_app/basics/data/variables.rb
ruby-processing-1.0.6 samples/processing_app/basics/data/variables.rb
ruby-processing-1.0.7 samples/processing_app/basics/data/variables.rb
ruby-processing-1.0.8 samples/processing_app/basics/data/variables.rb