In lab3, I was really frustrated with processing. Drawing with vertex is hard for me at the beginning. However, I get to known that it’s a good way to draw and test at the same time so it’s not so hard to do that now!

I drew an Issac hahah

here’s the code

int x,y;

void setup(){

size(640,480);

x=0;

y=0;

background(105,71,61);

}

void draw(){

//body

strokeWeight(10);

fill(197,158,155);

beginShape();

vertex(293,198); //zuoshang

vertex(350,198);//youshang

vertex(360,250);//you1

vertex(360,270);//you2

vertex(357,290);//youxia

vertex(340,290);

vertex(340,270);

vertex(305,270);

vertex(305,290);

vertex(288,290);//zuoxia

vertex(283,270);//zuo2

vertex(283,250);//zuo1

endShape();

//arms

beginShape();

vertex(350,198);

vertex(375,230);

vertex(365,247);

vertex(360,240);

endShape();

beginShape();

vertex(293,198);

vertex(270,230);

vertex(280,247);

vertex(283,240);

endShape();

//head

smooth();

strokeWeight(10);

fill(197,158,155);

ellipse(width/2,120,150,150);

//eyeblack

fill(0);

ellipse(280+(sin(x)*3),126,35,35);

ellipse(362+(sin(x)*3),126,35,35);

x++;

//light in his eye

fill(225);

noStroke();

ellipse(276+(sin(x)*3),120,14,14);

ellipse(358+(sin(x)*3),120,14,14);

x++;

//mouth

fill(0);

beginShape();

vertex(307,137); //shangzuo

vertex(332,137); //shangyou

vertex(338,143); //youzhong

vertex(338,155); //youxia

vertex(301,155); //zuoxia

vertex(301,143); //zuozhong

endShape();

//teeth

noStroke();

fill(225);

rect(305,145,28,5); //zuoshangdian,chang,gao

//tears

noStroke();

fill(156,200,204);

beginShape();//left

vertex(268,138);//tearzuoshang

vertex(293,138);//youshang

vertex(293,191);//youzhong

vertex(268,173);//

endShape();

fill(156,200,204);//reght

beginShape();

vertex(350,138);//tearzuoshang

vertex(376,138);//youshang

vertex(376,173);//youzhong

vertex(350,191);//

endShape();

}

(I lest some comments in Pinyin)

In lab4, I did a bouncing ball

Here’s the code

int x=0;

int speed =4;

void setup(){

size(300,300);

smooth();

}

void draw(){

background(255, mouseX+100 ,mouseX+100);//color changes with mouse

move();

bounce();

display();

}

void move(){

x=x+speed;

}

void bounce(){

if ((x>width)||(x<0)){

speed=speed*-1;

}

}

void display(){

int d=0;//trail of the ball

for(int c=225;c>0; c-=7){

fill(c);

noStroke();

rect(d,height/2,7,7);

d=d+15;

noStroke();//ball

if (speed>0){

fill(175,43,39);

}else{

fill(59,84,89);

}

ellipse(x,150,80,80);

}

}