i think i really got it this time, nature of code in

This commit is contained in:
shiffman
2012-09-04 01:47:20 +00:00
parent b5b67a12b5
commit 1d86e1f5bf
541 changed files with 35009 additions and 0 deletions
@@ -0,0 +1,26 @@
// An array to keep track of how often random numbers are picked
float[] randomCounts;
void setup() {
size(800,200);
randomCounts = new float[20];
}
void draw() {
background(255);
// Pick a random number and increase the count
int index = int(random(randomCounts.length));
randomCounts[index]++;
// Draw a rectangle to graph results
stroke(0);
strokeWeight(2);
fill(127);
int w = width/randomCounts.length;
for (int x = 0; x < randomCounts.length; x++) {
rect(x*w,height-randomCounts[x],w-1,randomCounts[x]);
}
}