rgriswol_project-07

sketch

/*
* Rachel Griswold
* rgriswol@andrew.cmu.edu
* Section B
* Project 07
*
*/

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

function draw(){
	background(0);
	stroke(255, 0, 0);
	strokeWeight(3);
	fill(255);
	drawScarabaeusCurve();
} 

function drawScarabaeusCurve(){
	// Scarabaeus:
	// http://mathworld.wolfram.com/Scarabaeus.html

	var x;
	var y;
	var nPoints = 500; 
	var a = mouseX;
	var b = mouseY;

	beginShape();
	for(var i = 0; i < nPoints; i++){
		var th = map(i, 0, nPoints, 0, TWO_PI);
		var r = b * cos(2 * th) - a * cos(th);
		x = r * cos(th) / 2 + width/2;
		y = r * sin(th) / 2 + height/2;
		vertex(x , y);
	}
	endShape(CLOSE);
}

For this project I decided to go with the “scarabaeus” curve, mostly because it had a cool name. I ended up liking the shape (reminded me of the suit of clubs) and originally I wanted to make nPoints = 5, because it made the shape turn into a star if you moved the mouse the right way, but I figured that kind of defeated the purpose of the whole “curve” bit.
I considered changing the colors too, but I liked the simple black-white-red look. I also find it interesting how you can end up making it just a circle.

Leave a Reply