วันอาทิตย์ที่ 23 สิงหาคม พ.ศ. 2558

Lab02 : Battery with signs

int dx=1;
int dy=1;
int x=70;
int y=110;
int wide=270,high=75;
void setup(){
  size(350,250);

}
void draw(){
  background(51);
  strokeWeight(4);
  stroke(0);
  draw_battery(x,y,wide,high);
  positive_sign(x+0.092*wide,y+0.2*high,5);
  negative_sign(x+0.8*wide,y+0.2*high,5);
  if (x+wide-20>width || x<0)
   dx*=-1;
  if (y+high-(0.2*high)>height || y-(0.2*high)<0)
   dy*=-1;
  
  x+=dx;
  y+=dy;
}


void draw_battery(int posX,int posY,int wide,int high){
  fill(255); //HEAD
  rect(posX,posY,wide/12,high*3/5);
 
  fill(#E5C81E); //Body Battery
  rect(posX+(wide/12),posY-(0.2*high),wide*5/6,high);
 
  //blue
  fill(#3531C1);
  rect(posX+(wide/6),posY,wide*0.75,0.6*high);
 
  //Line
  line(posX+(wide/6),posY-(0.2*high),posX+(wide/6),posY+(0.78*high));
 
  //Text
  fill(255);
  textSize(15);
  text("Panasonic",posX+0.22*wide,posY+0.4*high);
}

void positive_sign(float x,float y,int sizebox){
  noStroke();
  fill(255,0,0);
  rect(x+sizebox,y,sizebox,sizebox);
  rect(x+2*sizebox,y+sizebox,sizebox,sizebox);
  rect(x+sizebox,y+sizebox,sizebox,sizebox);
  rect(x+sizebox,y+2*sizebox,sizebox,sizebox);
  rect(x,y+sizebox,sizebox,sizebox);
 
}

void negative_sign(float x,float y,int sizebox){
  noStroke();
  fill(255,0,0);
  rect(x+2*sizebox,y+sizebox,sizebox,sizebox);
  rect(x+sizebox,y+sizebox,sizebox,sizebox);
  rect(x,y+sizebox,sizebox,sizebox);
}


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

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

commit เพิ่มเติม : เพื่ม userstory, bookmark

>>  add userstory ทำการเพิ่ม userstory ใน functional tests >>  add bookmark for user เพิ่มระบบ Bookmark โดยการสร้าง model ขึ...