2024年9月30日 星期一

比奇堡佳齁勝 04

 


PShape world;
void setup(){
    size(800,400);
    world = loadShape("world.svg");
}
float s=0.4;
void draw(){
  background(#92C2F5);
  scale(s);//改用變數s初始值是0.4
  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); //要再加上一個移動量x,y
  scale(s);//改用變數s初始值是0.4
  shape(world);
}

void mouseDragged(){ //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(){
  //ellipse(mouseX,mouseY,100,100);
}
void mousePressed(){
  ellipse(mouseX,mouseY,100,100);
}






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);//改用變數s初始值是0.4
  shape(world);
  ellipse(realX,realY,10,10);
}

void mouseDragged(){ //void mouseDragged()
  x+=mouseX - pmouseX;
  y+= mouseY - pmouseY;
}

void mouseWheel(MouseEvent e){
  realX=(mouseY - x) / s; //地圖上的真實座標
  realY=(mouseX - 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;
}

//中心+真實座標*s== mouseX,mouseY
//
//舊中心+真實座標*舊S == 新中心+真實座標*新s



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;//變小
}




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


















沒有留言:

張貼留言