Erin Fuller Project-07-Curves

//Erin Fuller
//SectionA
//efuller@andrew.cmu.edu
//Project 07 - Curves

function setup() {
    createCanvas(480, 480);  
}


function draw() {

	background(10);

    var a = map(mouseX, 0, width, 0, 200);
    var b = map(mouseY, 0, height, 0, 200);

    var r = map(mouseX, 0, width, 0, 255);
	var g = map(mouseY, 0, width, 0, 255);

	//var v = createVector( width / 2, height / 2);
    
	beginShape();
	for(var i = 0; i < 300; i ++) {

		noFill();
		stroke(r, g, -r);

		push();

        var t = map(i, 0, 200, 0, 360);
        var n = ceil(map(mouseX, 0, width, 3, 6));

        //http://mathworld.wolfram.com/Astroid.html

	    x = (2 * a * cos(t)) + (b * cos(n * t));
	    y = (2 * a * sin(t)) - (b * sin(n * t));
	    vertex(x + width / 2, y + height / 2);
	   
	    pop();
	}

	endShape();
}

I started this using the curve “Astroid” from Wolfram. The curve did not turn out how I thought it would but it looked better than I thought. In a very unscientific way, I messed around with different variables until I found something that looked nice.

Leave a Reply