Grace Cha – Project 07- Curves

myshapes

For this project I worked with the Astroid Radial Curve.  I was really surprised that this function created so many varied curves, and while playing around with it, I had a lot of fun adding values and switching up the boundaries for the equation.

note:  Hover & Click mouse over the Canvas to start *

sketch

//Grace Cha
//Section C
//heajinc
//Project 07: Composition with Curves


var nPoints = 500;// the amount of lines
var boxConstrain = 150; //constrains the small box within an area initially


function setup() {
  createCanvas(500, 500);
  frameRate(15); //make it slow enough to view changes 
  
}

function draw() {
  background(0);

  //call my shape twice
  myShape();

  push();//rotate myShape()
  translate(-30,-350);
  rotate(radians(40));
  myShape();
  pop();
}

function myShape() {
  translate(width/2, height/2);
  stroke(255);
  strokeWeight(.3);//make it thin to visualize the lines better
  noFill();
  //Manipulated to react to mouseX and mouseY location
  var h = constrain(mouseY/10, 0, boxConstrain); //constrain shape 
  var w = constrain(mouseX/10, 0, boxConstrain);//constrain shape 
  
  push();
  beginShape();
  for (var i = 0; i < nPoints; i++) {
    var t = map(i, 0, nPoints, 0,  TWO_PI); 
    
    //Astroid Radial Curve
    //http://mathworld.wolfram.com/AstroidRadialCurve.html
    var x = boxConstrain * pow(cos(t * w),3);
    var y = boxConstrain * pow(sin(t * h),3);
    //stroke(242,183,5)
    stroke("#EEE1EE");
    point(x, y, 10 *i , 10 *i); //adds point at each vertex 
    curveVertex(x , y); //to add curves rather than jagged edges
  }
  endShape();
}
function mousePressed(){
	nPoints = random(5, 360); //number of lines/points 
	boxConstrain = random( 100, 500); //constrains
}

Leave a Reply