2020年10月19日 星期一

06

打字 


fill(255,0,0);                                                  →用fill填充顏色//非stroke

textSize(40);                                                   →字型大小

text("Hello",30,30);


size(500,400);

rect(100,100,200,100);

fill(255,0,0);

textSize(40);

text("Hello",100,100);


size(500,400);

rect(100,100,200,100);

fill(255,0,0);

textSize(40);

textAlign(LEFT,TOP);                                       →字在框裡面

text("Hello",100,100);

字型

→選中文字型程式編輯時才會顯示中文


size(300,200);

PFont font=createFont("Times New Roman",30);

textFont(font);

text("中文vs.English",30,30);

size(800,300);

fill(255,0,0);


PFont font1=createFont("Times New Roman",30);

textFont(font1);

text("中文vs.English",30,30);


PFont font2=createFont("標楷體",30);

textFont(font2);

text("中文vs.English",30,130);

陣列

int[][]A={{1,1,1},

                {0,1,0},

                {0,1,1},

                {1,1,1}};

→高4層

size(300,400);

for(int i=0;i<4;i++)                                      →左邊

{

  for(int j=0;j<3;j++)                                    →右邊

  {

    if(A[i][j]==0)fill(0);                                →0=黑//沒有

    else fill(255,0,0);                                     →1=紅色//有

    

    rect(j*100,i*100,100,100);

  }

}


Angry

int[][]A={{2,2,2,2},

          {0,1,1,1},

          {0,1,1,1},

          {2,2,2,2}};                                          →0=黑,1=bird,2=pig

PImage bird,pig;

void setup()

{

  size(400,400);

  bird=loadImage("bird.png");

  pig=loadImage("pig.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(bird,j*100,i*100,100,100);

      if(A[i][j]==2)image(pig,j*100,i*100,100,100);

    }

  }

  

}

int[][]A={{2,2,2,2},

          {0,1,1,1},

          {0,1,1,1},

          {2,2,2,2}};

PImage bird,pig;

void mousePressed()

{

  int i=int(mouseY/100);

  int j=int(mouseX/100);

  A[i][j]=0;

}

void setup()

{

  size(400,400);

  bird=loadImage("bird.png");

  pig=loadImage("pig.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(bird,j*100,i*100,100,100);

      if(A[i][j]==2)image(pig,j*100,i*100,100,100);

    }

  }

}




期中(末?)作品:挖鑽石(暫定)

































沒有留言:

張貼留言