วันจันทร์ที่ 24 สิงหาคม พ.ศ. 2558

Lab 2 Battery (moving)

int space=75;
int move =0;
void setup(){
size(500,500);
}
void draw(){
background(0,0,0);
strokeWeight(5);
stroke(255,255,255);
rect(150+move,80,200,380);//ตัวแบตเตอร์รีี่
rect(190+move,20,40,60);//ขั้วแบต
rect(270+move,20,40,60);//ขั้วแบต
fill(0,255,0);


rect(152+move,85,195,70);//ขีดแบตก่อนที่1


rect(152+move,85+space,195,70);//ขีดแบตก่อนที่2


rect(152+move,85+space*2,195,70);//ขีดแบตก่อนที่3


rect(152+move,85+space*3,195,70);//ขีดแบตก่อนที่4


rect(152+move,85+space*4,195,70);//ขีดแบตก่อนที่5
fill(255,255,255);
textSize(20);
text("Battery",225+move,485);//word " Battery "

fill(255,0,0);
textSize(30);
text("100%",270+move,130);// 100 %

fill(255,0,0);
textSize(30);
text("80%",285+move,130+space);// 80%

fill(255,0,0);
textSize(30);
text("40%",285+move,130+space*2);//40 %

fill(255,0,0);
textSize(30);
text("20%",285+move,130+space*3);//20 %
fill(255,0,0);
textSize(30);
text("0%",285+move,130+space*4);// 0 %
move++;
if(move > 500){
move = -192;
}
}

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

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