Processing - 14 - if와 else if, fill와 마우스 좌표를 사용한 그리기

4477 단어 processing

void setup() {
  size(500, 500);
  noStroke();
}
void draw() {
  background(204);
  if ((mouseX <= width/2) && (mouseY <= height/2)) {
    fill(0);
    rect(0, 0, width/2, height/2);
  } else if ((mouseX > width/2) && (mouseY < height/2)) {
    fill(50);
    rect(width/2, 0, width/2, height/2);
  } else if ((mouseX > width/2) && (mouseY > height/2)) {
    fill(100);
    rect(width/2, height/2, width/2, height/2);
  } else {
    fill(150);
    rect(0, height/2, width/2, height/2);
  }
}

좋은 웹페이지 즐겨찾기