顯示文字
- 文字顏色:要用[fill]
- size(300,300);
- fill(255,0,0);
- textSize(40);
- text("MEOW",30,30);
- 對齊(textAlign) #橘點是對齊點
- textAlign(LEFT);(預設)
- textAlign(CENTER);
- textAlign(RIGHT);
- textAlign(CENTER,BOTTOM);(預設)
- textAlign(CENTER,CENTER);
- textAlign(CENTER,TOP);
- 字型
- 英文
- PFont font=createFont("Times New Roman",30);
- textFont(font);
- text("喵vs.MEOW",250,250);
- 中文
- PFont font=createFont("標楷體",30);
- textFont(font);
- text("喵vs.MEOW",250,250);
- 陣列填色
- int [][]A={{1,1,1},{0,1,0},
- {0,0,1},{1,1,1}};
- size(300,400);
- for(int i=0;i<4;i++){
- for(int j=0;j<3;j++){
- if(A[i][j]==0) fill(0);
- else fill(255,0,255);
- rect(j*100,i*100,100,100);
- }
- }
- 陣列填圖
- int [][]A={{2,2,2,2},{0,1,0,1},
- {0,0,1,1},{2,2,2,2}};
- PImage G,B;
- void setup(){
- size(400,400);
- G=loadImage("G.png");
- B=loadImage("B.png");
- }
- void draw(){
- background(0);
- for(int i=0;i<4;i++){
- for(int j=0;j<4;j++){
- if(A[i][j]==1) image(G, j*100, i*100, 100,100);
- if(A[i][j]==2) image(B, j*100, i*100, 100,100);
- }
- }
- }
- 戳氣球遊戲(滑鼠互動)
- int [][]A={{2,2,2,2},{0,1,0,1},
- {0,0,1,1},{2,2,2,2}};
- PImage G,B;
- void mousePressed(){
- int i=int(mouseY/100);
- int j=int(mouseX/100);
- A[i][j]=0;
- }
- void setup(){
- size(400,400);
- G=loadImage("G.png");
- B=loadImage("B.png");
- }
- void draw(){
- background(0);
- for(int i=0;i<4;i++){
- for(int j=0;j<4;j++){
- if(A[i][j]==1) image(G, j*100, i*100, 100,100);
- if(A[i][j]==2) image(B, j*100, i*100, 100,100);
- }
- }
- ellipse(mouseX,mouseY,10,10);
- }








沒有留言:
張貼留言