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;
}
沒有留言:
張貼留言