dynamicdrawing

/*
*Sadie Johnson
*15-104 Section C
*sajohnso@andrew.cmu.edu
*Project-03-Dynamic-Drawing
* This program creates an image based off mouse position

*/

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

function draw() {
    background(0);
    fill(mouseX/2,mouseY,mouseX/2);
//connecting lines t0 cursor
    stroke(mouseX/2);
    line(0, 0, mouseX, mouseY); // top left
    line(width, 0, mouseX, mouseY); //top right
    line(0, height, mouseX, mouseY); // bottom left
    line(width, height, mouseX, mouseY); // top left

//circle that follows cursor
    ellipse(mouseX, mouseY, 55, 55);

    fill(height-mouseY/2,width-mouseX,height-mouseY/2);
    ellipse(0,0,mouseX/2,mouseX/2); //top left
    ellipse(0,height,mouseX/2,mouseX/2); //bottom left
    ellipse(width,0,mouseX/2,mouseX/2); //top right
    ellipse(width,height,mouseX/2,mouseX/2); //bottom right

//rotating lines
    if (dist(width/2, height/2, mouseX, mouseY) > height/10) {
        stroke(225);
        strokeWeight(12);
        push();
        translate(mouseX, mouseY);
        rotate(millis()/mouseX/2);
        line(0,0,height,width);
        pop();  
        push();
        translate(mouseX, mouseY);
        rotate(millis()/mouseX/2);
        line(width,0,0,height);
        pop(); 
    }
}

The hardest part of this assignment for me was keeping track of which variables controlled which reactions, and fixing them accordingly when they didn’t work the way I wanted them to.

Leave a Reply