Recitation 7 Documentation (Isaac Schlager)

For this recitation, we were tasked with coming up with our own creative project using Processing and had to use mouse and/or keyboard interaction. To do this I created a project that created circles as you drag your mouse across the screen. The circle sizes change depending on the location on the screen. You can also change the size of the circle randomly by pressing the mouse. Pressing “j” randomly changes the color and “f” clears the screen.

Recitation 7 Part 1 Trimmed

Code: 

void setup(){
size(500,500);
background(0);

}
void draw() {
line(pmouseX, pmouseY, mouseX, mouseY);
ellipse(pmouseX, pmouseY, mouseX, mouseY);
if (keyPressed){
if (key==’f’){
clear();}{
if(keyPressed){
if(key==’j’){
fill(random(0,255), random(0,255), random(0,255));}
}}}}

void mousePressed(){
//if(mouseX<=width/2, mouseY) {
//float size= random(30,50);
//fill(random(0,255), random(0,255), random(0,255));
//fill(255, random(100,255), random(130));
ellipse(mouseX, mouseY, random(width), random(height));}
//else{
//float size= random(1,10);
//fill(255,255,255);
//ellipse(mouseX, mouseY, random(width), random(height))

For the next set of activities we had to first create an ellipse at the center of the screen. I did this below…

Code: 

size(600,600);
ellipse(300,300, 300, 300);

Afterwards, we had to make the circle contract and expand on a specific interval. I was able to do this below as well.

Recitation Part 3

Code:

int size = 20;
int growthFactor = 5;

void setup(){
size(600,600);
//ellipse(300,300, 300, 300);
}

void draw(){
background(255);
ellipse(300,300,size,size);
size += growthFactor;

if(size > 300 || size < 20){
growthFactor *= -1;
}
}

For the next part, we had to make the expanding and contracting circle change colors gradually. I was able to do this below by using a growth factor to set the color to fill randomly at specific growth intervals.

Recitation 7 Part 4

Code:

int size = 20;
int growthFactor = 5;

void setup(){
size(600,600);
colorMode(HSB, 360, 100, 100);
}

void draw(){
background(255);
if(size%100==0){
fill(random(255), random(255), random(255));
}
//if {
ellipse(300,300,size,size);
size += growthFactor;
if(size > 300 || size < 20){
growthFactor *= -1;
}
}

For the last step, we were asked the circle to move around the screen according to how we pressed the arrow keys on our keyboards. The problem with this was that although I could introduce the new variables in my code to have the circle react to the pressing of these keys, my circle would not move across or around the screen. Therefore I was unable to complete the last step to this assignment.

Leave a Reply