2024年9月30日 星期一

week-04.0

001.

 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;

}

___________________________________________________________
002.
PShape world;
void setup() {
  size(1600, 900);
  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) {
  float d = e.getCount();
  if (d>0)s *=1.1;
  else s *=0.9;
}
_____________________________________________________________________
003.
PShape world;
void setup() {
  size(1600, 900);
  world = loadShape("world.svg");
}
float s= 0.4, x=0, y=0,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) {
  float realX = (mouseX - x)/s;
  float 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;
}
______________________________________________________________________
004.
void setup() {
  size(600, 500);
  background(0);
  stroke(255);
  fill(0);
}
void draw() {
  //dellipse(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;
}

沒有留言:

張貼留言