# Project-07-Curves

For this project, I was interested in the different depictions that were shown in the example for how to generate a circle curve. I thought it would be fun to try and draw a circle, but with a specific math curve. I chose the petal curve, and created a code that allowed you to manipulate the shape and frequency of the curve based on the position of the mouse. At first, it looks like a relatively pattern, with the petal curve rotating in the center, and its shape becoming skewed the greater the mouseX position it. However, if the mouse is pressed, then the pattern becomes more intricate, with the curves increasing in frequency to create a void, or circle, in the center. I had difficulty being able to take the curve a step further to make it more dynamic to look at. At first I chose a much more complicated curve, but I could not get the parentheses right while typing it in and it never looked correct!

peachsketch
``````var nPoints = 100
var angle = 0
var m;
var n;

function setup() {

createCanvas(400, 400);
m = width/2
n = height/2
}

function draw() {
background(0);
frameRate(20)
drawPetalCurve(m,n);
if (mouseIsPressed){ // if mouseIsPressed, draws higher frequency of rotating petal curves
for (j= 0; j<10;j++){
drawPetalCurve(m,n);
}
}

}

function drawPetalCurve (m,n){
var x;
var y;
var a = 100
var b = 100
var p = (constrain(mouseX, 50, 300))/50 //change dimensions of curve based on mouse location
push();
stroke(255)
noFill();
translate(width/2, height/2) // curve drawn at center
beginShape();
for (var i = 0; i < nPoints; i++) {
rotate(angle)
var t = map(i, 0, nPoints, 0, TWO_PI);
x = p*a*cos(t)*(sin(t)*sin(t))
y = a*(cos(t)*cos(t))*sin(t)
vertex(m/2+x, n/2+y)
angle+=0.1
}
endShape(CLOSE);

pop();

}
``````