Project-07-mdambruc

sketch

//Mairead Dambruch
//mdambruc@andrew.cmu.edu
//Section C
//Project-07-A
var nPoints = 100;
function setup() {
   createCanvas(800, 150);
}
function draw() {
   background(255);
   for (var dist = -50; dist < 800; dist = dist + 100){
   push();
   translate(dist, 110);
   drawCycloid();
   pop();
}
}
function drawCycloid () {
  var x;
  var y;
  var a = 20;
  var yfactor = mouseX / 25;//makes waves!
  var colR = map(mouseY, 0, height, 151, 0);//changes color of waves
  var colB = map(mouseY, 0, height, 209, 111);
  var colG = map(mouseY, 0, height, 255, 189);
  noStroke();
  fill(colR, colB, colG);
  beginShape();
  for (var i = 0; i < nPoints; i++){
    var t = map(i, 0, nPoints, 0, TWO_PI);
    x = a * (t - sin(t + yfactor));//equations for cycloids
    y = a * (1 + cos(t));
    vertex(x, y);
}
endShape(CLOSE);
}

I was at first very scared for this project since it was using math equations. After getting the initial shape I had a lot of fun playing with possible interactions the mouse could have with the equation. In this project I wanted to create an animation of waves that crash as you move your mouse across the horizontal axis. The waves change color as you move your mouse across the vertical axis. I really enjoyed learning about the many ways you could alter math equations to create animations and had fun by using trial and error to discover new ways to move the object.

Leave a Reply