2024年9月30日 星期一

WEEK04-翁逸豪

 WEEK04-1

PShape taiwan = loadShape("taiwan.svg");
PShape taiwan2 = loadShape("tw.svg");
size(500,500);
shape(taiwan);
shape(taiwan2);
輸入兩個台灣的svg圖檔

WEEK04-2

size(500, 500);
PShape taiwan = loadShape("taiwan.svg");
PShape taiwan2 = loadShape("tw.svg");
pushMatrix();
  scale(10);
  shape(taiwan);
popMatrix();
pushMatrix();
  scale(0.5);
  shape(taiwan2);
popMatrix();
調整台灣的大小

WEEK04-3

PShape taiwan,taiwan2;
void setup() {
  size(500, 500);
  taiwan = loadShape("taiwan.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

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

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-6

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-7

size(600,500);
background(0);
stroke(255);
fill(0);
ellipse(50,50,100,100);
一個空心白色外框圓圈

WEEK04-8

void setup(){
  size(600,500);
  background(0);
  stroke(255);
  fill(0);
}
void draw(){
  //ellipse(mouseX,mouseY,100+i,100+i);
}
void mousePressed(){
  ellipse(mouseX,mouseY,100,100);
}
點擊滑鼠畫圓

WEEK04-9

void setup(){
  size(600,500);
  background(0);
  stroke(255);
  fill(0);
}
float s=25;
void draw(){
  //ellipse(mouseX,mouseY,100,100);
}
void mousePressed(){
  ellipse(mouseX,mouseY,s,s);
  if(mouseButton==LEFT)s*=1.1;
  if(mouseButton==RIGHT)s*=0.9;
}
圓漸漸變大

WEEK04-10

void setup(){
  size(600,500);
  background(0);
  stroke(255);
  fill(0);
}
float s=25,t=0;
void draw(){
  //ellipse(mouseX,mouseY,100,100);
}
void mousePressed(){
  ellipse(300+200*cos(t),250+200*sin(t),s,s);
  t+=0.03;
  if(mouseButton==LEFT)s*=1.1;
  if(mouseButton==RIGHT)s*=0.9;
}
用sin與cos依照圓心畫圖


沒有留言:

張貼留言