Sha256: 9b44ce37826e4325f2bca5ba7e8c0db19d10e354cb69223b7c2b32af0630886b

Contents?: true

Size: 556 Bytes

Versions: 5

Compression:

Stored size: 556 Bytes

Contents

# Pie Chart  
# By Ira Greenberg 
# 
# Uses the arc() function to generate a pie chart from the data
# stored in an array.


def setup
  size 640, 360
  background 100
  smooth
  no_stroke
  
  diameter = min(width, height) * 0.75
  angles = [30, 10, 45, 35 ,60, 38, 75, 67]
  last_angle = 0.0
  
  angles.each do |angle|
    fill angle * 3.0
    arc width/2, height/2, 	 						    # center x, y
    diameter, diameter,  						      # width, height
    last_angle, last_angle + radians(angle)	# angles from, to
    last_angle += radians(angle)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ruby-processing-2.5.0 samples/processing_app/basics/form/pie_chart.rb
ruby-processing-2.4.4 samples/processing_app/basics/form/pie_chart.rb
ruby-processing-2.4.3 samples/processing_app/basics/form/pie_chart.rb
ruby-processing-2.4.2 samples/processing_app/basics/form/pie_chart.rb
ruby-processing-2.4.1 samples/processing_app/basics/form/pie_chart.rb