sketch

//Dana Kim
// danakim@andrew.cmu.edu
//Section D
// Project-03

function setup() {
  createCanvas(640, 480);
  background(50);
}

var x = 320;
var y = 240;
var w = 4;
var angle = 0;

function draw() {
  //ColorChoice1
  if ((mouseY < y) & (mouseX < x)){
    c1 = "#FFA977"; //color for left cube
    c2 = "#FF3C38"; //color for top cube
    c3 = "#FF8D38"; //color for right cube
  }
  //ColorChoice2
  if ((mouseY > y) & (mouseX > x)){
    c1 = "#7A5C61";
    c2 = "#FF3C38";
    c3 = "#A23E48";
  }
  //ColorChoice3
  if ((mouseY > y) & (mouseX < x)){
    c1 = "#BB7279";
    c2 = "#68282E";
    c3 = "#A23E48";
  }

  //Rectangles change size, angle, and color
  push();
  noStroke();
  fill(c1);
  rotate(radians(angle));
  rect(318, 225, w, 30);
  translate(0, 100);
  fill(c2);
  rect(318, 225, w, 30);
  translate(0, -200);
  fill(c3);
  rect(318, 225, w, 30);
  pop();
  angle = angle + 50;

  //width of rectangles change
  if(mouseX>320){
    w = mouseX-300;
  }
  //circles change color and size
  if(mouseX < 320){
  fill(mouseX-200, mouseX+100, mouseY-200);
  stroke(265);
  ellipse(160, mouseY, mouseX-10, mouseX-10);
  }



}

I had originally planned on making a sandwich that would come apart and rotate. However, due to time constraints I decided to go with something simpler. The only problem I really bumped into was that the script kept redrawing the shapes. However, I thought it looked better with the redrawn parts.

Leave a Reply