Sha256: 287c0179f1a1e3e3ed1152bfaa05c6e703dee67586390c205f4e3c9d9c0020b4

Contents?: true

Size: 638 Bytes

Versions: 10

Compression:

Stored size: 638 Bytes

Contents

# Functions. 
# 
# The drawTarget() function makes it easy to draw many distinct targets. 
# Each call to drawTarget() specifies the position, size, and number of 
# rings for each target. 


def setup    
  size 640, 360    
  no_stroke
  no_loop
end

def draw    
  background 51    
  draw_target width * 0.25, height * 0.4, 200, 4
  draw_target width * 0.50, height * 0.5, 300, 10
  draw_target width * 0.75, height * 0.3,  120, 6
end

def draw_target ( x, y, size, num )    
  greys = 255 / num
  steps = size / num  	
  (0...num).each do |i|  		
    fill color(greys * i)
    ellipse x, y, size - i*steps, size - i*steps
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ruby-processing-2.6.3 samples/processing_app/basics/structure/functions.rb
ruby-processing-2.6.2 samples/processing_app/basics/structure/functions.rb
ruby-processing-2.6.1 samples/processing_app/basics/structure/functions.rb
ruby-processing-2.6.0 samples/processing_app/basics/structure/functions.rb
ruby-processing-2.5.1 samples/processing_app/basics/structure/functions.rb
ruby-processing-2.5.0 samples/processing_app/basics/structure/functions.rb
ruby-processing-2.4.4 samples/processing_app/basics/structure/functions.rb
ruby-processing-2.4.3 samples/processing_app/basics/structure/functions.rb
ruby-processing-2.4.2 samples/processing_app/basics/structure/functions.rb
ruby-processing-2.4.1 samples/processing_app/basics/structure/functions.rb