Janet Lee-Project 07-Curves

sketch

//Janet Lee
//Section C
//janetl2@andrew.cmu.edu
//Project 07


var points = 70;
function setup() {
    createCanvas(400, 400);
    strokeWeight(2);
    //stroke("#F1CDD4");//baby pink
    frameRate (30);


}

function draw() {
  background ("#CDE7EE");//baby blue

  push();
  translate (width/2,height/2);
  drawHeart();
  pop();


function drawHeart () {
  var a = map(mouseX,0,width,25,75);
  var b = map(mouseY,0,height,0,100);
//heart becomes bigger and wider

  beginShape()
  //base shape: heart
  for (var i = 0; i < points; i ++ ) {
    var t= map(i,0,points,0,70);//hearts made out of lines
    x = a* sin(t)*sin(t)*sin(t);
    y = b*cos(t)-a*cos(2*t)-2*cos(b*t)-cos(a*t);

    fill("#F1CDD4");//baby pink
    strokeWeight(2);
    vertex(-x,-y);//make the heart upright
  }
  endShape(CLOSE);
}
}

heartcurves_801

Leave a Reply