Sha256: bed2af63faf0c3db654a4d9e0fea4abe6f61ce66fde52473c57e1357c0d21c89

Contents?: true

Size: 649 Bytes

Versions: 10

Compression:

Stored size: 649 Bytes

Contents

# Embedding "for" structures allows repetition in two dimensions. 

def setup
  size 640, 360
  background 0
  no_stroke
  
  box_size = 11.0
  box_space = 12.0
  margin = 7
  
  # Draw gray boxes 
  
  (margin...height-margin).step(box_space) do |i|
    # or, if you feel more java-loopy:
    # i = margin; while i < height-margin
    
    if box_size > 0
      
      (margin...width-margin).step(box_space) do |j|
        
        fill( 255 - box_size * 10 )
        rect j, i, box_size, box_size
      end
      
    end
    
    box_size -= 0.3
    
    # for java loops, don't forget to increment with while:
    # i += box_space
  end
  
end

Version data entries

10 entries across 10 versions & 1 rubygems

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