วันพุธที่ 3 กันยายน พ.ศ. 2557

Lab2 : bicycle


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

draw_tire(100,300,100,100);
draw_spoke(55,300,145,300);
draw_lockring(95, 305);
draw_quadCLC(105,300,190,310,190,290,105,295);
draw_lineCLC(105,295,160,300);
draw_chainRings(180,300,20,20);
draw_seatTube(180, 290);
draw_CLS(100, 295);
draw_hub(270,300,10,10);
draw_frontFock(270, 300);
draw_mainFrame(253, 240);
draw_topTube(253, 230);
draw_seat(200, 245);
draw_hand(255,200,15,5,3);
}


void draw_tire(int x,int y,int width,int height){
  fill(0);
  ellipse(x,y,width,height);  // tire

  fill(133,210,255);
  ellipse(x,y,width-10,height-10);  //tire

  fill(0);
  ellipse(x+170,y,width,height);  //tire

  fill(133,210,255);
  ellipse(x+170,y,width-10,height-10);  //tire
}

void draw_spoke(int x1,int y1,int x2,int y2){

  line(x1,y1,x2,y2);  //spoke
  line(x1+45,y1-45,x2-45,y2+45);  //spoke
  line(x1+215,y1-45,x2+125,y2+45);  //spoke
  line(x1+170,y1,x2+175,y2);  //spoke
}

void draw_lockring(int x,int y){
  fill(192,192,192);
  beginShape();
  vertex(x,y);
  vertex(x+10,y);
  vertex(x+10,y-10);
  vertex(x+5,y-10);
  vertex(x,y-5);
  endShape(CLOSE);  //lockring
}

void draw_quadCLC(int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4){

  fill(255,255,204);
  quad(x1,y1,x2,y2,x3,y3,x4,y4);  // connecting lockring and chain rings(CLC)
}

void draw_lineCLC(int x1,int y1,int x2,int y2){

  line(x1,y1,x2,y2);  // connecting lockring and chain rings(CLC)
  line(x1+55,y1+5,x2+10,y2+5);  // connecting lockring and chain rings(CLC)
}

void draw_chainRings(int x,int y,int width,int height){
 
  fill(192,192,192);
  ellipse(x,y,width,height);  // chain rings
  fill(133,210,255);
  ellipse(x,y,width-15,height-15);  // chain rings

 
}

void draw_seatTube(int x,int y){

  fill(255,255,204);
  beginShape();
  vertex(x,y);
  vertex(x-5,y);
  vertex(x-10,y-50);
  vertex(x-5,y-50);
  endShape(CLOSE);  //seat tube
}

void draw_CLS(int x,int y){

  fill(255,255,204);
  beginShape();
  vertex(x,y);
  vertex(x+5,y);
  vertex(x+75,y-45);
  vertex(x+70,y-45);
  endShape(CLOSE);  // connecting lockring and seat post(CLS)
}

void draw_hub(int x,int y,int width,int height){

  fill(192,192,192);
  ellipse(x,y,width,height);  // hub
}

void draw_frontFock(int x,int y){

  fill(255,255,204);
  beginShape();
  vertex(x,y);
  vertex(x-15,y-30);
  vertex(x-20,y-100);
  vertex(x-15,y-100);
  vertex(x-10,y-30);
  vertex(x+5,y-5);
  endShape(CLOSE);  //front fock
}

void draw_mainFrame(int x,int y){

  fill(255,255,204);
  beginShape();
  vertex(x,y);
  vertex(x,y-5);
  vertex(x-66,y+50);
  vertex(x-63,y+55);
  endShape(CLOSE);  //main frame
}

void draw_topTube(int x,int y){

  beginShape();
  vertex(x,y);
  vertex(x,y-5);
  vertex(178, 265);
  vertex(178, 270);
  endShape(CLOSE);  //top tube
  }
 
void draw_seat(int x,int y){

  fill(153,76,0);
  beginShape();
  vertex(x,y);
  vertex(x, y-5);
  vertex(x-35,y-20);
  vertex(x-50,y-10);
  vertex(x-35,y+5);
  endShape(CLOSE);  //seat
}

void draw_hand(int x,int y,int width,int height,int radius){

  fill(102,71,0);
  rect(x,y,width,height,radius);  //hand



}

ไม่มีความคิดเห็น:

แสดงความคิดเห็น