2024年9月30日 星期一

第四章

1. week04_1_PShape_loadShape_shape

1-1. 練習開啟 svg

1-2. google:taiwan svg 下載 svg 檔(需要有副檔名)

Ps. 檔案總管 - 檢視 - 副檔名

1-3. 開始寫程式

```
size(500, 500);
PShape taiwan = loadShap("Taiwan-icon.svg");
PShape taiwan2 = loadShap("tw.svg");
shape(taiwan);
shape(taiwan2);
```

week04_2_pushMatrix_scale_popMatrix

2-1. 複製 week04_1 的程式碼

2-2. 新增程式碼(修改圖片大小)

```
pushMatrix();
  scale(10);
  shape(taiwan);
popMatrix();

pushMatrix();
  scale(0.5);
  shape(taiwan2);
popMatrix();
```


week04_3_void_setup_void_draw_void_mouseWheel
PShape taiwan, taiwan2;
void setup(){
  size(500, 500);
  taiwan = loadShape("Taiwan-icon.svg");
  taiwan2 = loadShape("tw.svg");
}
float taiwanScale = 1;
void draw(){
  background(#1C56AF);
  pushMatrix();
    scale(10*taiwanScale);
    shape(taiwan);
  popMatrix();

pushMatrix();
  scale(0.5*taiwanScale);
  shape(taiwan2);
popMatrix();
}

void mouseWheel(MouseEvent e){
  float d = e.getCount();
  if(d > 0) taiwanScale *= 1.1;
  else taiwanScale *= 0.9;
}





week04_4_world_svg_float_s_void_mouseWheel
PShape world;
void setup(){
    size(800, 400);
    world = loadShape("world.svg");
}
float s = 0.4;
void draw(){
background(#1C56AF);
scale(s); //改用變數 s 初始值是0.4
shape(world);
}
void mouseWheel(MouseEvent e){
    if(e.getCount()>0) s *= 1.1;
    else s *= 0.9;
}


week04_5_float_x_y_translate_x_y_void_mouseDragged

PShape world;
void setup(){
  size(800, 400);
  world = loadShape("world.svg");
}
float s = 0.4, x = 0, y = 0;
void draw(){
  background(#1C56AF);
  translate(x, y);
  scale(s); //改用變數 s 初始值是0.4
  shape(world);
}
void mouseDragged(){
  x += mouseX - pmouseX;
  y += mouseY - pmouseY;
}

void mouseWheel(MouseEvent e){
  if(e.getCount()>0) s *= 1.1;
  else s *= 0.9;
}


week04_6_better_scale


PShape world;
void setup(){
  size(800, 400);
  world = loadShape("world.svg");
}
float s = 0.4, x = 0, y = 0;
float realX = 0, realY = 0;
void draw(){
  background(#1C56AF);
  translate(x, y);
  scale(s); //改用變數 s 初始值是0.4
  shape(world);
  ellipse(realX, realY, 10, 10);
}
void mouseDragged(){
  x += mouseX - pmouseX;
  y += mouseY - pmouseY;
}

void mouseWheel(MouseEvent e){
  realX = (mouseX - x)/s; //真實座標(mouseX) - 中心)/s
  realY = (mouseY - y)/s; //真實座標(mouseY) - 中心)/s
  float oldS = s;
  if(e.getCount() > 0) s *= 1.1;
  else s *= 0.9;
  x = x + realX*oldS - realX*s;
  y = y + realY*oldS - realY*s;
}


week04_7_carrot01_background_stroke_fill_ellipse

size(600, 500);
background(0);
ellipse(50, 50, 100, 100);
stroke(255);
fill(0);





week04_8_carrot02_void_setup_void_draw_void_mouseDrageed

void setup(){
  size(600, 500);
  background(0);
  stroke(255);
  fill(0);
}

void draw(){
    //ellipse(mouseX, mouseY, 100, 100);
}

float s = 25;
void mousePressed(){
  ellipse(mouseX, mouseY, s, s);
}



week04_9_carrot03_float_s_mouseButton_LEFT_RIGHT
void setup(){
  size(600, 500);
  background(0);
  stroke(255);
  fill(0);
}

void draw(){
    //ellipse(mouseX, mouseY, 100, 100);
}

float s = 25;
void mousePressed(){
  ellipse(mouseX, mouseY, s, s);
  if(mouseButton == LEFT) s *= 1.1;
  if(mouseButton == RIGHT) s *= 0.9;
}


week04_10_carrot04__float_t_cos_t_sin_t
void setup(){
  size(600, 500);
  background(0);
  stroke(255);
  fill(0);
}

void draw(){
    //ellipse(mouseX, mouseY, 100, 100);
}

float s = 25, t = 0;
void mousePressed(){
  ellipse(300 + 200*cos(t), 250 + 200*sin(t), s, s);
  t += 0.06;
  if(mouseButton == LEFT) s *= 1.1;
  if(mouseButton == RIGHT) s *= 0.9;
}





Week04 你諸位十連四金啊

 04-1(.svg)

下載 .svg



//week04_1_PShape_load_shape

PShape taiwan = loadShape("Taiwan-icon.svg");

PShape taiwan2 = loadShape("tw.svg");

size(500,500);

shape(taiwan);

shape(taiwan2);



04-2(調整大小)

//week04_2_pushMatrix_scale_popMatrix

size(500, 500);

PShape taiwan = loadShape("Taiwan-icon.svg");

PShape taiwan2 = loadShape("tw.svg");

pushMatrix();

  scale(10);

  shape(taiwan);

popMatrix();


pushMatrix();

  scale(0.5);

  shape(taiwan2);

popMatrix();

04-3(調整大小)

//week04_3_void_setup_void_draw_void_mouseWheel
PShape taiwan, taiwan2;
void setup() {
  size(500, 500);
  taiwan = loadShape("Taiwan-icon.svg");
  taiwan2 = loadShape("tw.svg");
}
float taiwanScale = 1;
void draw() {
  background(15,88,255);
  pushMatrix();
  scale(10*taiwanScale);
  shape(taiwan);
  popMatrix();

  pushMatrix();
  scale(0.5*taiwanScale);
  shape(taiwan2);
  popMatrix();
}
void mouseWheel(MouseEvent e){
 float d = e.getCount();
 if(d>0) taiwanScale *= 1.05;
 else taiwanScale *= 0.95;
}


04-4(世界地圖 調整大小)

//week04_4_world_svg_float_s_scale_s_void_mouseWheel

PShape world;

void setup(){

 size(1000,500);

 world = loadShape("world.svg");

}

float s = 0.5;

void draw(){

 background(#92C2F5);

 scale(s);

 shape(world);

}


void mouseWheel(MouseEvent e){

 if(e.getCount()>0) s *= 1.05;

 else s *= 0.95;

}


04-5(世界地圖 調整位置)

//week04_5_world_svg_translate_XY
PShape world;
void setup(){
 size(1000,500);
 world = loadShape("world.svg");
}
float s = 0.5,x=0,y=0;
void draw(){
 background(#92C2F5);
 translate(x,y);
 scale(s);
 shape(world);
}
void mouseDragged(){
 x +=mouseX-pmouseX;
 y +=mouseY-pmouseY;
}


void mouseWheel(MouseEvent e){
 if(e.getCount()>0) s *= 1.05;
 else s *= 0.95;
}


04-6(世界地圖 以鼠標調整位置)

//week04_6_world_svg_better_scale

PShape world;

void setup() {

  size(1000, 500);

  world = loadShape("world.svg");

}

float s = 0.5, x=0, y=0;

float realX = 0, realY = 0;

void draw() {

  background(#92C2F5);

  translate(x, y);

  scale(s);

  shape(world);

  ellipse(realX, realY, 10/s, 10/s);

  noStroke();

  fill(255,0,0);

}

void mouseDragged() {

  x +=mouseX-pmouseX;

  y +=mouseY-pmouseY;

}



void mouseWheel(MouseEvent e) {

  realX = (mouseX -x) /s;

  realY = (mouseY -y) /s;

  float oldS = s;

  if (e.getCount()>0) s *= 1.05;

  else s *= 0.95;

  x = x +realX*oldS - realX*s;

  y = y +realY*oldS - realY*s;

}


04-7(圈)

//week04_7_carrot01_background_stroke_fill_ellipse
size(600, 500);
background(0);
stroke(255);
fill(0);
ellipse(50, 50, 100, 100);



04-8(可控的圈)

//week04_8_carrot02_void_setup_void_draw_void_mousePressed

void setup() {

  size(600, 500);

  background(0);

  stroke(255);

  fill(0);

}

void draw() {

  //

}


void mousePressed() {

  ellipse(mouseX, mouseY, 99, 99);

}


04-9(可控大小的圈)

//week04_9_carrot03_left_right_button

void setup() {

  size(600, 500);

  background(0);

  stroke(255);

  fill(0);

}

void draw() {

  //

}

float s = 25;

void mousePressed() {

  ellipse(mouseX, mouseY, s, s);

  if(mouseButton==LEFT) s = s*1.1;

  if(mouseButton==RIGHT) s = s*0.9;

}



04-a(圈組成圈)

//week04_a_carrot04_cos_sin_t

void setup() {

  size(600, 500);

  background(0);

  stroke(255);

  fill(0);

}

void draw() {

  //

}

float s = 25, t=0;

void mousePressed() {

  ellipse(300+200*cos(t), 250+200*sin(t), s, s);

  t+=0.06;

  if (mouseButton==LEFT) s = s*1.1;

  if (mouseButton==RIGHT) s = s*0.9;

}




我想放假

 //week04_1_PShape_???

PShape taiwan = loadShape("Taiwan-icon.svg");

PShape taiwan2 = loadShape("tw.svg");

//PImage img = loadImage("image.jpg");

size(500,500);

shape(taiwan);

shape(taiwan2);


//week04_02_pushMatrix_scale_popMatrix

size(500,500);

PShape taiwan = loadShape("Taiwan-icon.svg");

PShape taiwan2 = loadShape("tw.svg");

//PImage img = loadImage("image.jpg");

pushMatrix();

  scale(10);

  shape(taiwan);

popMatrix();

pushMatrix();

  scale(0.05);

  shape(taiwan2);

popMatrix();



//week04_03_void_setup_draw_void_wheelMouse

PShape taiwan, taiwan2;

void setup()

{

  size(500,500);

  taiwan = loadShape("Taiwan-icon.svg");

  taiwan2 = loadShape("tw.svg");

}

float taiwanScale = 1;

//PImage img = loadImage("image.jpg");

void draw()

{

  background(#92C2F5);

  pushMatrix();

    scale(10*taiwanScale);

    shape(taiwan);

  popMatrix();

  pushMatrix();

    scale(0.5*taiwanScale);

    shape(taiwan2);

  popMatrix();

}

void mouseWheel(MouseEvent e)

{

  float d = e.getCount();

  if(d>0)taiwanScale *=1.1;

  else taiwanScale *=0.9;

}


//week04_4_world.svg_float_s_scale_s_void_mouseWheel_s

PShape world;

void setup()

{

  size(800,400);

  world = loadShape("world.svg");

}

float s = 0.4;

void draw()

{

  background(#92C2F5);

  scale(s);

  shape(world);

}

void mouseWheel(MouseEvent e)

{

  if (e.getCount()>0)s*=1.1;

  else s *= 0.9;

}



//week04_05_world_svg_translatc_x_y_void_mouseDragged

PShape world;

void setup()

{

  size(800,400);

  world = loadShape("world.svg");

}

float s = 0.4, x=0,y=0;

void draw()

{


  background(#92C2F5);

  translate(x,y);

  scale(s);

  shape(world);

}

void mouseDragged()

{

  x += mouseX - pmouseX;

  y += mouseY - pmouseY;

}

void mouseWheel(MouseEvent e)

{

  if (e.getCount()>0)s*=1.1;

  else s *= 0.9;

}


//week04_06_better_scale

PShape world;

void setup()

{

  size(800,400);

  world = loadShape("world.svg");

}

float s = 0.4, x=0,y=0;

float realX = 0, realY = 0;

void draw()

{


  background(#92C2F5);

  translate(x,y);

  scale(s);

  shape(world);

  ellipse(realX,realY,10,10);

}

void mouseDragged()

{

  x += mouseX - pmouseX;

  y += mouseY - pmouseY;

}

void mouseWheel(MouseEvent e)

{

  realX = (mouseX - x)/s;

  realY = (mouseY - y)/s;

  float oldS = s;

  if (e.getCount()>0)s*=1.1;

  else s *= 0.9;

  x = x + realX*oldS - realX*s;

  y = y + realY*oldS - realY*s;

}




//week04_07_carrot01_stroke_fill_ellipse

size(600,500);

background(0);

stroke(255);

fill(0);

ellipse(50,50,100,100);

//week04_08_carrot02_void_setup_void_setup_void_draw_void_mouseDragged

void setup()

{

  size(600,500);

  background(0);

  stroke(255);

  fill(0);

}

void draw()

{

  //ellipse(mouseX,mouseY,100,100)

}

float s=25;

void mousePressed()

{

  ellipse(mouseX,mouseY,100,100);

  //if(mouseButton==LEFT)s *= 1.1;

  //if(mouseButton==RIGHT)s *= 0.9;

}

//week04_09_carrot03_float_s_mouseButton_LEFT_RIGHT

void setup()

{

  size(600,500);

  background(0);

  stroke(255);

  fill(0);

}

void draw()

{

  //ellipse(mouseX,mouseY,100,100)

}

float s=25;

void mousePressed()

{

  ellipse(mouseX,mouseY,s,s);

  if(mouseButton==LEFT)s *= 1.1;

  if(mouseButton==RIGHT)s *= 0.9;

}

//week04_a_carrot03_float_t_cos_t_cos_t_sin_t

void setup()

{

  size(600,500);

  background(0);

  stroke(255);

  fill(0);

}

void draw()

{

  //ellipse(mouseX,mouseY,100,100)

}

float s=25,t=0;

void mousePressed()

{

  ellipse(300+200*cos(t),250+200*sin(t),s,s);

  t+=0.06;

  if(mouseButton==LEFT)s *= 1.1;

  if(mouseButton==RIGHT)s *= 0.9;

}






SY-BlingBangBang week04 Taiwan-icon.svg

 [TODO]

上課內容:

Taiwan-icon.svg(讀入svg)

// week04_1_PShape_loadShape_shape
// google: taiwan-icon.svg 下載 svg 檔(檔案總管-檢視-副檔名)
//PImage img = loadImage("image.jpg"); //上週教的
//image(img, 0, 0); // week03_1_PImage_loadImage_image
size(500,500);
// 本周要教的 PShape loadShape shape
PShape taiwan = loadShape("Taiwan-icon.svg");
PShape taiwan2 = loadShape("tw.svg");
shape(taiwan);
shape(taiwan2);


Taiwan-icon.svg(調整大小)

// week04_2_pushMatrix_scale_popMatrix
size(500,500);
PShape taiwan = loadShape("Taiwan-icon.svg");
PShape taiwan2 = loadShape("tw.svg"); //第二張svg圖檔
pushMatrix();
  scale(10);
  shape(taiwan);
popMatrix();
pushMatrix();
  scale(0.5);
  shape(taiwan2);
popMatrix();


Taiwan-icon.svg(放大縮小)

// week04_3_void_setup_void_draw_void_mouseWheel
PShape taiwan,taiwan2; //宣告變數
void setup(){
  size(500,500);
  taiwan = loadShape("Taiwan-icon.svg"); //讀入 svg
  taiwan2 = loadShape("tw.svg"); //第二張svg圖檔
}
float taiwanScale = 1;
void draw(){
  background(#90C8FF);
  pushMatrix();
    scale(10*taiwanScale);
    shape(taiwan);
  popMatrix();
  pushMatrix();
    scale(0.5*taiwanScale);
    shape(taiwan2);
  popMatrix();
}
void mouseWheel(MouseEvent e){
  float d = e.getCount();
  if(d>0) taiwanScale *= 1.1;
  else taiwanScale *= 0.9;
}


world.svg(換圖)

// week04_4_world_svg_float_s_scale_s_void_mouseWheel_s
PShape world;
void setup(){
  size(800,400);
  world = loadShape("world.svg");
}
float s = 0.4;
void draw(){
  background(#90C8FF);
  scale(s); //改用變數 s 初始值是 0.4
  shape(world);
}
void mouseWheel(MouseEvent e){
  if(e.getCount()>0) s*=1.1;
  else s*=0.9;
}


world.svg(拖曳)

// week04_5_float_x_y_translate_x_y_void_mouseDragged
PShape world;
void setup(){
  size(800,400);
  world = loadShape("world.svg");
}
float s=0.4, x=0, y=0;
void draw(){
  background(#90C8FF);
  translate(x,y); //要再加上一個移動量 x,y
  scale(s); //改用變數 s 初始值是 0.4
  shape(world);
}
void mouseDragged(){ //void mouseDragged()
  x += mouseX - pmouseX;
  y += mouseY - pmouseY;
}
void mouseWheel(MouseEvent e){//void mouseWheel(MouseEvent e)
  if(e.getCount()>0) s*=1.1;
  else s*=0.9;
}


world.svg(定中心位置)
// week04_6_better_scale
PShape world;
void setup(){
  size(800,400);
  world = loadShape("world.svg");
}
float s=0.4, x=0, y=0;
float realX=0, realY=0;
void draw(){
  background(#90C8FF);
  translate(x,y); //要再加上一個移動量 x,y
  scale(s); //改用變數 s 初始值是 0.4
  shape(world);
  ellipse(realX, realY, 10, 10);
}
void mouseDragged(){ //void mouseDragged()
  x += mouseX - pmouseX;
  y += mouseY - pmouseY;
}
void mouseWheel(MouseEvent e){//void mouseWheel(MouseEvent e)
  realX = (mouseX - x)/s; //地圖上,真的座標
  realY = (mouseY - y)/s; //地圖上,真的座標
  float oldS = s;
  if(e.getCount()>0) s*=1.1;
  else s*=0.9;
  x = x+realX*oldS - realX*s;
  y = y+realY*oldS - realY*s;
}

world.svg(定中心位置,圓圈比例)
// week04_6_better_scale
PShape world;
void setup(){
  size(800,400);
  world = loadShape("world.svg");
}
float s=0.4, x=0, y=0;
float realX=0, realY=0;
void draw(){
  background(#90C8FF);
  translate(x,y); //要再加上一個移動量 x,y
  scale(s); //改用變數 s 初始值是 0.4
  shape(world);
  ellipse(realX, realY, 10/s, 10/s); //除s,讓圓圈比例不變
}
void mouseDragged(){ //void mouseDragged()
  x += mouseX - pmouseX;
  y += mouseY - pmouseY;
}
void mouseWheel(MouseEvent e){//void mouseWheel(MouseEvent e)
  realX = (mouseX - x)/s; //地圖上,真的座標
  realY = (mouseY - y)/s; //地圖上,真的座標
  float oldS = s;
  if(e.getCount()>0) s*=1.1;
  else s*=0.9;
  x = x+realX*oldS - realX*s;
  y = y+realY*oldS - realY*s;
}


carrot01

// week04_7_carrot01_background_stroke_fill_ellipse
size(600,500);
background(0);
stroke(255);
fill(0);
ellipse(50,50,100,100);

carrot02(多個大小一樣的圓)
// week04_8_carrot02_void_setup_void_draw_mouseDragged
void setup(){
  size(600,500);
  background(0); //黑畫1次
  stroke(255);
  fill(0);
}
void draw(){
  //ellipse(mouseX,mouseY,100,100);
}
void mousePressed(){
  ellipse(mouseX,mouseY,100,100);
}

carrot03(手動,左右鍵控制大小)

// week04_9_carrot03_float_mouseButton_LEFT_RIGHT
void setup(){
  size(600,500);
  background(0); //黑畫1次
  stroke(255);
  fill(0);
}
void draw(){
  //ellipse(mouseX,mouseY,100,100);
}
float s=25;
void mousePressed(){
  ellipse(mouseX,mouseY,s,s);
  if(mouseButton==LEFT) s*=1.1; //滑鼠左鍵
  if(mouseButton==RIGHT) s*=0.9; //滑鼠右鍵
}


carrot04(半自動)

// week04_10_carrot04_float_t_cos_t_sin_t
void setup(){
  size(600,500);
  background(0); //黑畫1次
  stroke(255);
  fill(0);
}
void draw(){
  //ellipse(mouseX,mouseY,100,100);
}
float s=25, t=0;
void mousePressed(){
  ellipse(300+200*cos(t), 250+200*sin(t),s,s);
  t += 0.06;
  if(mouseButton==LEFT) s*=1.1; //滑鼠左鍵
  if(mouseButton==RIGHT) s*=0.9; //滑鼠右鍵
}



聽均一席話如聽一席話 Week04 11160712

 //week04_1_PShape_loadShape-shape

//google下載svg檔
//PImage img = loadImage("image.jpg");上週教的

PShape taiwan = loadShape("Taiwan-icon.svg");
PShape taiwan2 = loadShape("tw.svg");

size(500,500);
shape(taiwan);
shape(taiwan2);

載入svg檔案

//week04_2_pushMatrix_scale_popMatrix
//google下載svg檔

size(500,500);
PShape taiwan = loadShape("Taiwan-icon.svg");
PShape taiwan2 = loadShape("tw.svg");

pushMatrix();
  scale(10);
  shape(taiwan);
popMatrix();
pushMatrix();
  scale(0.5);
  shape(taiwan2);  
popMatrix();


改變他的大小

//week04_3_void_setup_voiddraw_void_wheelMouse
//google下載svg檔
PShape taiwan, taiwan2;
void setup() {
  size(500, 500);
  taiwan = loadShape("Taiwan-icon.svg");
  taiwan2 = loadShape("tw.svg");
}
float taiwanScale = 1;
void draw() {
  background(#92C2F5);
  pushMatrix();
  scale(10*taiwanScale);
  shape(taiwan);
  popMatrix();
  pushMatrix();
  scale(0.5*taiwanScale);
  shape(taiwan2);
  popMatrix();
}
void mouseWheel(MouseEvent e) {
  float d = e.getCount();
  if (d>0)taiwanScale *=1.1;
  else taiwanScale *=0.9;
}

用滾輪控制她的大小

///week04_4_world_svg_float_s_scale_s_void_mouseWheel_s
PShape world;
void setup(){
  size(800,400);
  world = loadShape("world.svg");
}
float s = 0.4;
void draw(){
  background(#92C2F5);
  scale(s);
  shape(world);
} 
void mouseWheel(MouseEvent e) {
  if (e.getCount()>0)s *=1.1;
  else s *=0.9;
}
改成世界地圖

///week04_5_float_x_y_translate_x_y_void_mouseDragged
PShape world;
void setup(){
  size(800,400);
  world = loadShape("world.svg");
}
float s = 0.4,x=0,y=0;
void draw(){
  background(#92C2F5);
  translate(x,y);//加上一個移動量x,y
  scale(s);
  shape(world);
} 
void mouseDragged(){
  x += mouseX-pmouseX;
  y += mouseY-pmouseY;
}
void mouseWheel(MouseEvent e) {
  if (e.getCount()>0)s *=0.9;
  else s *=1.1;
  
}
加上滑鼠拖曳的功能

///
PShape world;
void setup(){
  size(800,400);
  world = loadShape("world.svg");
}
float s = 0.4,x=0,y=0;
float realX = 0,realY = 0;
void draw(){
  background(#92C2F5);
  translate(x,y);//加上一個移動量x,y
  scale(s);
  shape(world);
} 
void mouseDragged(){
  x += mouseX-pmouseX;
  y += mouseY-pmouseY;
}
void mouseWheel(MouseEvent e) {
  realX = (mouseX-x)/s;
  realY = (mouseY-y)/s;
  float oldS=s;
  if (e.getCount()>0)s *=0.9;
  else s *=1.1;
  x=x+realX*oldS-realX*s;
  y=y+realY*oldS-realY*s;
}

在鼠標的位置(座標)進行放大


//week04_7_carrot01_background_stroke_fill_ellipse
size(600,500);
background(0);
stroke(255);
fill(0);
ellipse(50,50,100,100);

劃一個圈


//week04_8_carrot02_void_setup_void_draw_void_mouseDragged

void setup(){
size(600,500);
background(0);
stroke(255);
fill(0);
}
void draw(){
  //ellipse(mouseX,mouseY,100,100);
}
void mousePressed(){
  ellipse(mouseX,mouseY,100,100);
}
每按一次滑鼠下一個圈圈會越來越大
//week04_9_carrot03_float_s_mouseButton_LEFT_RIGHT

void setup(){
size(600,500);
background(0);
stroke(255);
fill(0);
}
void draw(){
  //ellipse(mouseX,mouseY,100,100);
}
float s=25;
void mousePressed(){
  
  ellipse(mouseX,mouseY,s,s);
  if(mouseButton==LEFT)s *=1.1;
  if(mouseButton==RIGHT)s *=0.9;
}
每按一次滑鼠左鍵下一個圈圈會越來越大
每按一次滑鼠右鍵下一個圈圈會越來越大

//week04_10_carrot04_float_cos_t_sin_t

void setup(){
size(600,500);
background(0);
stroke(255);
fill(0);
}
void draw(){

}
float s=25,t = 0;
void mousePressed(){
  
  ellipse(300+200*cos(t),250+200*sin(t),s,s);
  t += 0.06;
  if(mouseButton==LEFT)s *=1.1;
  if(mouseButton==RIGHT)s *=0.9;
}
自動畫圓

WEEK04他寶了個貝的,頭好痛,好想一槍愛死自己

 Week04

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
顯示圖片
PShape taiwan = loadShape("Taiwan-icon.svg");
PShape taiwan2 = loadShape("taiwan.svg");
size(500, 500);
shape(taiwan);
shape(taiwan2);

用Matrix陣列顯示
size(500, 500);
PShape taiwan = loadShape("Taiwan-icon.svg");
PShape taiwan2 = loadShape("tw.svg");
pushMatrix();
  scale(10);
  shape(taiwan);
popMatrix();
pushMatrix();
  scale(10);
  shape(taiwan2);
popMatrix();

圖片隨滑鼠中鍵縮放
PShape taiwan, taiwan2;
void setup(){
   size(500, 500);
   taiwan = loadShape("Taiwan-icon.svg");
   taiwan2 = loadShape("tw.svg");
}
float taiwanScale = 1;
void draw(){
  background(#92C2F5);
   pushMatrix();
     scale(10*taiwanScale);
     shape(taiwan);
   popMatrix();
   pushMatrix();
     scale(0.5*taiwanScale);
     shape(taiwan2);
   popMatrix();
}
void mouseWheel(MouseEvent e){
  float d = e.getCount();
  if(d<0)taiwanScale *= 1.1;
  else taiwanScale *= 0.9;
}

世界地圖的縮放
PShape world;
void setup(){
   size(800, 400);
   world = loadShape("world.svg");
}
float s = 0.4;
void draw(){
  background(#92C2F5);
  scale(s);
  shape(world);
}
void mouseWheel(MouseEvent e){
   if(e.getCount () <0)s *=1.1;
   else s*=0.9;
}



滑鼠拖曳放大世界地圖
PShape world;
void setup(){
   size(800, 400);
   world = loadShape("world.svg");
}
float s = 0.4, x = 0, y = 0;
void draw(){
  background(#92C2F5);
  translate(x, y);
  scale(s);
  shape(world);
}
void mouseDragged(){
  x += mouseX - pmouseX;
  y += mouseY - pmouseY;
}
void mouseWheel(MouseEvent e){
   if(e.getCount () <0)s *=1.1;
   else s*=0.9;
}



size(600, 500);
background(0);
stroke(255);
fill(0);
ellipse(50, 50, 100, 100);

按滑鼠左鍵召喚更大的圓圈,右鍵更小的圓圈
void setup(){
  size(600, 500);
  background(0);
  stroke(255);
  fill(0);
}
void draw(){
  //elipse(mouseX, mouseY, 100, 100);
}
float s = 25;
void mousePressed(){
  ellipse(mouseX, mouseY, s, s); 
  if(mouseButton == LEFT) s *=1.1;
  if(mouseButton == RIGHT) s *=0.9;
}



自動座標,按滑鼠左鍵召喚更大的圓圈,右鍵更小的圓圈
void setup(){
  size(600, 500);
  background(0);
  stroke(255);
  fill(0);
}
void draw(){
  //elipse(mouseX, mouseY, 100, 100);
}
float s = 25, t=0;
void mousePressed(){
  ellipse(300+200*cos(t),250+200*sin(t), s, s);
  t += 0.06; 
  if(mouseButton == LEFT) s *=1.1;
  if(mouseButton == RIGHT) s *=0.9;
}