# hschung-Project-07

``````//Heidi Chung
//Section A
//hschung@andrew.cmu.edu
//Project-07

var nPoints = 1000;

function setup() {
createCanvas(400, 400);
frameRate(10);
}

function draw() {
background(70, 140, 140);

var a = 1.5;
var b = 1.0;
var w = map(height/2, height/2, width/4, width-(width/4));
var inc = TWO_PI/(mouseX-height/4);

for (var waves = 0; waves < 400; waves++) { //waves behind the butterfly
strokeWeight(20);
stroke(83, 167, 218, 90);//blue thin lines sine curve
line(w, 100 -mouseY, waves*4 -mouseY, 100+sin(b)*40.0);
b = b + inc;

strokeWeight(3);
stroke(126, 180, 227, 90);//blue thick dotted sine curve
line(waves*10, 50, waves*4, 50+sin(b)*40.0);
b = b + inc;

strokeWeight(5);
stroke(30, 160, 154, 90); //green dotted sine curve
line(w, 150 -mouseY, waves*4, 150+sin(b)*40.0);
b = b + inc;

stroke(30, 160, 154, 90); //green lines sine curve
line(waves*10, 250, waves*4, 250+sin(b)*40.0);
b = b + inc;

stroke(255, 122, 153, 90); //dark pink dotted sine curve
line(w, 300, waves*4 -mouseX, 300+sin(b)*40.0);
b = b + inc;
}

push();
translate(width/2, height/2+30); //centers the butterfly
drawButterfly();
pop();
}

function drawButterfly() {
var x;
var y;
stroke(30, 160, 154, 90);
fill(255, 200, 200);
beginShape();
for (var i = 0; i < nPoints; i++) {
var t = map(i, 0, nPoints, 0, TWO_PI); //adding mouseX and mouseY alters the power of sin()
x = -50 * (sin(t) * (exp(cos(t))- 2*cos(4*t) + pow(sin((1*t+mouseX)/12), 5)));
y = -50 * (cos(t) * (exp(cos(t))- 2*cos(4*t) + pow(sin((1*t+mouseY)/12), 5)));
vertex(x, y);
//I chose the Butterfly Curve.
//http://mathworld.wolfram.com/ButterflyCurve.html