Project 7: Curves

Abstract roses using astroids and astroid evolutes. Astroids rotate using mouseX and scale using the minimum of mouseX and mouse Y. Random astroids are added to the canvas. The color of these depends on the mouse’s position on the canvas. If left on canvas they are red, and if on right of canvas they are black. Moving mouse along diagonals creates and in bottom right corner creates best shapes.

sketch – Copy – Copy – Copy
// Ana Furtado 
// Section E
// Project 7 Composition with Curves

var nPoints = 100;

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

function draw() {
    
    strokeWeight(3);

    //rotates and scales by mouse at top right
    //brown/red at left and bottom
    push();
    translate(width/4, height/4);
    scale(mouseX/width);
    rotate(radians(min(mouseX,mouseY)));
    drawAstroid();
    if (mouseX < width/2) {
        stroke('brown'); 
        rotate(radians(min(mouseX,mouseY)));
        drawAstroid();
    } 
    pop();

    //rotates and scales by mouse at bottom left
    //brown/red at left and bottom
    push();
    //translate(width/2, height/2)
    translate(width/4 * 3, height/4 * 3);
    scale(mouseX/width);
    rotate(radians(min(mouseX,mouseY)));
    drawAstroid();
    if (mouseX < width/2) {
        stroke('brown'); 
        rotate(radians(min(mouseX,mouseY)));
        drawAstroid();
    } if (mouseY > height/2) {
        stroke('brown'); 
        rotate(radians(min(mouseX,mouseY)));
        drawAstroid();
    }
    pop();

    //rotates and scales by mouse at random location 
    //move/leve mouse to left of canvas for red atroids 
    //move/leave mouse to right of canvas for black atroids 
    //move/leave in top right of canvas to fill with more black atroids
    push();
    translate(random(0,480), random(0,480));
    scale(0.5);
    rotate(radians(min(mouseX,mouseY)));
    drawAstroid();
    if ( mouseX < width/2) {
        stroke('brown'); 
        rotate(radians(min(mouseX,mouseY)));
        drawAstroid();
    }
    pop();

    

    //originals that stay in  splace
    //only show in beginning
    //scaled and rotated turns the astroid into an atroid evolute
    push();
    translate(width/2, height/2);
    drawAstroid();
    pop();

    //stays in place scale 0.5
    push();
    translate(width/2, height/2);
    scale(0.5);
    rotate(radians(45));
    drawAstroid();
    pop();

    //stays in place scale 0.25
    push();
    translate(width/2, height/2);
    scale(0.25);
    rotate(radians(45));
    drawAstroid();
    pop();

}

function drawAstroid() {
    //Astroid
    //https://mathworld.wolfram.com/AstroidEvolute.html

    var x;
    var y;
    var a = 300;

    //fill('pink');
    noFill();
    beginShape();
    for (var i = 0; i < nPoints; i++) {
        var t = map(i, 0, nPoints, 0, TWO_PI);
        //angleMode(DEGREES);
        x = a * (cos(t) * cos(t) * cos(t));
        y = a * (sin(t) * sin(t) * sin(t));
        vertex(x, y);
    }
    endShape(CLOSE);
    constrain(a, 0, 325);
}

I think the most difficult part of this was getting the shape to be represented properly.

Leave a Reply