Monthly Archives: July 2015

Animation

code from class

Echo’s Self-portrait

Hi All,

Here is my self-portrait. I constructed the basic shapes first, then used the mouse to draw the rest detail part.

Step1

Echo_Self-portraitStep1

 

Step2: Finished Version

Echo_self-portrait

 

Here is my code:

float lineWidth = 3;
PFont f;

void setup(){
size(600, 600);
background(161,209,193);
f = loadFont(“Avenir-Medium-48.vlw”);
noStroke();
fill(244, 211, 228);
rect(530, 0, 70, 70);
fill(0);
rect(530, 70, 70, 70);
fill(233, 61, 40);
rect(530, 140, 70, 70);
stroke(0);
fill(101,163,188); //circle_back
noStroke(); //circle_back
ellipse(245,210,200,200);//circle_back
fill(0); //hair_bottom
noStroke(); //hair_bottom
rect(185,175,120, 110);//hair_bottom
fill(244, 211, 228); //face
noStroke(); //face
ellipse(245,200,90,130); //face
fill(0); //hair_top
noStroke(); //hair_top
arc(245,175,120, 110, PI, TWO_PI);//hair_top
fill(0);
ellipse(220,200,40,40); //left glass
fill(0);
ellipse(270,200,40,40); //right glass
fill(244, 211, 228);
ellipse(220,200,30,30); //left glass
fill(244, 211, 228);
ellipse(270,200,30,30); //right glass
fill(244, 211, 228); //neck
noStroke(); //neck
rect(230,230,30,60); //neck
}

void draw(){
strokeWeight(lineWidth);
textFont(f,16);
fill(255);
text(“Hello! I’m Echo.”, 190, 340);
if (mousePressed){
line(mouseX, mouseY, pmouseX, pmouseY);
}
if(mousePressed && mouseX >= 530 && mouseY<= 70){
stroke(244, 211, 228);
}
if(mousePressed && mouseX >= 530 && mouseY<= 140 && mouseY >=70){
stroke(0);
}
if(mousePressed && mouseX >= 530 && mouseY>= 140){
stroke(233, 61, 40);
}
}

void keyPressed(){
if(key == ‘+’){
lineWidth++;
}
if (key == ‘-‘){
lineWidth–;
if (lineWidth <= 0){
lineWidth=1;
}
if(key == ‘ ‘){
background(161,209,193);
noStroke();
fill(220, 10, 180);
rect(700, 0, 100, 100);
fill(0,0,255);
rect(700, 100, 100, 100);
}
}
}

Self Portrait (With a Nice Soundtrack!)