Author Archive

Variable Expressions

Screenshot (15) Screenshot (14) Screenshot (9) Screenshot (8) Screenshot (7) Screenshot (6) Screenshot (5) Screenshot (4) Screenshot (3)

//create variables we will want to change
float faceW; //variable for face width
float faceH; //variable for face height

float eye1X; //variable for eye 1 X position
float eye2X; //variable for eye 2 Y position

float mouth1X; //variable for eye 1 X position
float mouth2X; //variable for eye 2 Y position

void setup() {
size(400, 400);
//intial values for variables
faceW=300;
faceH=300;

eye1X= width/2 – 50; // 50 pixels left of the middle of the screen
eye2X= width/2 + 50; // 50 pixels right of the middle of the screen

mouth1X=150; //variable for mouth left X position
mouth2X=250; //variable for mouth right Y position.
}

void draw() {
background(255, 0, 100); //refresh background each time
//face
fill(0, 170, 100);
ellipse(200, 200, faceW, faceH);
//
//eyes

noStroke();
fill(255);
ellipse(eye1X, 200, 70, 70); //left eye middle
ellipse(eye2X, 200, 70, 70); //right eye middle

//mouth
curve(100, 0, mouth1X, 250, mouth2X, 250, 300, 0); //see https://processing.org/reference/curve_.html
//then if the mouse is clicked
if (mousePressed) {
//generate new values for our variables
faceW=random(100, 400); //new random width within the range of 280-320
faceH=random(100, 400); //new random height

eye1X= width/2 – random(20, 80); // locate eye1 at a random value between 40-60 pixels left of the middle of the screen
eye2X= width/2 + random(20, 80); // locate eye1 at a random value between 40-60 pixels right of the middle of the screen

mouth1X=random(100, 180); //variable for eye 1 X position
mouth2X=random(230, 300); //variable for eye 2 Y position
}
}

Processing Portrait

Screenshot (19)

void setup() {
size(400, 400);
background(255);

//ears
fill(255,0,0);
noStroke();
ellipse(50,200,20,70);
ellipse(350,200,20,70);

//rectMode(CENTER);
fill(0,255,0);
rect(50,200,20,-120);
rect(330,200,20,-120);
}
void draw() {
fill(255, 0, 0);
ellipse(100, 200, 80, 120); // left eye
ellipse(300, 200, 80, 120); // right eye

//face
//noFill();
fill(0,170,100);
ellipse(200, 200, 300, 300);

//eyes
noStroke();
fill(255);
ellipse(100, 200, 70, 70); //left eye middle
ellipse(300,200,70,70); //right eye middle

stroke(0);
fill(89,164,180);
ellipse(200,260,20,7); //nose

//mouth
strokeWeight(4);
line(160,300,240,300);

//hat
rectMode(CENTER);
//rect(200,100,40,40);
rect(200,40,80,30);
rect(200,60,100,10);
}

'+
1
'+
2 - 3
4 - 5
6 - 7
8 - 9
10 - 11
12 - 13
13 - 14
[x]