Project 07 – Yugyeong Lee

 

sketch

//Yugyeong Lee
//Section B
//yugyeonl@andrew.cmu.edu
//Project-07

var nPointsA= 600;
var nPointsB= 200;
var nPointsC= 800;
var x;
var y;
var constrainX;

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

function draw() {
	//ghosted background changing color based on mouseX
	var constrainX = constrain(mouseX, 0, width); //constraining mouseX in the page
	var r = map(constrainX, 0, width, 100, 39);
	var g = map(constrainX, 0, width, 43, 15);
	var b = map(constrainX, 0, width, 107, 54);
    background(r, g, b, 40);
    //Hypotrochoid & Ellipse
    push();
    translate(width/2, height/2);
    drawHypotrochoid();
    drawEllipse();
    pop();
    //Ranunculoid (only appears if mouseX is on left three quarter of page)
    if (constrainX < 3*width/4) {
   		push();
    	translate(width/2, height/2);
    	//mapping the angle of rotation based on mouseX
    	var angle = map(constrainX, 0, width, 0, 4 * TWO_PI);
		rotate(angle);
    	drawRanunculoid();
    	pop();
    }
}

function drawHypotrochoid() {
    constrainX = constrain(mouseX, 0, width); //constraining mouseX in the page
	var n = map(constrainX, 0, width, 0, .5);
    var a = 225;
    var b = n*a;
    var h = constrain(mouseY/2, 0, b);

    noFill();
    //change strokeWeight based on mouseX
    var s = map(constrainX, 0, width, .1, 2);
    //change stroke color based on mouseX
    var c = map(constrainX, 0, width, 255, 100);
    stroke(c)
    strokeWeight(s);
	beginShape()
		for (var i = 0; i < nPointsA; i++) {
			var t = map(i, 0, nPointsA, 0, 6*TWO_PI);
			x = (a - b)*cos(t) + h*cos((a - b)/b*t);
			y = (a-b)*sin(t) + h*sin((a-b)/b*t);
			vertex(x, y);
		}
	endShape(CLOSE);
 }

 function drawRanunculoid() {
    constrainX = constrain(mouseX, 0, width); //constraining mouseX in the page
    var a = 30;
    noStroke();
    //change fill oppacity based on mouseX
    var opacity = map(constrainX, 0, width, 10, 50);
    fill(255, 255, 255, opacity);
	beginShape()
		for (var i = 0; i < nPointsB; i++) {
			var t = map(i, 0, nPointsB, 0, TWO_PI);
			x = a*(6*cos(t)-cos(6*t));
			y = a*(6*sin(t)-sin(6*t));
        	ellipse(x, y, 5, 5); //ellipse at each points
		}
	endShape(CLOSE);
 }

function drawEllipse() {
    constrainX = constrain(mouseX, 0, width); //constraining mouseX in the page
    var a = 270;
    var b = 270;
    noFill();
	beginShape()
		for (var i = 0; i < nPointsC; i++) {
			var t = map(i, 0, nPointsC, 0, 6*TWO_PI);
			x = a*cos(t);
			y = b*sin(t);
			//ellipse at random position x and y range
        	ellipse(x+random(-50, 50), y+random(-50, 50), 3, 3);
		}
	endShape(CLOSE);
 }

I used three different curves for this interactive design: hypotrochoid, ranunculoid, and ellipse. The final product is interactive in that not only does the design react to position Y of the mouse location, the curves, the angle it rotates, stroke weight, stroke color, stroke opacity and background color all react to position X of the mouse location. Because of the circular movement of the other two curves, I wanted to create a “night-sky-with-blinking-stars” effect through creating an ellipse in which points are randomly positioned within a limited range with white blinking circles. The color palette was also chose to reflect the night sky atmosphere.

how Hypotrochoid & Ranunculoid works

aerubin-Project-06-Curves

For this project, I was inspired by the polar curves we learned in calculus. I remember drawing them on the graphing calculator and adding them together to make cool designs. This polar curve reminds me of part of a flower, so I rotated it around itself to create one. The flower grows when the mouse is moved from left to right, and the number of petals change when the mouse is moved from top to bottom. In addition, I also added a bee that bounces around to establish the flower design. The bee can also be hidden behind the flower if the mouse is far enough to the right.


Equation to the polar curve pictured above and utilized to make the petals for the flower.

sketch

//Angela Rubin
//Section C
//aerubin@andrew.cmu.edu
//Project-07-Curves

var turn = 0;
var beeX = 200; //x position of bee
var beeY = 200; //y position of bee
var xvel = 0;
var yvel = 0;

function setup() {
    createCanvas(400, 400);
    xvel = random(-4,4); //x velocity of bee
    yvel = random(-4,4); //y velocity of bee
    frameRate(5);
}

function draw() { 
    background(178, 216, 203);

    //moves bee
    push();
    translate(beeX-200, beeY-200);
    makeBee();
    pop();

    beeX+= xvel;
    beeY+= yvel;

    //makes bee bounce off edges
    if (beeX<35 || beeX>375) {
        xvel = -xvel;
    }

    if (beeY<50 || beeY>375) {
        yvel = -yvel;
    }

    //makes the curve repeat around itself to make a flower
    fill(249, 212, 222);
    stroke(255);
    push();
    translate(width/2, height/2);
    //mouseY controls the number of times the curve is repeated
    for (var rot = 0; rot < 360; rot+= 45-mouseY/40) {
        makeFlower(rot);
    }
    pop();
}

function makeFlower(turn) {
    //mouseX controls the size of the flower
    var a = 10 + mouseX/4;
    beginShape();
    rotate(radians(turn));
    for(var t = 0; t < 2*TWO_PI; t+= .01) {
        //equation for curve
        var r = a*sin(t)+(a*sin(5*(t/2)));
        //polar curve to x,y plane equation
        var x = r*cos(t);
        var y = r*sin(t);
        vertex(x, y);
    }
    endShape();
}

function makeBee() {
    strokeWeight(1);
    stroke(0);

    //wings
    push();
    fill(228-20, 242-20, 251-10);
    rotate(radians(-20));
    ellipse(120, 230, 20, 40);
    pop();

    push();
    fill(228, 242, 251);
    rotate(radians(20));
    ellipse(200+50, 230-140, 20, 40);
    pop();

    //body of bee
    fill(253, 190, 44);
    ellipse(200, 200, 50, 40);

    //stinger of bee
    fill(0);
    triangle(175, 195, 175, 205, 165, 200);

    //eye
    ellipse(220-7, 198, 7, 7);

    //stripes
    noFill();
    strokeWeight(3);
    stroke(0);
    arc(160, 210-8, 70, 70, 12, 13);
    arc(160+10, 210-7, 70, 70, 12-.1, 13);
    arc(160-10, 210-7, 70, 70, 12+.1, 13-.1);

    //smile
    strokeWeight(2);
    arc(220, 210-8, 20, 20, 1.5, 2.5);

    //antennae
    arc(220+5, 210-20, 20, 20, 3.7, 4.5);
    arc(220+5+3, 210-20+2, 20, 20, 3.7, 4.5);

    //legs
    arc(220-30, 210+20-6, 20, 10, 12.7-.5, 13.5-.7);
    arc(220-30+6, 210+20-6, 20, 10, 12.7-.5, 13.5-.7);
    arc(220-30-6, 210+20-6-2, 20, 10, 12.7-.5, 13.5-.7);
    arc(220-30-12, 210+20-6-4, 20, 10, 12.7-.5, 13.5-.7);
}

ikrsek-SectionC-Project-07-Curves

http://mathworld.wolfram.com/SphericalSpiral.html

sketch

//Isadora Krsek
//Ikrsek@andrew.cmu.edu
//Section C
//Project 07: Curves

var x; 
var y; 
var z; 

function setup() {
    createCanvas(400, 400);
    noStroke();
}
 
function draw() {
    background(0);
    //adjusting placement & size of curves
    translate(width/2, height/2);
    scale(150)
    limit = (map(mouseX, 0, width, 2, 8)); //caps the # of loops
    limit2 = (map(mouseY,0,height,20, 80)) //caps the # of loops
    push();
    scale(3,3)
    rotate(radians(90));
    push();
    rotate(mouseY,0,height,0,360)
    drawLoxoB();
    pop();
    drawLoxo();
    pop();
}


function drawLoxo() {
  //a controls how many strokes there are in terms of representing the loxodrome
    for (var a=.4; a<limit; a+=.2) {  
    //color change mapped to a
      var rValue = (map(a, 0.4, 4, 0, 360))
      fill(rValue);
      beginShape(QUADS);   
      for (var t = -20; t <limit2; t+=.1) {
        x = ((cos(t))/(sqrt(1+pow(a,2)*pow(t,2))));
        y = ((sin(t))/(sqrt(1+pow(a,2)*pow(t,2))));
        vertex(x, y);
      }
      endShape();
    } 
}

function drawLoxoB() {
  for (var a=.4; a<limit; a+=.2) { 
    var rValue = (map(a, 4, 0.4, 0, 360)) 
    fill(rValue);
    beginShape(QUAD_STRIP);   
    for (var t = -20; t <limit2; t+=.1) {
      x = ((cos(t))/(sqrt(1+pow(a,2)*pow(t,2))));
      y = ((sin(t))/(sqrt(1+pow(a,2)*pow(t,2))));
      vertex(x, y);
    }
    endShape();
  } 
}

I was looking at a few different curves but was most inspired by the loxodrome which I decided to try to replicate 2-dimensionally.

I wanted to create something a little haunting, but still somewhat visually exciting in the spirit of October, and as a result this is what I came up with. It brings to mind for me, the headlight of a train as it’s running towards you inside of a tunnel.

 

 

juyeonk-Project-07-Curves-Section E

sketch

//Claire Koh
//Section E
//juyeonk@andrew.cmu.edu
//Project-07


function setup() {
    createCanvas(480, 480); //sets the size of the canvas 
}


function draw() {
    background(0);
    translate(width/2, height/2); //so that the shapes would begin from the center of the canvas
    drawStar();
    drawRose();
}


//this function will generate the outer shape. There is no specific name for this curve. I invented this 🙂 Also it's called drawStar because it'll draw a star if you move your mouse towards the furthermost right side of the canvas. 
function drawStar() {
    var flicker = random(240, 255); //will be used to make the star flicker 
    var transparency = random(100,200); //also will be used to make the star flicker by controlling its transparency
    var gradient = map(mouseX, 0, width, 0, 255)
    var a = constrain(mouseX, 50,480);
    var n = constrain(mouseX, 50,480);
    
    if (a != 480) {
        push();
        rotate(mouseY/300);
        fill(0);
        strokeWeight(0.7);
        stroke(200,255-gradient,255-gradient);
        beginShape();
            for (var t=0; t <= 2 * PI; t+= PI/100) {
                var x = 0.5 * a * cos(n * t); 
                var y = 0.5 * a * sin(n * t); 
                vertex(x, y);
            }  
        endShape();
    }
    
    
    //when the a value of the equation reaches 480, the curve's stroke color and fill color will change
    else {
        push();
        rotate(mouseY/300);
        fill(flicker, 200, 200, transparency);
        strokeWeight(2);
        stroke(255);
        beginShape();
            for (var t=0; t <= 2 * PI; t+= PI/100) {
                var x = 0.5 * a * cos(n * t); 
                var y = 0.5 * a * sin(n * t); 
                vertex(x, y);
            }  
        endShape();
        pop();
    }
}
    


//this function will draw the fixed rose in the middle of the canvas
function drawRose() {
    //http://mathworld.wolfram.com/Rose.html
    var a = map(mouseX, 0, width, 0, 40);
    var n = map(constrain(mouseX, 0, width), 0, width, 0 , 6);
    var r;
    
    noFill();
    strokeWeight(1);
    stroke(255);
    
    push();
    rotate(mouseY/300)
    beginShape(); // will draw the rose shape in the middle 
        for (var t=0; t <= 2 * PI; t+= PI/100) {
            r = a*sin(n*t);
            x = r * cos(t);
            y = r * sin(t)
            vertex(x,y);
        }
    endShape();
    pop();
    
}



For this project I wanted to create a set of symmetrical curves that are somewhat related to each other for the sake of aesthetics and clarity.

The shapes starts with a square and a point in the very middle. But as you move your mouse sideways you’ll notice the outer curve changes to a drastic degree while all the inner curve is doing is just drawing more rose petals at a time. The outer shape doesn’t have a specific name; it was a result of an incorrect rose petal function but I am satisfied at how it turned out because of the variety of shapes it could create.
I added a bit of fun by making the star flicker at the end when the outer shape is complete.

(Final form)

 

 

hqq – secE – project 07 – curves

hamza

//hamza qureshi
//hqq@andrew.cmu.edu
//section e
//project 07 - curves

function setup(){
    createCanvas(480,480);
    angleMode(DEGREES);
}

function draw(){
    background(130,120,150);
    stroke(40,40,60);
    strokeWeight(0.25);
    noFill();
    translate(width/2,height/2); //moves shapes to center of canvas
    drawEpitrochoid(); //calls function to draw epitrochoid
    stroke(200,200,240);
    drawHypotrochoid(); //calls function to draw hypotrochoid
}

function drawEpitrochoid(){
    var p = width/2; //variable to call bounds of rotational shift
    var a = map(mouseX,0,width,0,40); //remaps x-value of mouse location to adjust center diameter
    var b = map(mouseY,0,height/2,0,80); //remaps y-value of mouse location to adjust radius of petals
    var h = 75; //number of lines
    beginShape();
    for (var i = 0; i < p; i++){
        var t = map(i,0,mouseX/30,0,360); //remaps i-value to correspond angularly
        var x = (a + b) * cos(t)-h*cos(t*(a+b)/b); //equations for epitrochoid
        var y = (a + b) * sin(t)-h*sin(t*(a+b)/b);
        vertex(x,y);
        endShape();
    }
}

function drawHypotrochoid(){
    var p = width/2;//variable to call bounds of rotational shift
    var a = map(mouseX,0,width,0,10); //remaps x-value of mouse location to adjust center diameter
    var b = map(mouseY,0,height/2,0,20);//remaps y-value of mouse location to adjust radius of petals
    var h = 50;//number of lines
    beginShape();
    for (var i = 0; i < p; i++){
        var t = map(i,0,mouseX/15,0,360); //remaps i-value to correspond angularly
        var x = (a + b) * cos(t) + h*cos(t*(a+b)/b);//equations for hypotrochoid
        var y = (a + b) * sin(t) - h*sin(t*(a+b)/b);
        vertex(x,y);
        endShape();
    }
}

In my exploration of a dynamic image using curve functions, I chose to draw an epitrochoid and a hypotrochoid. I appreciated the fact that both shapes are essentially inverses of each other. I wanted to also work the algorithms so that one would sit within the other, but the smaller one would increase in size less exponentially than the larger one. This creates an interesting sequence of shapes that produces a variety of silhouettes of the outer curve shape while maintaining a consistently shaped interior shape.

selinal-Project-07

sketch

//Selina Lee
//Section C
//selinal@andrew.cmu.edu
//Project-07

var nPoints = 70; //amount of elements
var Cissoid = 0; //http://mathworld.wolfram.com/CissoidofDiocles.html
var Conchoid = 0; //http://mathworld.wolfram.com/ConchoidofdeSluze.html

var titles = ["1. Cissoid", "2. Conchoid"];
var curveMode = Cissoid;

function setup() {
    createCanvas(480, 480);
    frameRate(10);
}

function draw() {
	background(255, 160, 60);  //orange background

	translate(240, 240); //place objects or focus on middle
	drawConchoidCurve(); //draw green and pink curves in back
	drawCissoidCurve(); //circles and blue lines in front
     
	
}

function drawCissoidCurve() {
	var x; //defining normal plane variables
	var y;

	var a1 = mouseX/20; //containing area of mouse interaction based on size or stretch of curves
	var a2 = mouseY/70;

	stroke(130, 130, 255); //blue lines
	strokeWeight(.5);
	beginShape(); //creating visuals based on Cissoid of Diocles curve
	for (var i = 0; i < nPoints; i++) {
		var t = map(i, 0, nPoints, 0, TWO_PI); //making i obtain to angle which is t 

		x = (10 * a1 * sq(t)) / (1 + sq(t)); //formulas for x and y of curve
		// 10 for x and 20 for y were used as constant values based on the composition attained in the index
		y = (20 * a2 * sq(t) * t) / (1 + sq(t));

		
		fill(250, 240, 220); //off white filling

		vertex(x, y); //draws single curve in normal direction for x and y on an index
		vertex(-x, y); //after adding this vertex, i noticed a greater variation and extension of the curves and lines so I continued this process
		vertex(x, -y);
		vertex(-x, -y);
		

		for(var ext = 0; ext < x; ext++) { //creating visuals deviating away from the lines but controlled by the same curve

			push(); //contain colors in this for loop not the colors also belonging to the blue line series
			fill(150, 255, 200); //green fill
			ellipse(ext * 10, -y * 5, 10, 10);  //greenish/aqua series of ellipses on top right and bottom left
			ellipse(-ext * 10, y * 5, 10, 10);

			fill(255, 120, 160); //reddish fill
			ellipse(ext * 15, -y * 19, 20, 20); //ellipses accompanying the ones in code written above
			ellipse(-ext * 15, y * 19, 20, 20);
	        pop();
		}

	}
	endShape(CLOSE);
}

function drawConchoidCurve() {
	var x2; //defining second x and y plane variables
	var y2;

	var b1 = mouseX; //containment of lines based on mouse interaction
	var b2 = mouseY;

	stroke(255, 100, 255); //magenta strokes
	strokeWeight(2); //thicker stroke
	beginShape();
	for (var j = 0; j < nPoints; j++) { 
		var ang = map(j, 0, nPoints, 0, TWO_PI); //setting the angle value same as var t in the first for loop for the Cissoid of Diocles curve

		x2 = ((1 / cos(ang)) + b1 * cos(ang)) * cos(ang); //formulas for Conchoid de Sluze curve	
        y2 = ((1 / cos(ang)) + b2 * cos(ang)) * sin(ang);

        fill(200, 255, 50); //lime green fill

        vertex(x2, y2); // this initial curve also only gave be one shape at first which looked like a flower petal from the center of the frame
        //this shape seemed more centered rather than side oriented like the Cissoid function so I experimented with on other vertex implementation focusing on the center of x
        vertex(-x2, y2); //created an inkblot array type of line series, more angular than round
        

        push(); // so that other functions not used before like noFill only affect these two vertex
        noFill(); //no fill so there is no overwhelming green
        vertex(x2 * 10, y2 * 10); //creating wider and bigger curve series of the same physical orientation and interaction
        vertex(-x2 * 10, y2 * 10);
        pop();
    }
    endShape(CLOSE);


}

sijings-project07-Composition with Curves

sijings-07


//Clair(sijing) Sun
//session C
//sijings@andrew.cmu.edu
//Assignment-06-compositionwithCurve

var t=0;
var r=60;
var curveP1;
var curveP2;
var color1=141;
var color2=141;

function setup() {
  createCanvas(480, 480);
}
 
function draw() {
  var t=map(mouseY, 0, height/4, height/2, height/4);//constrain it between hieght/2 and height/3
  background(156,170,164);
  noStroke();  
  var limit;//curve for determining how many times we want to rotate
  if (mouseX<width/2){
    limit=map(mouseX,0,width/2,0,16);
  }else{
    limit=map(mouseX, width/2, width,16,0);
  }
  for (var num=0;num<limit;num++){//set limit as our limit for iteration
    //leafs
    angleMode();
    fill(200,195,167);
    arc(50, 50, 140, 140, 180, 270,CHORD);//all used chord becuase we need to create
    arc(50, 80, 140, 140, 200, 270,CHORD);//a effect of leaves
    arc(width-50, height-50, 140, 140, 180, 270,CHORD);
    arc(width-50, height-80, 140, 140, 200, 270,CHORD);
    fill(104,103,78);
    arc(50, 70, 160, 140, 30, 0,CHORD);
    arc(60, -90, 260, 240, 190,40, CHORD);
    arc(width-50, height-30, 160, 140, 30, 0,CHORD);
    arc(width-50, height-90, 260, 240, 190,40, CHORD);
    fill(203,169,111,70);
    arc(30, -40, 260, 240, 190,40, CHORD);
    arc(20, 70, 140, 140, 180, 270,CHORD);
    arc(55, 115, 140, 140, 200, 270,CHORD);
    arc(width-150, height-90, 260, 240, 190,40, CHORD);
    arc(width-20, height-70, 140, 140, 180, 270,CHORD);
    arc(width-55, height-115, 140, 140, 200, 270,CHORD);
    fill(212,202,144);
    arc(50, 120, 240, 240, 200, 270,CHORD);
    arc(width-115, height-120, 240, 240, 200, 270,CHORD);
    fill(104,103,78,100);
    arc(-20, 90, 160, 140, 30, 0,CHORD);
    arc(20, -90, 260, 240, 190,40, CHORD);
    arc(width-80, height-90, 160, 140, 30, 0,CHORD);
    arc(width-80, height-90, 260, 240, 190,40, CHORD);

  //inner loop for drawing the actual curve
    for (var i=0;i<670;i++){
      r=mouseX/5;//set the radius to continue change
      if (num%4==0){//set different conditions for determing which direction we want
        var x=r*cos(t)*(1+cos(t));
        var y=r*sin(t)*(1+cos(t));
      }
      if (num%4==1){
        var x=r*cos(t)*(1-cos(t));
        var y=r*sin(t)*(1-cos(t));
      }
      if (num%4==2){
        var x=r*sin(t)*(1+cos(t));
        var y=r*cos(t)*(1+cos(t));
      }
      if (num%4==3){
        var x=r*sin(t)*(1-cos(t));
        var y=r*cos(t)*(1-cos(t)); 
      }
      t+=0.97;
      curveP1=width/2+num*2+x-12;//circles position x
      curveP2=height/2+num+y;//circles position y
      if (mouseX<width/2){
        var color1=map(mouseX, 0, width/2, 200, 74);//set conditions for changing color
        var color2=map(mouseX, 0, width/2, 121, 36);
      }else{
        var color1=map(mouseX, width/2, width, 80,200);
        var color2=map(mouseX, width/2, width, 35,121);
      }

      rotate(PI/5.0);//for rotating shape
      fill(255,color1,color2,255-mouseX/3);
      var size=map(mouseX,width/2,width,2,10);//also constrain size
      ellipse(curveP1,curveP2,size,size);
    } 

  }
  

}



sketch before starting the project

For this project, I wanted to express the idea a flower is blooming and then dying based on our mouse movement from left of the canvas to the right. So we can see there are changes of the number of petals (increase when mouseX approaching to the center of the canvas) and decreases when mouseX leaving the center of the canvas and going to the edge. With this movement, there are also changes in color, opacity, size, and the position of each dots. The audience can play this interactive work by rotating the flower and seeing how they can transform a flower from born to death. There are also some leaves being created for decoration. Here are some screenshots of the different states of the flower.

when the flower first appear, color-light orange
When flowers get bigger and curves appear, color becomes darker orange
when flower bloom and become orange red

The final state of the curves, which will be reduced to fewer curves

enwandu-Project-07-Curves

curves

// Emmanuel Nwandu
// enwandu@andrew.cmu.edu
// Section D
// Project-07-Curves

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

function draw() {
  background(0);
  translate(width/2, height/2);  // Center drawing on canvas
  drawEpitrochoid(); // Calls the function drawEpitrochoid
}

// Creates the geometry of the Epitrochoid curve
function drawEpitrochoid() {
    noFill();
    stroke(200, 0, 0);

    var points = 750;
    var x;
    var y;
    var h = constrain(mouseX, 0, 250)
    var a = 375;
    var b = a/constrain(mouseY, 0 , 250) //Constrains the width of geometry created
    // by the curves between the top and bottom edge of the canvas

    beginShape();
        for (var i=0; i < points; i++) {
            var t =map(i, 0, points, 0, TWO_PI);
            // Equation of epitrochoid applied to the x and y variables
            x = (a-b)*cos(t) + h*cos(((a-b)/b)*t)
            y = (a-b)*sin(t) + h*sin(((a-b)/b)*t)
            vertex(x, y);
        }
    endShape();
}

I ended up going for an Epitrochoid curve, but I bounced between that and the logarithmic spiral as an option. I played around with both, but ended up going for the Epitrochoid curve. I was initially confused about what parameters of the drawing would be controlled by what variables, but I played around with it for a while until I understood how my manipulation of the code influenced my drawing. I would suggest moving slowly across the canvas, in both x and y directions to see the full breadth of geometry generated by the code.

Source: http://mathworld.wolfram.com/Epitrochoid.html

jwchou-Project07-Curves

sketch 66

// Jackie Chou
// Section E
// jwchou@andrew.cmu.edu
// Project-07-Curves

function setup() {
    createCanvas(480, 480);
    frameRate(60);
    angleMode(DEGREES); //change angle mode
}

//goal: draw a flower with a center that pops up as the flower takes form
//then flower abstracts and center dissapears

function draw() {
    background(200, 210, 253);
    var R = map(mouseX, 0, width, 200, 255); //change stroke color of flower as mouseX changes
    var G = map(mouseX, 0, width, 140, 250);
    var B = map(mouseX, 0, width, 60, 130);

    drawRanunculoiud(); //draw curve function

    //flower center
    translate(-width/2, - height/2); //move flower center to center
    fill(170, 80, 130); 
    
    if (mouseX < 200 & mouseX > 50) {   //draw flower center when flower starts to be visible
    var ellipseSize = map(mouseX, 0, 200, 80, 0)
    noStroke();
    ellipse(width/2, height/2, ellipseSize, ellipseSize);
}

function drawRanunculoiud(){
    beginShape();
    noFill();
    stroke(R, G, B); 
    translate(width/2, height/2); //move curve to center


    for (var i = 0; i < width/5; i++){ //mouseX controls number of curves
        constrain(mouseX/3, 100, 300); //constrain mouseX

        var x;
        var y;

        var a = map(mouseX, 0, width, 30, 10);
        var t = map(i, 0, mouseX, 10, 360);

        //Ranunculoid http://mathworld.wolfram.com/Ranunculoid.html
 		x = a * (6 * cos(t) - cos(6 * t));
        y = a * (6 * sin(t) - sin(6 * t));
        vertex(x, y);

    endShape();
    }
}
}

For this project, I had a bit of a hard time implementing the equation. However, looking and actually studying the diagrams on the site helped me understand what each variable affected the curve.

I eventually created a Ranunculoid, which looks like a flower with 5 pedals. When the mouse moves to the right, the flower grows but then eventually abstracts. When the form looks like a flower, a center disk forms. However, when the form abstracts, the center disk dissappears.

The first three frames showcase the growth of the flower.


The next three frames showcase the abstraction.

eeryan-Project07-Curves

sketch

function setup() {
  createCanvas(400, 400);
  frameRate(10);
}


function draw() {
  background(245, 252, 99);
  // draw the frame
  fill(0);
  noStroke();
  stroke(1);

  // draw the curve
  push();
  translate(width / 2, height / 2);
  drawNeoid();
  pop();
}

function drawNeoid(){
  var x;
  var y;
  var ac = mouseX/50;
  var a = constrain(ac, 0.4, 80);//constrains variable to keep curve from scrunching too small
  var b = mouseY/100;
  noFill();
  stroke(0,0,255);
  strokeWeight(2);
  beginShape();
  for(var i = 0; i < width; i+=5){
    var t = map(i, 0, -10, 10, TWO_PI);//maps theta so curve expands and contracts smoothly
    x = cos(t) * (a * t + b);//parametric equation for neoid
    y = sin(t) * (a * t + b);//parametric equation for neoid
    vertex(x,y);
  }
  endShape(OPEN);
}

I started by playing with the epichondroid curve example code. By using the vertex command twice with differently ordered variables, I was able to render the curves in interesting ways. I then moved to playing around with a neoid curve, and by adjusting the for loop I was able to achieve the curve I ended up with.

These are examples of what the curve would have looked like if my for loop had added 5, 10, and 15 to i.