For this exercise I changed some parameters in the for() loop building upon the code we started writing during class. I wanted to experiment more with color and random(). Here, the color of the background is changed on mouse click while the larger ellipses and rectangles change colors randomly. To me, the outcome looks like a whirlwind of confetti. Accidentally, the screen recording captured a song of the RealAD show which I was listening to in the background. This started a new idea for creating a Processing artwork that reacts to sound but this will have to wait until I learn more about Processing and how it can react to different input.
int x = 0; int ellWidth = 100; int rectWidth = 20; color backColor = color(255, 255, 255); // taken from https://forum.processing.org/one/topic/how-can-i-change-background-color-with-mouse-click.html void setup() { size(640, 640); rectMode(CENTER); ellipseMode(CENTER); } void draw () { background(backColor); for (int x = 0; x<width; x+=ellWidth) { float center = height*0.5; float amplitude = TWO_PI; float speed = 0.01; float granular = 0.01; float freq = (frameCount*speed) + (x * granular); float angle = noise(freq); angle *= amplitude; pushMatrix(); translate(x + ellWidth/2, center); rotate(angle); rotate( map(mouseX, 0, width, 0, TWO_PI)); noStroke(); fill(random(255), random(255), random(255)); ellipse(width/4, height/4, ellWidth, ellWidth); popMatrix(); } for (int x = 0; x<width; x+=rectWidth) { float center = height; float amplitude = TWO_PI; float speed = 0.01; float granular = .001; float freq = (frameCount*speed*2) + (x * granular); float angle = noise(freq); angle *= amplitude; translate(x + rectWidth/2, center); rotate(angle); rotate( map(mouseX, 0, width, 0, TWO_PI)); noStroke(); fill( random(255), random(255), random(255)); rect(0, 0, rectWidth, 100); } for (int x = 0; x<width; x+=rectWidth) { float center = height; float amplitude = TWO_PI; float speed = 2; float granular = .001; float freq = (frameCount*speed*2) + (x * granular); float angle = noise(freq); angle *= amplitude; translate(x + 20/2, center); rotate(angle); rotate( map(mouseX, 0, width, 0, TWO_PI)); noStroke(); fill( random(255), random(255), random(255)); rect(0, 0, rectWidth, 100); fill(0); ellipse(width/2, height/2, 20, 20); } } void mousePressed() { backColor = color(random(255), random(255), random(255)); }