Project 3: Dynamic Drawing

sketch.sl4Download
// Sarah Luongo
// Section A

function setup() {
    createCanvas(600, 450);
}

function draw() {
// To change background according to positon of mouse
var bkgrR = min(mouseY/4, 45);
var bkgrB = min(mouseX/4, 45);
var bkgrG = (bkgrR-bkgrB);

// To constrain motion of stars within canvas
var motionX = map(mouseX, 0, width, 0, 15);
var motionY = map(mouseY, 0, height, 0, 15);

// To change colors of stars	
var r = max(mouseX/1.8, 150);
var g = max(mouseY/1.8, 150);
var b = max((mouseY/1.8)-(mouseX/1.8), 150);
	
    // Fourth value gives background transparency - will make all stars have "following circles" that fade as the stars move (easier to see when you move the mouse really fast
    background(bkgrR, bkgrG, bkgrB, 45);
    
    // To get rid of cursor
    noCursor();

    // This circle is the new cursor shape
    fill(255, 255, 51); // yellow
    circle(mouseX, mouseY, 3);

    // Stars
    fill(r, g, b);
    circle(motionX, motionY, 8 * mouseX/560);
    circle(motionX + 320, motionY + 420, 6 * (mouseX/560 + mouseY/410));
    fill(r - 47, g - 27, b - 143);
    circle(motionX + 340, motionY + 19, 8 * (mouseX/560 + mouseY/410));
    circle(motionX + 233, motionY + 385, 9 * (mouseX/560 + mouseY/410));
    circle(motionX + 19, motionY + 347, 8 * (mouseX/560 + mouseY/410));
    fill(r + 84, g + 119, b - 78);
    circle(motionX + 40, motionY + 238, 10 * (mouseX/560 + mouseY/410));
    fill(r, g, b);
    circle(motionX + 405, motionY + 356, 7 * (mouseX/560 + mouseY/410));
    circle(motionX + 446, motionY + 395, 10 * (mouseX/560 + mouseY/410));
    circle(motionX + 23, motionY + 273, 8 * (mouseX/560 + mouseY/410));
    fill(r + 210 , g - 140, b + 37);
    circle(motionX + 172, motionY + 143, 6 * (mouseX/560 + mouseY/410));
    circle(motionX + 204, motionY + 297, 8 * (mouseX/560 + mouseY/410));
    circle(motionX + 198, motionY + 189, 10 * (mouseX/560 + mouseY/410));
    fill(r + 32, g + 130, b + 23);
    circle(motionX + 285, motionY + 302, 9 * (mouseX/560 + mouseY/410));
    circle(motionX + 534, motionY + 67, 10 * (mouseX/560 + mouseY/410));
    circle(motionX + 67, motionY + 45, 7 * (mouseX/560 + mouseY/410));
    fill(r, g, b);
    circle(motionX + 423, motionY + 227, 10 * (mouseX/560 + mouseY/410));
    circle(motionX + 367, motionY + 329, 7 * (mouseX/560 + mouseY/410));
    circle(motionX + 257, motionY + 348, 10 * (mouseX/560 + mouseY/410));
    fill(r - 190, g + 66, b - 15);
    circle(motionX + 73, motionY + 143, 9 * (mouseX/560 + mouseY/410));
    circle(motionX + 143, motionY + 324, 10 * (mouseX/560 + mouseY/410));
    circle(motionX + 300, motionY + 225, 8 * (mouseX/560 + mouseY/410));
    circle(motionX + 558, motionY + 420, 6 * (mouseX/560 + mouseY/410));
    circle(motionX + 340, motionY + 445, 9 * (mouseX/560 + mouseY/410));
    fill(r, g, b);
    circle(motionX + 510, motionY + 267, 10 * (mouseX/560 + mouseY/410));
    circle(motionX + 304, motionY + 130, 8 * (mouseX/560 + mouseY/410));
    circle(motionX + 229, motionY + 38, 7 * (mouseX/560 + mouseY/410));
    circle(motionX + 512, motionY + 106, 8 * (mouseX/560 + mouseY/410));
    fill(r - 190, g + 66, b - 15);
    circle(motionX + 429, motionY + 145, 9 * (mouseX/560 + mouseY/410));
    circle(motionX + 400, motionY + 73, 10 * (mouseX/560 + mouseY/410));
    circle(motionX + 172, motionY + 430, 6 * (mouseX/560 + mouseY/410));
    circle(motionX + 84, motionY + 443, 9 * (mouseX/560 + mouseY/410));
    circle(motionX + 117, motionY + 233, 10 * (mouseX/560 + mouseY/410));
    fill(r, g, b);
    circle(motionX + 545, motionY + 357, 8 * (mouseX/560 + mouseY/410));
    circle(motionX + 584, motionY + 167, 10 * (mouseX/560 + mouseY/410));
    circle(motionX + 448, motionY + 332, 7 * (mouseX/560 + mouseY/410));
    circle(motionX + 515, motionY + 207, 6 * (mouseX/560 + mouseY/410));
}

I’m very fascinated by stars and one of my favorite albums to listen to is an astronomy album by Sleeping At Last. I was inspired by this album, so I wanted to make this project kind of like space, but a little more fun. I wasn’t quite sure how to make a star shape, so I decided to makes circles as stars. My sketch is below:

Leave a Reply