Project 07: Curves

For this assignment I began with the equation for the Quadratrix of Hippias, and scaled the equation based on the Y-Coordinate of the mouse. I also identified the limits of the formula and changed their visibility based on the X-Coordinate of the mouse.

sketchDownload
var t = 0;
var points = 200;
var eX = [];
var eY = [];
var a = 0;
var b = 0;
var r = 200;

function setup() {
    createCanvas(480, 480);
    background(0);

    stroke(255);
    strokeWeight(1);
    noFill();

    a = 15;
    b = mouseY;
}

function draw() {
  background(0);

  if (mouseY < 150 || mouseY > 330) {
    a = map(mouseY,0,height,-40,40);
  } else {a = 15}

  for (let i = 0; i < height; i += 1) {
    eY[i] = i;

    eX[i] = eY[i]*((1)/(tan((PI*eY[i])/(2*a))));

    line(eX[i]+240,eY[i]+240,eX[i+1]+240,eY[i+1]+240);
    line(eX[i]+240,-eY[i]+240,eX[i+1]+240,-eY[i+1]+240);

    if (abs((eX[i])-(eX[i+1])) > 400) {
      push();
      strokeWeight(2);
      stroke(map(mouseX,0,width,0,255),0,0);
      line(eX[i]+240,eY[i]+240,eX[i+1]+240,eY[i+1]+240);
      line(eX[i]+240,-eY[i]+240,eX[i+1]+240,-eY[i+1]+240)
      pop();
    }
  }
}

Leave a Reply