2024年9月16日 星期一

HSY互動技術 week02

 void setup() {

  size(400, 400);

}


void draw() {

  background(255);

  fill(#FFDC0F);

  float a =radians(mouseX);

  for (int x=0; x<400; x+=100) {

    for (int y=0; y<400; y+=100) {

      arc(x+50, y+50, 100, 100, 0+a, PI*2 - a, PIE);

    }

  }

}


//week02_2
void setup() {
  size(400, 400);
}

void draw() {
  background(255);
  fill(#FFDC0F);
  float a = radians(frameCount);
  if (a>PI/4) a = a - PI/4;
  arc(200, 200, 300, 300, 0+a, PI*2-a, PIE);
}


void setup() {
  size(400, 400);
}

void draw() {
  background(255);
  fill(#FFDC0F);
  float a = frameCount % 180;
  if (a<45) a = radians(a);
  else if (a<90) a = radians(90-a);
  else if (a<135) a = radians(a-90);
  else if (a<180) a = radians(180-a);
  arc(200, 200, 300, 300, 0+a, PI*2-a, PIE);
}


void setup() {
  size(400, 400);
}

void draw() {
  background(255);
  fill(#FFDC0F);
  for (int x=0; x<400; x+=100) {
    for (int y=0; y<400; y+=100) {
      float a = frameCount % 180;
      if (a<45) a = radians(a);
      else if (a<90) a = radians(90-a);
      else if (a<135) a = radians(a-90);
      else if (a<180) a = radians(180-a);
      arc(x+50, y+50, 100, 100, 0+a, PI*2 - a, PIE);
    }
  }
}



//week02_5
void setup(){
  size(400,400);
  frameRate(120);
}

int x = 200, y = 200;
void draw(){
  background(255);
  fill(#FFDC0F);
  if(keyPressed && keyCode == RIGHT) x++;
  if(keyPressed && keyCode == LEFT) x--;
  if(keyPressed && keyCode == UP) y--;
  if(keyPressed && keyCode == DOWN) y++;
  ellipse(x, y, 100, 100);
}


void setup() {
  size(400, 400);
}

void draw() {
  background(255);
  fill(#FFDC0F);
  float a = frameCount % 180;
  float b = radians(mouseX);
  if (a<45) a = radians(a);
  else if (a<90) a = radians(90-a);
  else if (a<135) a = radians(a-90);
  else if (a<180) a = radians(180-a);
  arc(200, 200, 300, 300, b+0+a, b+PI*2-a, PIE);
}


//week02_7
void setup() {
  size(400, 400);
}
float x = 200, y = 200, d=PI/2*0;
void draw() {
  background(255);
  fill(#FFDC0F);
  float a = frameCount % 180;
  if (a<45) a = radians(a);
  else if (a<90) a = radians(90-a);
  else if (a<135) a = radians(a-90);
  else if (a<180) a = radians(180-a);
  arc(x, y, 100, 100, d+0+a, d+PI*2-a, PIE);
}

void keyPressed(){
  if(keyCode==RIGHT){
    x++;
    d = PI/2*0;
  }else if(keyCode==DOWN){
    y++;
    d = PI/2*1;
  }else if(keyCode==LEFT){
    x--;
    d = PI/2*2;
  }else if(keyCode==UP){
    y--;
    d = PI/2*3;
  }    
  }


void setup() {
  size(400, 400);
}

int x = 200, y = 200, d = 0;
void draw() {
  background(255);
  fill(#FFDC0F);

  float a = radians(abs(frameCount%90-45));
  int [] dx = {1, 0, -1, 0};
  int [] dy = {0, 1, 0, -1};
  if(keyPressed)x += dx[d];
  if(keyPressed)y += dy[d];
  arc(x, y, 100, 100, PI/2*d+a, PI/2*d+PI*2 - a, PIE);
}

void keyPressed() {
  if (keyCode==RIGHT) d = 0;
  if (keyCode==DOWN) d = 1;
  if (keyCode==LEFT) d = 2;
  if (keyCode==UP) d = 3;
}
















沒有留言:

張貼留言