Documentation 7 – Yixuan Liu ( Recitation Instructor Younghyun Chung, Eric Parren)

In this recitation, I add more code to the picture that I drew last week to make it more interactive. My design is that the four rectangles will change color randomly, and the colors they can have are already limited so that the design of the picture will not be so irrelevant. When people press the mouse, all four rectangles start changing color, and when you see the combination that you like, you just press the mouse again and it stops. I make this code so that I can see more possible combinations within a certain amount of colors and get unexpected results.

Recitation 7(Video Clip)

Here is my code.

color a = color(210, 170, 78);
color b = color(146, 143, 137);
color c = color(66, 125, 129);
color d = color(58, 112, 67);
color e = color(68, 119, 89);

color[] myColors = {a, b, c, d, e};

void setup() {
size(500, 500);
background(225);
frameRate(5);
//int colorPicker = int(random(0, 5));
// fill(myColors[colorPicker]);
}

int value = 0;
boolean changing = true;
boolean previous = true;
int colorPicker = int(random(0, 5));

void draw() {
if (changing) {
for (int l = 500; l>=130; l-= 100) {

colorPicker = int(random(0, 5));
fill(myColors[colorPicker]);
noStroke();

rect(250-l/2, 250-l/2, l, l);
}
}
}

void mousePressed() {
if (mousePressed == true) {
if (previous == true){
changing = false;
previous = false;
} else if(previous == false){
changing = true;
previous = true;
}
}
}

Here is my homework, both video and code.

Homework(Video Clip)

Code:

void setup() {
size(700, 700);
background(0);
colorMode(HSB, 100);
strokeWeight(25);
}

int y = 350;
int x = 350;
int d;
int steps = 3;
int a;
int step = 1;

void draw() {
background(100);
circle(x, y, d);
stroke (a, 100, 100);
d = d+steps;
if (d>250 || d<0) {
steps= -steps;
}
a = a + step;
if (a>100 || a<0) {
step = -step;
}
if (keyPressed == true) {
if (keyCode == DOWN) {
if (y<height){
y=y+1;}
} else if (keyCode == UP) {
if (y>0){
y-=1;}
} else if (keyCode == RIGHT) {
if (x<width){
x+=1;}
} else if (keyCode == LEFT) {
if (x>0){
x-=1;}
}
}
}

From this week’s recitation, I learn how to use colorPicker and also practice more of using mousePressed code. I think these two functions are really important because, for colorPicker, it provides with a way that I can limit my data into a certain rage. By doing this, I can have better control of the results that come out of the Processing. For the mousePressed function, it is able to connect the machine with people’s action, and I believe that this function will be used often in the future for acquiring an intermedia engagement between the machine and individuals. 

For the homework, I practice more about the functions of keyboard interaction as well as combining them with other elements. I think this is the third function that I prefer to use in the future study process.

Leave a Reply