// the frequencies as collected during the in class survey int[] numBirthdays = {1, 1, 1, 2, 4, 5, 4, 1, 4, 2, 1, 6}; int N; float cx, cy, sz; void setup() { // Compute the total size of population, N N = 0; for (int n : numBirthdays) { N += n; } // Sketch set up... size(500, 500); smooth(); background(#D8D4D4); noLoop(); cx = width/2; cy = height/2; sz = width*0.75; } // setup() void draw() { color[] colors = { color(#D6CDCD), color(#D30404), color(#D1A6A6), color(#D12828), color(#CE7070), color(#CE4D4D), color(#B9DCFF), color(#023467), color(#6395C9), color(#C9A663), color(#FFA703), color(#5F3F03) }; // Draw Pie Chart... float startAngle = 0; float stopAngle = 0; for (int i = 0; i < numBirthdays.length; i++) { float perc = float(numBirthdays[i])/N; startAngle = stopAngle; stopAngle = startAngle + perc * TWO_PI; fill(colors[i]); arc(cx, cy, sz, sz, startAngle, stopAngle); } } // draw()