Jonathan Liang – Project 7 – Curves

sketch

//Jonathan Liang
//jliang2
//Section A

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

function draw() {
	background(0);
	push();
	translate(300,300);
	rotate(sin(mouseX));
	drawKevin();
	pop();

	push();
	translate(300,300);
	rotate(-sin(mouseX));
	drawStanley();
	pop();
}

function drawKevin() {
    var kPoints = map(mouseX, 0, height, 0 , 500);
    var x;
    var y;
    var tj = map(mouseX, 0, width,0,8); // for iterations
    beginShape();
    for (var i=0; i < kPoints; i++){ 
        var t = map(i,0,kPoints,0,TWO_PI*tj);
        noFill();
        var colR = map(mouseX, 0, width, 0, 255);
        var colG = map(mouseY, 0, width, 0, 255);
        var colB = map(mouseX, 0, width, 0, 255);
        strokeWeight(.5);
        stroke(colR, colG, colB); // 
        //equations as listed on mathworld.wolfram.com/ButterflyCurve.html
        x = Math.sin(t) * (Math.pow(Math.E,Math.cos(t))
                        - 2*Math.cos(4*t) 
                        + Math.pow(Math.sin(t/12),5));

        y = Math.cos(t) * (Math.pow(Math.E,Math.cos(t))
                        - 2*Math.cos(4*t) 
                        + Math.pow(Math.sin(t/12),5));

        vertex(i*x,i*y);
    }
    endShape(CLOSE);  
}

function drawStanley() {
    var sPoints = map(mouseX, 0, height, 0 , 500);
    var x;
    var y;
    var tj = map(mouseX, 0, width,0,8); 

    beginShape();
 
    for (var i=0; i < sPoints; i++){ 
        var t = map(i,0,sPoints,0,TWO_PI*tj);
        noFill();
        var colR = map(mouseX, 0, width, 255, 0);
        var colG = map(mouseY, 0, width, 255, 0);
        var colB = map(mouseX, 0, width, 255, 0);
        strokeWeight(0.5);

        stroke(colR, colG, colB); // 
        //equations as listed on mathworld.wolfram.com/ButterflyCurve.html
        x = Math.sin(t) * (Math.pow(Math.E,Math.cos(t))
                        - 2*Math.cos(4*t) 
                        + Math.pow(Math.sin(t/12),5));

        y = Math.cos(t) * (Math.pow(Math.E,Math.cos(t))
                        - 2*Math.cos(4*t) 
                        + Math.pow(Math.sin(t/12),5));

        vertex(i*x,i*y);
    }
    endShape(CLOSE);  
}

I see the butterfly curve more like a ripple or a flower, growing over time. Just a flower blooms, butterflies blossom from little caterpillars to marvelous winged insects. However, as one butterfly blossoms, one must leave; which is why I made one fade away as the other became more prominent. The color becomes the most vibrant at the top right, symbolizing the butterfly’s prime, while the faded bottom right corner symbolizes its passing.

Leave a Reply