Project 07-Curves

sketch
var nPoints = 100;
function setup() {
    createCanvas(400, 400);
    frameRate(60);
}


function draw() {
    background(0);
    
    // draw the frame
    fill(0); 
    noStroke();
    stroke(57,255,20);
    noFill(); 
    rect(0, 0, width-1, height-1); 
    
    // draw the curve
    push();
    translate(width / 2, height / 2);
    for( var count = 1; count <= 9; count += 1){
      if(count <=3){
        drawButterflyCurve(-200 + count*100, 110);
      }else if(count <= 6){
        drawButterflyCurve(-200 + (count-3)*100, 0);
      }else if(count <= 9){
        drawButterflyCurve(-200 + (count - 6)*100, -110);
      
      
        
      }
    }
    pop();
  
}
function drawButterflyCurve(dx, dy){
  var x;
  var y;
  beginShape();
  for (var i = 0; i < nPoints; i++) {
        var t = map(i, 0, nPoints, 0, TWO_PI);
        x = 20*Math.sin(t) * [(Math.E)**(Math.cos(t)) - 2*Math.cos(mouseX/100 + 4*t) + (Math.sin(t/12))**5] - dx;
        y = -20*Math.cos(t) * [(Math.E)**(Math.cos(t)) - 2*Math.cos(mouseY/100 + 4*t) + (Math.sin(t/12))**5] - dy;
    vertex(x,y);
    
  }
  endShape(CLOSE);
}

Reading the project description, I was very intimidated by this week’s project due to all the complicated formulas and many options. I think I was drawn to the butterfly curve because of the shape and the complexity of it. I wanted to make a pattern out of these curves while it would turn based off the mouse’s position. Based on the mouse position, the curves would change and the lines would make different positions.

Leave a Reply