size(600,600);
fill(255,0,0); //第二週教過
textSize(80); //放大字
text("Hello", 50,50); //一開始字的fill填充色彩:白
void setup(){
size(600,600);
fill(255,0,0);
textSize(80);
}
void draw(){
text("Hello", 50,100);
}
//呈現時間:秒數
void setup(){
size(600,600);
fill(255,0,0);
textSize(80);
}
void draw(){
background(255);
text("Time:"+frameCount/60, 50,100); //不準
//每秒60frame,過了幾個frame
text("millis:"+millis()/1000,50,200); //準
//千分之一秒
}
//呈現現在時間
void setup(){
size(600,600);
fill(255,0,0);
textSize(80);
}
void draw(){
background(255);
text(hour()+":"+minute()+":"+second(), 50,100);
}
//加上中文字且可改變字體
PFont font1,font2; //自創可輸入中文的字串
void setup(){
size(800,400);
fill(255,0,0);
textSize(80);
font1 = createFont("標楷體",100); //給予中文設定
textFont(font1);
font2 = createFont("微軟正黑體",100);
}
void draw(){
background(255);
text("時間>>",0,100); //顯示中文
text(hour()+":"+minute()+":"+second(), 350,100);
if(mousePressed) textFont(font2); //當滑鼠按下去換字體
else textFont(font1); //滑鼠放開恢復原字體
}
//接續上方程式的補充
text(hour()+":"+minute()+":"+second(), 350,100);
改成=>
text(nf(hour(),2)+":"+nf(minute(),2)+":"+nf(second(),2), 350,100);
//nf()可以補0,例如:6 變成 06 如上圖所示
PFont font1;
void setup(){
size(800,400);
fill(255);
textSize(80);
font1 = createFont("標楷體",100); //給予中文設定
textFont(font1);
}
void draw(){
background(#075BB2);
text("現在>>"+nf(hour(),2)+":"+nf(minute(),2)+":"+nf(second(),2),50,100);
text("下課>>15:40:00",50,200);
int now = hour()*60*60+minute()*60+second();
int next = 15 *60*60+40 *60+0;
int remain = next-now;
//text("剩下>>"+remain,50,300); //剩下總秒數
text("剩下>>"+nf(remain/60/60,2)+":"+nf(remain/60,2)+":"+nf(remain%60,2),50,300);
//剩下幾分幾秒
}
//用漂亮的圖片來顯示數字
PFont font1;
PImage[] img = new PImage[10];
void setup(){
size(1120,450);
for(int i=0;i<10;i++) img[i]=loadImage(i+".png");
fill(255);
textSize(80);
font1 = createFont("標楷體",100); //給予中文設定
textFont(font1);
}
void draw(){
background(#075BB2);
text("現在>>"+nf(hour(),2)+":"+nf(minute(),2)+":"+nf(second(),2),50,100);
text("下課>>15:40:00",50,200);
int now = hour()*60*60+minute()*60+second();
int next = 16 *60*60+40 *60+0;
int remain = next-now;
if(remain<0) remain+=24*60*60;
text("剩下>>"+remain,50,300); //剩下總秒數
text("剩下>>"+nf(remain/60/60%60,2)+":"+nf(remain/60%60,2)+":"+nf(remain%60,2),50,400);
//剩下幾分幾秒
int x =800;
while(remain>0){
int n = remain%10;
remain = remain/10;
image(img[n],x,100,100,100);
x-=100;
}
}
沒有留言:
張貼留言