def binary():
n=18
c=0
b=""
s=""
while(n>0):
b=n%2
c=n%2
if(b==1):
b="1"
elif(b==0):
b="0"
s=b+s
n=(n-c)/2
return s
binary()
print(binary())
วันจันทร์ที่ 28 กันยายน พ.ศ. 2558
วันอาทิตย์ที่ 20 กันยายน พ.ศ. 2558
HELLO PYTHON
###################### BMI ##########################1
ef displayBMI():
weight=84
height=184
bmi=cal(weight,height)
print(bmi)
def cal(w,h):
bmi=0
h=h/100
bmi=w/(h*h)
return bmi
displayBMI()
######################## Area and Circum #########################2
def display():
diameter = 10
circum=calCircum(diameter)
area=calArea(diameter)
print("Circumference is ",circum)
print("Area is ",area)
def calCircum(d):
c=0
c=(22/7)*d
return c
def calArea(d):
r=0
a=0
r=d/2
a=(22/7)*(r*r)
return a
display()
##################### power_of_ten ########################3
def display():
value=12;
power=power_of_ten(value)
print("10 ^",value," is ",power)
def power_of_ten(v):#v is value
if(v==6):
s="Million"
return s
elif(v==9):
s="Billion"
return s
elif(v==12):
s="Trillion"
return s
elif(v==15):
s="Quadrillion"
return s
elif(v==18):
s="Quintillion"
return s
elif(v==21):
s="Sextillion"
return s
elif(v==30):
s="Nonillion"
return s
elif(v==100):
s="Googol"
return s
display()
#################### Grade ############################4
def display():
value=50;
grade=cal_grade(value)
print("grade is ",grade)
def cal_grade(v):#v is value
if(v>=80):
s="A"
return s
elif(v>=70):
s="B"
return s
elif(v>=60):
s="C"
return s
elif(v>=50):
s="D"
return s
else:
s="F"
return s
display()
#####################################################5
###########main############
def display_leapyear():
year=1600
leapYear=cal_leapYear(year)
print(year," is ",leapYear)
###########main############
def cal_leapYear(year):
value=0
value=year%400
if(value==0):
s="leap year"
return s
else:
value=year%100
if(value==0):
s="don't leap year"
return s
else:
value=year%4
if(value==0):
s="leap year"
return s
else:
s="don't leap year"
return s
display_leapyear()
############### multiplication_table ################6
def display():
multiplication_table=table(3)
def table(num):
count=1
while(count<=12):
print(num," * ",count," = ",num*count)
count=count+1
####################################################
display()
#################### Sum of number #######################7
def displaySum():
sum=cal_sum(50)
print(sum)
def cal_sum(n):
sum1=0
count=0
while(count<n):
count=count+1
sum1=sum1+count
return sum1
################################
displaySum()
#################### PrimeOfNum ###################8
def displayPrimeOfNum():
prime=cal_prime(20)#(n)
def cal_prime(n):
count=1
while(count<n):
count=count+1
if(prime1(count) == "true"):
print(count," ")
def prime1(count):
count1=2
while(count1<count):
if(count%count1==0):
x="false"
return x
count1=count1+1
x="true"
return x
x="true"
return x
#######################################
displayPrimeOfNum()
#################### Loan_payment ######################9
def display():
interest_rate = 12
loan_month = 5000
total_of_payments = 12
calJ = cal_j(interest_rate,total_of_payments)
cal_1 = cals1(calJ,total_of_payments)
calM = cals2(calJ,cal_1)
payment = calM*loan_month
begin_ba=loan_month
displayMain(begin_ba,calJ,payment,total_of_payments)
def cal_j(interest_rate,total_of_payments):
j = 0;
j = (interest_rate/100)/total_of_payments
return j
def cals1(calJ,total_of_payments):
cals01=0
cals01 = pow((1+calJ),-total_of_payments)
return cals01
def cals2(calJ,cal_1):
cals02=0
cals02=calJ/(1-cal_1)
return cals02
def displayMain(begin_ba,calJ,payment,total_of_payments):
print("No. Beginning Balance interest principal Ending balance")
count=1
while(count<=total_of_payments):
interest = calJ*begin_ba
pricipal = payment-interest
End_ba = begin_ba-pricipal
print(count," ",begin_ba," ",interest," ",pricipal," ",End_ba," ")
begin_ba = End_ba
count=count+1
display()
ef displayBMI():
weight=84
height=184
bmi=cal(weight,height)
print(bmi)
def cal(w,h):
bmi=0
h=h/100
bmi=w/(h*h)
return bmi
displayBMI()
######################## Area and Circum #########################2
def display():
diameter = 10
circum=calCircum(diameter)
area=calArea(diameter)
print("Circumference is ",circum)
print("Area is ",area)
def calCircum(d):
c=0
c=(22/7)*d
return c
def calArea(d):
r=0
a=0
r=d/2
a=(22/7)*(r*r)
return a
display()
##################### power_of_ten ########################3
def display():
value=12;
power=power_of_ten(value)
print("10 ^",value," is ",power)
def power_of_ten(v):#v is value
if(v==6):
s="Million"
return s
elif(v==9):
s="Billion"
return s
elif(v==12):
s="Trillion"
return s
elif(v==15):
s="Quadrillion"
return s
elif(v==18):
s="Quintillion"
return s
elif(v==21):
s="Sextillion"
return s
elif(v==30):
s="Nonillion"
return s
elif(v==100):
s="Googol"
return s
display()
#################### Grade ############################4
def display():
value=50;
grade=cal_grade(value)
print("grade is ",grade)
def cal_grade(v):#v is value
if(v>=80):
s="A"
return s
elif(v>=70):
s="B"
return s
elif(v>=60):
s="C"
return s
elif(v>=50):
s="D"
return s
else:
s="F"
return s
display()
#####################################################5
###########main############
def display_leapyear():
year=1600
leapYear=cal_leapYear(year)
print(year," is ",leapYear)
###########main############
def cal_leapYear(year):
value=0
value=year%400
if(value==0):
s="leap year"
return s
else:
value=year%100
if(value==0):
s="don't leap year"
return s
else:
value=year%4
if(value==0):
s="leap year"
return s
else:
s="don't leap year"
return s
display_leapyear()
############### multiplication_table ################6
def display():
multiplication_table=table(3)
def table(num):
count=1
while(count<=12):
print(num," * ",count," = ",num*count)
count=count+1
####################################################
display()
#################### Sum of number #######################7
def displaySum():
sum=cal_sum(50)
print(sum)
def cal_sum(n):
sum1=0
count=0
while(count<n):
count=count+1
sum1=sum1+count
return sum1
################################
displaySum()
#################### PrimeOfNum ###################8
def displayPrimeOfNum():
prime=cal_prime(20)#(n)
def cal_prime(n):
count=1
while(count<n):
count=count+1
if(prime1(count) == "true"):
print(count," ")
def prime1(count):
count1=2
while(count1<count):
if(count%count1==0):
x="false"
return x
count1=count1+1
x="true"
return x
x="true"
return x
#######################################
displayPrimeOfNum()
#################### Loan_payment ######################9
def display():
interest_rate = 12
loan_month = 5000
total_of_payments = 12
calJ = cal_j(interest_rate,total_of_payments)
cal_1 = cals1(calJ,total_of_payments)
calM = cals2(calJ,cal_1)
payment = calM*loan_month
begin_ba=loan_month
displayMain(begin_ba,calJ,payment,total_of_payments)
def cal_j(interest_rate,total_of_payments):
j = 0;
j = (interest_rate/100)/total_of_payments
return j
def cals1(calJ,total_of_payments):
cals01=0
cals01 = pow((1+calJ),-total_of_payments)
return cals01
def cals2(calJ,cal_1):
cals02=0
cals02=calJ/(1-cal_1)
return cals02
def displayMain(begin_ba,calJ,payment,total_of_payments):
print("No. Beginning Balance interest principal Ending balance")
count=1
while(count<=total_of_payments):
interest = calJ*begin_ba
pricipal = payment-interest
End_ba = begin_ba-pricipal
print(count," ",begin_ba," ",interest," ",pricipal," ",End_ba," ")
begin_ba = End_ba
count=count+1
display()
book_lab4
int moveY;
int cout;
void setup(){
size(1100,700);
}
void draw(){
int count=0;
int n=2;
int pos=0;
while(count<n){
book(pos);
pos=pos+550;
count++;
// fill(#000000);
// rect(10,50,50,50);
}
//book();
if(cout < 20){
moveY++;
cout++;
}else if(cout > 0){
moveY--;
if(moveY == -20){
cout=-20;
}
}
println(moveY);
print("..................");
println(cout);
}
void book(int pos){
int posy=50;
//moveY=(moveY+1)%(100);
fill(#D8BABA);
rect(pos+0, 0, 549, 699);
fill(#FFFFFF);
rect(pos+0, 0, 55, 699);
textSize(40);
fill(#000000);
text("1",pos+15,50);
textSize(20);
text("45B",pos+8,660);
fill(#FF9966);
rect(pos+60, 5, 485, 450);
//////////////////Body/////////////////
fill(#000000);
strokeWeight(4);
ellipse(pos+300, posy+250-moveY, 240, 250);//face back
fill(#FFFFFF);
rect(pos+165, posy+251-moveY, 30, 40);//left ear
rect(pos+405, posy+251-moveY, 30, 40);//right ear
ellipse(pos+300, posy+254-moveY, 238, 245);
fill(#FDFF40);//face front
ellipse(pos+360, posy+245-moveY, 70, 80);//right eye
ellipse(pos+240, posy+245-moveY, 70, 80);//left eye
strokeWeight(2);
fill(#000000);
triangle(pos+300, posy+275-moveY, pos+285,posy+100-moveY, pos+315, posy+100-moveY); //crest
textSize(70);
fill(#000000);
text("The",pos+100,530);
textSize(60);
text("Ultraman",pos+250,530);
textSize(40);
text("Original",pos+380,580);
/*
println("My faverite book is ");
println ("ultranma");
println(-moveY);*/
}
movie_lab4
int resize;
int move;
int cout;
void setup(){
size(600, 600);
}
void draw(){
background(#778899);
int count=1;
int n=4;
int pos=0;
while(count<=n){
fill (#ADABBC);
textSize(50);
text("Joker",pos-20,50);
text("Joker",pos+40,150);
text("Joker",pos-20,250);
text("Joker",pos+40,350);
text("Joker",pos-20,450);
text("Joker",pos+40,550);
pos=pos+180;
count++;
}
movie(400);
if (cout < 30){
move++;
cout++;
}else if(cout > 0){
move--;
if(move==0){
cout =0;}
}
println(move);
println("..................");
println(cout);
}
void movie(int x){
int posx=50;
resize=(resize+1)%20;
fill(#FAEBD7);
stroke(#000000);
strokeWeight(5);
ellipse(300, 300, 300, 400); //face
stroke(#000000);
strokeWeight(5);
line(300, 98, 300, 50); //hair 1
line(295, 98, 280, 60); //hair 2
line(305, 98, 320, 60); //hair 3
//Nose
fill(#CC0000);
strokeWeight(5);
ellipse(x, 350, 70+resize, 65+resize); //nose
fill(#FF0000);
stroke(#FF0000);
strokeWeight(1);
ellipse(x, 350, 59+resize, 55+resize); //nose red
fill(#FF4500);
stroke(#FF4500);
strokeWeight(1);
ellipse(x, 350, 48+resize, 45+resize); //nose orange
fill(#FFA500);
stroke(#FFA500);
strokeWeight(1);
ellipse(x, 350, 37+resize, 35+resize); //nose yellow
fill(#000000);
stroke(#000000);
quad(posx+210, 250, posx+230, 200, posx+250, 250, posx+230, 300); //left tatto
fill(#F8F8FF);
strokeWeight(2);
ellipse(posx+230, 250, 80+resize, 30+resize); //left eye
ellipse(posx+370, 250, 80+resize, 30+resize); //right eye
fill(#CC0000);
stroke(#CC0000);
strokeWeight(1);
ellipse(posx+230+move, 250, 10+resize, 26+resize); //left small eye
ellipse(posx+370+move, 250, 10+resize, 26+resize); //right small eye
fill(#FF0000);
stroke(#FF0000);
strokeWeight(1);
ellipse(posx+230+move, 250, 2+resize, 2+resize); //left very small eye
ellipse(posx+370+move, 250, 2+resize, 2+resize); //right very small eye
println("My Movie is Batman");
println("This is JOKER");
println(resize);
}
music_lab4
int moveX;
int moveY;
void setup(){
size(500,550);
}
void draw(){
int count=0;
int n=3;
int pos=0;
background(#F5F5F5);
while(count<n){
fill (#FFDEDE);
textSize(60);
text("Girl's",pos+50,80);
text("Girl's",pos-50,160);
text("Girl's",pos+50,240);
text("Girl's",pos-50,320);
text("Girl's",pos+50,400);
text("Girl's",pos-50,480);
text("Girl's",pos+50,560);
pos+=220;
count++;
}
music(pos);
}
void music(int pos){
int posx=25;
int posy=7;
moveX=(moveX+1)%4;
moveY=(moveY+1)%4;
//rect(0, 0, 499, 549);
//left heart
stroke(#000000);
strokeWeight(10);
line(246-posx+moveX, 85-posy, 190-posx+moveX, 15-posy); //1
line(190-posx+moveX, 15-posy, 90-posx+moveX, 130-posy); //2
line(90-posx+moveX, 130-posy, 246-posx+moveX, 321-posy); //3
line(246-posx+moveX, 321-posy, 246-posx+moveX, 150-posy); //4
line(246-posx+moveX, 150-posy, 155-posx+moveX, 150-posy); //5
stroke(#F23383);
strokeWeight(7.5);
line(246, 85+moveY, 190, 15+moveY); //1
line(190, 15+moveY, 90, 130+moveY); //2
line(90, 130+moveY, 246, 321+moveY); //3
line(246, 321+moveY, 246, 150+moveY); //4
line(246, 150+moveY, 155, 150+moveY); //5
//right heart
stroke(#000000);
strokeWeight(10);
line(262+posx+moveX, 85-posy,318+posx+moveX, 15-posy); //1
line(318+posx+moveX, 15-posy, 418+posx+moveX, 130-posy); //2
line(418+posx+moveX, 130-posy, 262+posx+moveX, 321-posy); //3
line(262+posx+moveX, 321-posy, 262+posx+moveX, 150-posy); //4
line(262+posx+moveX, 150-posy, 353+posx+moveX, 150-posy); //5
stroke(#F23383);
strokeWeight(7.5);
line(262, 85+moveY,318, 15+moveY); //1
line(318, 15+moveY, 418, 130+moveY); //2
line(418, 130+moveY, 262, 321+moveY); //3
line(262, 321+moveY, 262, 150+moveY); //4
line(262, 150+moveY, 353, 150+moveY); //5
//Heart WAVE
strokeWeight(1);
line(150, 370+moveY, 185, 370+moveY);
line(185, 370+moveY, 202, 344+moveY);
line(202, 345+moveY, 202, 370+moveY);
line(202, 370+moveY, 217, 344+moveY);
line(217, 345+moveY, 217, 385+moveY);
line(217, 385+moveY, 234, 357+moveY);
line(234, 357+moveY, 244, 357+moveY);
line(244, 357+moveY, 244, 370+moveY);
line(244, 370+moveY, 259, 370+moveY);
line(259, 370+moveY, 276, 344+moveY);
line(276, 344+moveY, 276, 370+moveY);
line(276, 370+moveY, 292, 344+moveY);
line(292, 344+moveY, 292, 384+moveY);
line(292, 384+moveY, 309, 357+moveY);
line(309, 357+moveY, 319, 357+moveY);
line(319, 357+moveY, 319, 370+moveY);
line(319, 370+moveY, 354, 370+moveY);
fill(#F23383);
ellipse(354, 370+moveY, 3, 3);
if(mousePressed == true){
textSize(90);
fill(#000000);
text("G",130+moveX,478+moveY);
}
else{
textSize(90);
fill(#F23383);
text("G",130+moveX,478+moveY);
}
if (keyPressed == false){
fill(#FFA5CB);
textSize(40);
text("irls",191,445);
textSize(40);
text("eneration",189,478);
}
else{
fill(#ED0707);
textSize(40);
text("irls",191,445);
textSize(40);
text("eneration",189,478);
}
fill(#FFFFFF);
println("My faverite Music is ");
println ("Girlsgeneration");
println(moveX);
}
loan_payment_lab4
void setup() {
size();
////////// INPUT /////////////
float interest_rate = 12;
float loan_month = 5000 ;
float total_of_payments = 12;
///////// PROCESS ///////////
int count=1;
float calJ;
float cal_1;
float calM;
float total_in;
//float cal_inter;
calJ = cal_j(interest_rate,total_of_payments);
cal_1 = cals1(calJ,total_of_payments);
calM = cals2(calJ,cal_1);
println("cal2 "+calJ);
float payment = calM*loan_month;
//println("calpayment "+(payment);
///////////////////////Display////////////////////////
println("No. Beginning Balance interest principal Ending balance");
float begin_ba=loan_month;
float interest;
float pricipal;
float End_ba;
while(count<=total_of_payments){
interest = calJ*begin_ba;
pricipal = payment-interest;
End_ba = begin_ba-pricipal;
println(count+" "+begin_ba+" "+interest+" "+pricipal+" "+End_ba+" ");
begin_ba = End_ba ;
count++;
}
///////////////////////Display////////////////////////
}
float cal_j(float interest_rate,float total_of_payments){
float j = 0;
j = (interest_rate/100)/total_of_payments;
return j;
}
float cals1(float calJ,float total_of_payments){
float cals01;
cals01 = pow((1+calJ),-total_of_payments);
return cals01;
}
float cals2(float calJ,float cal_1){
float cals02;
cals02=calJ/(1-cal_1);
return cals02 ;
}
วันเสาร์ที่ 19 กันยายน พ.ศ. 2558
bird_lab4
int movey=0;
float movex=0;
int count=0;
void setup() {
size(600, 600);
}
void draw() {
background(255-mouseY);
////////////////////////While////////////////////////
int count1=0;
int n=2;
int posx=0;
while (count1<n){
bird(posx+mouseX, mouseY, 30, 30);
bird(mouseX, mouseY-posx, 30, 30);
bird(mouseX, mouseY+posx, 30, 30);
bird(mouseX-posx, mouseY, 30, 30);
posx=posx+100;
count1++;
println(posx);
}
////////////////////////While////////////////////////
println("count"+count);
println("moveY"+movey);
println("moveX"+movex);
}
void bird(int x, int y, int w, int h) {
//w= width
//h= hight
if(count<120){
movey++;
count++;
}
else if(count>=0){
movey--;
if(movey==0){
count=0;
}
}
strokeWeight(5);
fill(#FFFFFF);
line(x+15, y, x+80-movex, y+60-movey);//right
line(x-15, y, x-80, y+60-movey); //left
ellipse(x, y, w, h);
fill(#F21616);
strokeWeight(1);
ellipse(x+7, y, w-22, h-15);//left eye
ellipse(x-7, y, w-22, h-15);//right eye
fill(#E08B22);
triangle(x-6,y+9,x+6,y+9,x,y+18);//mouth
}
วันอาทิตย์ที่ 13 กันยายน พ.ศ. 2558
prime_fo_num_lab4
void setup(){
sum_of_integers(100);
}
void sum_of_integers(int n){
int sum=0;
int count=0;
while(count<n){
count++;
sum=sum+count;
}
println("Sum is "+sum);
}
prime_of_number_lab4
void setup(){
int n=150;//1 to n=N
prime_of_num(n);
}
void prime_of_num(int n){
int count1=1;
while(count1<n){
count1++;
if(prime(count1)== true){
print(count1+" ");
}
}
}
boolean prime(int n){
int count=2;
while(count<n){
if(n%count==0){
return false;
}
count++;
}
return true;
}
multiplication_table_lab4
void setup(){
multiplication_table(2);
}
void multiplication_table(int num){
int count=0;
while(count<12){
count++;
println(num+" * "+count+" = "+num*count);
}
}
balloon_lab4
void setup(){
size(500, 500);
}
void draw(){
background(#FFFFFF);
int y=mouseY;
if(y>400){
fill(#04D605);//green
background(#7C7C7C);//gray
}
else if(y<100){
fill(#EDE202);//yellow
background(#E517E5);//pink
}
else{
fill(#ED1A1A);//red
background(#3C17E5);//blue
}
draw_balloon(width/2,y,2);
}
void draw_balloon(int x,int y,int n){
int r=100;
int string_length=200;
int count=1,count1=0;
//int n=2;
int l=(r/2)+20;
int l1=0;
while(count<=n){
line(x-count1,l1+y,x,y+string_length);//left rope
line(count1+x,l1+y,x,y+string_length);
ellipse(x-count1,l1+y,r,r);//left balloon
ellipse(count1+x,y+l1,r,r);
l1=l1+20;
count1=count1+l;
count++;
}
}
วันจันทร์ที่ 7 กันยายน พ.ศ. 2558
Delivery_lab3
float price;
int Package,Service;
int weight;
void setup(){
size(200,200);
//1=letter
//2=box
PackageType(1);
SeviceType(2);
weight=10;
calculate(Package,Service,weight);
}
void PackageType(int PackageType_1){
if(PackageType_1==1)
println("Package is Letter");
else if(PackageType_1==2)
println("Package is Box");
else
println("Error and try again");
Package=PackageType_1;
}
void SeviceType(int SeviceType_1){
if(SeviceType_1==1)
println("Next Day Priority");
else if(SeviceType_1==2)
println("Next Day Standard");
else if(SeviceType_1==3)
println("2-Day");
else
println("Error and try again");
Service=SeviceType_1;
}
void calculate(int Package,int Service,int weight){
/////////////Letter//////////////
if(Package==1 && Service==1){
if((weight%8)==0 || weight<=8)
price=12;
else if((weight%8)!= 0){
price=12*(int(weight/8)+1);
}
}
else if(Package==1 && Service==2){
if((weight%8)==0 || weight<=8)
price=10.5;
else if((weight%8)!= 0){
price=10.5*(int(weight/8)+1);
}
}
else if(Package==1 && Service==3)
println("not avariable");
//////////////Box////////////////
else if (Package==2&&Service==1){
if(weight==1)
price=15.75;
else if(weight != 1){
price=15.75+((weight-1)*1.25);
}
}
else if (Package==2&&Service==2){
if(weight==1)
price=13.75;
else if(weight != 1){
price=13.75+((weight-1)*1.00);
}
}
else if (Package==2&&Service==3){
if(weight==1){
price=7;
}
else if(weight != 1){
price=7+((weight-1)*0.5);
}
}
println("weight is "+weight);
println("price is "+price);
}
วันอาทิตย์ที่ 6 กันยายน พ.ศ. 2558
Logo_lab3
int moveX;
int moveY;
void setup(){
size(500,550);
}
void draw(){
music();
}
void music(){
int posx=25;
int posy=7;
moveX=(moveX+1)%4;
moveY=(moveY+1)%4;
rect(0, 0, 499, 549);
//left heart
stroke(#000000);
strokeWeight(10);
line(246-posx+moveX, 85-posy, 190-posx+moveX, 15-posy); //1
line(190-posx+moveX, 15-posy, 90-posx+moveX, 130-posy); //2
line(90-posx+moveX, 130-posy, 246-posx+moveX, 321-posy); //3
line(246-posx+moveX, 321-posy, 246-posx+moveX, 150-posy); //4
line(246-posx+moveX, 150-posy, 155-posx+moveX, 150-posy); //5
stroke(#F23383);
strokeWeight(7.5);
line(246, 85+moveY, 190, 15+moveY); //1
line(190, 15+moveY, 90, 130+moveY); //2
line(90, 130+moveY, 246, 321+moveY); //3
line(246, 321+moveY, 246, 150+moveY); //4
line(246, 150+moveY, 155, 150+moveY); //5
//right heart
stroke(#000000);
strokeWeight(10);
line(262+posx+moveX, 85-posy,318+posx+moveX, 15-posy); //1
line(318+posx+moveX, 15-posy, 418+posx+moveX, 130-posy); //2
line(418+posx+moveX, 130-posy, 262+posx+moveX, 321-posy); //3
line(262+posx+moveX, 321-posy, 262+posx+moveX, 150-posy); //4
line(262+posx+moveX, 150-posy, 353+posx+moveX, 150-posy); //5
stroke(#F23383);
strokeWeight(7.5);
line(262, 85+moveY,318, 15+moveY); //1
line(318, 15+moveY, 418, 130+moveY); //2
line(418, 130+moveY, 262, 321+moveY); //3
line(262, 321+moveY, 262, 150+moveY); //4
line(262, 150+moveY, 353, 150+moveY); //5
//Heart WAVE
strokeWeight(1);
line(150, 370+moveY,185, 370+moveY);
line(185, 370+moveY, 202, 344+moveY);
line(202, 345+moveY, 202, 370+moveY);
line(202, 370+moveY, 217, 344+moveY);
line(217, 345+moveY, 217, 385+moveY);
line(217, 385+moveY, 234, 357+moveY);
line(234, 357+moveY, 244, 357+moveY);
line(244, 357+moveY, 244, 370+moveY);
line(244, 370+moveY, 259, 370+moveY);
line(259, 370+moveY, 276, 344+moveY);
line(276, 344+moveY, 276, 370+moveY);
line(276, 370+moveY, 292, 344+moveY);
line(292, 344+moveY, 292, 384+moveY);
line(292, 384+moveY, 309, 357+moveY);
line(309, 357+moveY, 319, 357+moveY);
line(319, 357+moveY, 319, 370+moveY);
line(319, 370+moveY, 354, 370+moveY);
fill(#F23383);
ellipse(354, 370+moveY, 3, 3);
if(mousePressed == true){
textSize(90);
fill(#000000);
text("G",130+moveX,478+moveY);
}
else{
textSize(90);
fill(#F23383);
text("G",130+moveX,478+moveY);
}
if (keyPressed == false){
fill(#FFA5CB);
textSize(40);
text("irls",191,445);
textSize(40);
text("eneration",189,478);
}
else{
fill(#ED0707);
textSize(40);
text("irls",191,445);
textSize(40);
text("eneration",189,478);
}
fill(#FFFFFF);
println("My faverite Music is ");
println ("Girlsgeneration");
println(moveX);
}
Power_of_ten_lab3
void setup(){
size();
int value=0;
println("10e"+value);
power_of_ten(value);
}
void power_of_ten(int value){
if (value==6){
println("Million");
}
else if(value==9){
println("Billion");
}
else if(value==12){
println("Trillion");
}
else if(value==15){
println("Quadrillion");
}
else if(value==18){
println("Quintillion");
}
else if(value==21){
println("Sextillion");
}
else if(value==30){
println("Nonillion");
}
else if(value==100){
println("Googol");
}
else{
println("Error");
}
}
Movie_lab_3
int resize;
int move;
int cout;
void setup(){
size(600, 600);
}
void draw(){
movie(400);
if (cout < 30){
move++;
cout++;
}else if(cout > 0){
move--;
if(move==0){
cout =0;}
}
println(move);
println("..................");
println(cout);
}
void movie(int x){
int posx=50;
resize=(resize+1)%20;
background(#778899);
fill(#FAEBD7);
stroke(#000000);
strokeWeight(5);
ellipse(300, 300, 300, 400); //face
stroke(#000000);
strokeWeight(5);
line(300, 98, 300, 50); //hair 1
line(295, 98, 280, 60); //hair 2
line(305, 98, 320, 60); //hair 3
//Nose
fill(#CC0000);
strokeWeight(5);
ellipse(x, 350, 70+resize, 65+resize); //nose
fill(#FF0000);
stroke(#FF0000);
strokeWeight(1);
ellipse(x, 350, 59+resize, 55+resize); //nose red
fill(#FF4500);
stroke(#FF4500);
strokeWeight(1);
ellipse(x, 350, 48+resize, 45+resize); //nose orange
fill(#FFA500);
stroke(#FFA500);
strokeWeight(1);
ellipse(x, 350, 37+resize, 35+resize); //nose yellow
fill(#000000);
stroke(#000000);
quad(posx+210, 250, posx+230, 200, posx+250, 250, posx+230, 300); //left tatto
fill(#F8F8FF);
strokeWeight(2);
ellipse(posx+230, 250, 80+resize, 30+resize); //left eye
ellipse(posx+370, 250, 80+resize, 30+resize); //right eye
fill(#CC0000);
stroke(#CC0000);
strokeWeight(1);
ellipse(posx+230+move, 250, 10+resize, 26+resize); //left small eye
ellipse(posx+370+move, 250, 10+resize, 26+resize); //right small eye
fill(#FF0000);
stroke(#FF0000);
strokeWeight(1);
ellipse(posx+230+move, 250, 2+resize, 2+resize); //left very small eye
ellipse(posx+370+move, 250, 2+resize, 2+resize); //right very small eye
println("My Movie is Batman");
println("This is JOKER");
println(resize);
}
leap_year_lab3
void setup(){
size();
leap_year(2016);
}
void leap_year(int year){
float value;
value=year%400;
if(value==0){
println("(r1)leap year 29 days");
}
else{
value=year%100;
if(value==0){
println("(r2)dont leap year 28 day");
}
else{
value=year%4;
if(value==0){
println("(r3)leap year 29 days");
}
else{
println("dont Leave year 28 day");
}
}
}
}
cal_GPA_lab3
void setup(){
size();
cal_GPA(45);
}
void cal_GPA(int score)
{
if(score<0){
println("Error");
}
else if(score<50){
println("F");
}
else if(score<60){
println("D");
}
else if(score<70){
println("C");
}
else if(score<80){
println("B");
}
else if(score<=100){
println("A");
}
else{
println("Error");
}
}
book_lab_3
int moveY;
int cout;
void setup(){
size(550,700);
}
void draw(){
book();
if(cout < 20){
moveY++;
cout++;
}else if(cout > 0){
moveY--;
if(moveY == -20){
cout=-20;
}
}
println(moveY);
print("..................");
println(cout);
}
void book(){
int posy=50;
//moveY=(moveY+1)%(100);
fill(#D8BABA);
rect(0, 0, 549, 699);
fill(#FFFFFF);
rect(0, 0, 55, 699);
textSize(40);
fill(#000000);
text("1",15,50);
textSize(20);
text("45B",8,660);
fill(#FF9966);
rect(60, 5, 485, 450);
//////////////////Body/////////////////
fill(#000000);
strokeWeight(4);
ellipse(300, posy+250-moveY, 240, 250);//face back
fill(#FFFFFF);
rect(165, posy+251-moveY, 30, 40);//left ear
rect(405, posy+251-moveY, 30, 40);//right ear
ellipse(300, posy+254-moveY, 238, 245);
fill(#FDFF40);//face front
ellipse(360, posy+245-moveY, 70, 80);//right eye
ellipse(240, posy+245-moveY, 70, 80);//left eye
strokeWeight(2);
fill(#000000);
triangle(300, posy+275-moveY, 285,posy+100-moveY, 315, posy+100-moveY); //crest
textSize(70);
fill(#000000);
text("The",100,530);
textSize(60);
text("Ultraman",250,530);
textSize(40);
text("Original",380,580);
/*
println("My faverite book is ");
println ("ultranma");
println(-moveY);*/
}
bird_lab3
int movey=0;
float movex=0;
int count=0;
void setup() {
size(600, 600);
}
void draw() {
background(255-mouseY);
bird(mouseX, mouseY, 30, 30);
println("count"+count);
println("moveY"+movey);
println("moveX"+movex);
}
void bird(int x, int y, int w, int h) {
//w= width
//h= hight
if(count<120){
movey++;
count++;
}
else if(count>=0){
movey--;
if(movey==0){
count=0;
}
}
strokeWeight(5);
fill(#FFFFFF);
line(x+15, y, x+80-movex, y+60-movey);//right
line(x-15, y, x-80, y+60-movey); //left
ellipse(x, y, w, h);
fill(#F21616);
strokeWeight(1);
ellipse(x+7, y, w-22, h-15);//left eye
ellipse(x-7, y, w-22, h-15);//right eye
fill(#E08B22);
triangle(x-6,y+9,x+6,y+9,x,y+18);//mouth
}
battery_lab3
int resize;
int countL;
int countD;
int a;
void setup() {
size(600, 450);
}
void draw() {
background(#EAE49C);
draw_battery(220, 175, 200, 75);
//draw_positionSign(15, 3);
//draw_negativeSign(260);
println(resize);
println(mouseX);
println("CountL"+countL);
println("CountD"+countD);
println("Press"+mousePressed);
}
void draw_battery(int x,int y,int w,int h) {
fill(#EAE49C);
stroke(#384D12);
strokeWeight(5);
rect(x, y, w, h, 7); //case
fill(#384D12);
//depolarized
rect(x-10, y+15, w-190, h-30, 2);
//in case
resize=(resize+3)%180;
rect(((x+191)-resize), y+9, resize, h-17, 1);
////////// POS /////////////
fill(#ED0C0C);
stroke(#ED0C0C);
rect(x-45, y+34, w-185, h-72);//horizontal
rect(x-39, y+28, w-197, h-60);//vertical
//////////// NEG //////////
fill(#ED0C0C);
stroke(#ED0C0C);
rect(x+215, y+34, w-185, h-72);//horizontal
if (mouseX<100 || mouseX>500) {
rect(x+172, y+9, w-181, h-17, 1);
resize=0;
textSize(50);
text("Low Battery", x-45, y+135);
countL++;
if(countL>20){//50
countD++;
fill(#EAE49C);
stroke(#EAE49C);
strokeWeight(5);
rect(x+172, y+9, w-181, h-17, 1);
if(countD>20){
countL=0;
countD=0;
}
}
}
}
balloon_lab3
void setup(){
size(300, 500);
}
void draw(){
background(#FFFFFF);
int y=mouseY;
if(y>400){
fill(#04D605);//green
background(#7C7C7C);//gray
}
else if(y<100){
fill(#EDE202);//yello
background(#E517E5);//pink
}
else{
fill(#ED1A1A);//red
background(#3C17E5);//blue
}
draw_balloon(150,y);
}
void draw_balloon(int x,int y){
int r=100;
int string_length=200;
line(x,y,x,y+string_length);
ellipse(x,y,r,r);
}
สมัครสมาชิก:
บทความ (Atom)