Project 3 – Dynamic Drawing

sunsetbeach
// Yoo Jin Kim
// 15104 - section D
// yoojink1@andrew.cmu.edu
// Project-03

var wavy = 10;
var toggle = 0;
var bird = 255;

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

function draw() {
	//background - color changes from light blue to light purple as y-axis changes
	background(212 + mouseY / 50, 235 - mouseY / 53, 242 - mouseY / 49);

	//sun - size changes as y-axis changes 
	stroke(255);
	fill('#FFB7B2');
	ellipse(225, 418, min((mouseY), 260));

	//waves - position shift as y-axis changes 
	fill(255);
    var points = 5;
    var wav = wavy + mouseX / (width * 20);
    var step = mouseY / height * 100;

    beginShape();
    vertex(0, height);
    vertex(0, height / 1.5  + step);
    curveVertex(0, height / 1.5  + step);
    curveVertex(width / points, height / 1.5 + wav + step);
    curveVertex(2 * width / points, height / 1.5  - wav + step);
    curveVertex(3 * width / points, height / 1.5  + wav + step);
    curveVertex(4 * width / points, height / 1.5  - wav + step);
    curveVertex(5 * width / points, height / 1.5  + step);
    vertex(5 * width / points, height / 2 + step);
    vertex(width, height);
    vertex(0, height);
    vertex(0, height);
    endShape(CLOSE);

    //toggle when waves get high
    if (wav >= 15) {
    	toggle = 0;
    } else if (wav <= -15) {
    	toggle = 1;
    }

    //wave movement correction
    if (toggle == 0) {
    	wavy = wavy - 0.3;
    } else if (toggle == 1) {
    	wavy = wavy + 0.3;
    }

	//top right cloud - position shift as y-asis changes
	push();
	fill(255, 255, 255, 110);
	ellipse(440 - mouseY / 10, 320, (constrain(mouseY, 120, 320)), 25);
	pop();

	//bottom left cloud - position shift as y-axis changes
	fill(255, 255, 255, 100);
	ellipse(mouseY / 5.5, 370,(constrain(mouseY, 100, 340)), 20);

	//birds' right wings - birds move along with the mouse
	noStroke();
	fill(bird);
	arc(mouseX, mouseY, 20, 4, 0, PI + QUARTER_PI, PIE);
	arc(mouseX + 15, mouseY + 13, 20, 4, 0, PI + QUARTER_PI, PIE);
	arc(mouseX + 25, mouseY + 7, 20, 4, 0, PI + QUARTER_PI, PIE);
	arc(mouseX + 65, mouseY + 9, 20, 4, 0, PI + QUARTER_PI, PIE);
	arc(mouseX + 145, mouseY + 30, 20, 4, 0, PI + QUARTER_PI, PIE);

	//birds' left wings - birds move along with the mouse
	ellipse(mouseX - 4, mouseY - 3, 3, 10);
	ellipse(mouseX + 12, mouseY + 9, 3, 10);
	ellipse(mouseX + 22, mouseY + 3, 3, 10);
	ellipse(mouseX + 62, mouseY + 5, 3, 10);	
	ellipse(mouseX + 142, mouseY + 26, 3, 10);	

	//when the white birds go below the water, birds color changes to gray
	if (mouseY > 500) {
		bird = 205; 
	} else {
		bird = 255;
	}
}

At first, I wanted to create a realistic radial gradient sun, but the visuals did not turn out the way I expected; so I diverted direction and created a much simpler, more animated concept of the sunset beach.

Project-03 Dynamic Drawing

dynamic
function setup() {
    createCanvas(600, 450); 
    background(220);
    text("p5.js vers 0.9.0 test.", 10, 15);
}

function draw() { 
	background(0);
	noStroke();
	//boxes coming in from the right 
	fill(mouseY, 0, mouseX);
    rect(0, 0, mouseX, 50);
    fill(0, mouseY/2, mouseX/2);
    rect(0, 100, mouseX, 50);
    fill(mouseY/3, 0, mouseX/3);
    rect(0, 200, mouseX, 50);
    fill(0, mouseY, mouseX);
    rect(0, 300, mouseX, 50);
    fill(mouseY/2, 0, mouseX/2);
    rect(0, 400, mouseX, 50);

    //boxes coming in from the left 
    fill(255-mouseY, 0, 255-mouseX);
    rect(600, 50, -mouseX, 50);
    fill(0, 255-mouseY/2, 255-mouseX/2);
    rect(600, 150, -mouseX, 50);
    fill(255-mouseY/3, 0, 255-mouseX/3);
    rect(600, 250, -mouseX, 50);
    fill(0, 255-mouseY, 255-mouseX);
    rect(600, 350, -mouseX, 50);

    //boxes coming in from the top 
    fill(255-mouseY, 0, 255-mouseX);
    rect(0, 0, 50, mouseY);   
    fill(0, 255-mouseY/2, 255-mouseX/2);
    rect(120, 0, 50, mouseY); 
    fill(255-mouseY/3, 0, 255-mouseX/3);
    rect(240, 0, 50, mouseY);   
    fill(0, 255-mouseY, 255-mouseX);
    rect(360, 0, 50, mouseY);
    fill(255-mouseY/2, 0, 255-mouseX/2);
    rect(480, 0, 50, mouseY);

    //boxes coming in from the bottom 
    fill(mouseY, 0, mouseX);
    rect(60, 600, 50, -mouseY);  
    fill(0, mouseY/2, mouseX/2);
    rect(180, 600, 50, -mouseY);   
    fill(mouseY/3, 0, mouseX/3);
    rect(300, 600, 50, -mouseY);   
    fill(0, mouseY, mouseX);
    rect(420, 600, 50, -mouseY);
    fill(mouseY/2, 0, mouseX/2);
    rect(540, 600, 50, -mouseY);

    //moving origin point to the center 
    translate(300, 225);

    //rect & all ellipses rotate based on mouse 
    rectMode(CENTER);
    rotate(radians(mouseX));
    rect(0, 0, 100, 100);

    //ellipses change position based on mouse 
    ellipse(-100, mouseX, 30, 30);
    ellipse(mouseX, -100, 30, 30);

    //ellipses get bigger based on mouse 
    stroke(255);
    strokeWeight(3);
    noFill();
    ellipse(0, 0, mouseX, mouseY);
    stroke(100);
    ellipse(0, 0, -mouseX, mouseY);
    //rotated ellipses  
    rotate(radians(45));
    stroke(255);
    ellipse(0, 0, mouseX+20, mouseY);
    stroke(100);
    ellipse(0, 0, -mouseX+20, mouseY);

    rotate(radians(45));
    stroke(255);
    ellipse(0, 0, mouseX+50, mouseY);
    stroke(100);
    ellipse(0, 0, -mouseX+50, mouseY);

    rotate(radians(45));
    stroke(255);
    ellipse(0, 0, mouseX+90, mouseY);
    stroke(100);
    ellipse(0, 0, -mouseX+90, mouseY);
}

I was inspired by the shape of atoms. For the background, I was partly inspired by the way a tv looks when it glitches.

Inspiration image
Background inspiration image

Project 3 – Dynamic Drawing

sketch


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

function draw() {
    background(30, 30, 40);
    noStroke();
    translate(200, 200);
    let angle = mouseY;
    rotate(radians(angle));
    //rectangle
    translate(-200, -200);
    fill(221, 115, 115);
    var m = max(min(mouseX, 400), 0);
    var size = m * 350.0 / 400.0;
    rect(10 + m * 190.0 / 400.0, 200.0,
         size/2, size/2);
    fill(234, 217, 76);
    size = 350 - size;
    rect(200 + m * 190.0 / 400.0, 200.0,
         size/2, size/2);
    //circles
    fill(209, 209, 209);
    var m = max(min(mouseY, 400), 0);
     var size = m * 350.0 / 400.0;
    circle(10 + m * 190.0 / 400.0, 200.0,
         size/2);
    fill(81, 163, 163);
    size = 350 - size;
    circle(200 + m * 190.0 / 400.0, 200.0,
         size/2);
    //small circle
    var m = min(min(mouseX, 400), 0);
    var size = m * 350.0 / 400.0; 
    fill(100, 178, 200);
    size = 250 - size;
    circle(m * 190.0 / 400.0, 200.0,
         size/10);
    //small circle pink
    var m = min(min(mouseX, 400), 0);
    var size = m * 350.0 / 400.0; 
    fill(240, 178, 200);
    size = 250 - size;
    circle(width - (m * 190.0 / 400.0), height - (200.0),
         size/10);
    //vertex circles
     fill(59, 53, 97);
    var m = max(min(mouseY, 400), 0);
     var size = m * 350.0 / 400.0;
    circle((10 + m * 190.0 / 400.0) + 100, (200.0) + 100,
         size/5);
    fill(196, 224, 249);
    size = 350 - size;
    circle((200 + m * 190.0 / 400.0) - 100, (200.0) - 100,
         size/5);
    //other vertex circles
     fill(171, 73, 103);
    var m = max(min(mouseY, 400), 0);
     var size = m * 350.0 / 400.0;
    circle(width - ((10 + m * 190.0 / 400.0) + 100), height - ((200.0) + 100),
         size/5);
    fill(173, 246, 177);
    size = 350 - size;
    circle(width - ((200 + m * 190.0 / 400.0) - 100), height - ((200.0) - 100),
         size/5);

}

I was inspired by random movements of shapes and the pattern that could be formed from it. The color palette was a big factor in this project.

Project-03: Dynamic Drawing

I was somewhat inspired by the overlapping tonal shapes of the art of designer Verner Panton, so I decided to use a similar concept for building tonal shades through scaling, adapting to the mouse movements. The whole structure of the program runs off of one while loop to create the intervals in spacing, location, rotation, and scale that many of the objects have.

Verner Panton Art Prints for Any Decor Style | Society6
Verner Panton painting

mouseadaptiveart

var centerX = 300;
var centerY = 225;

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

function draw() {
	noStroke();
	background(255);
	rectMode(CENTER);
	let i =0;
	while(i<mouseX){
		noStroke();
//centered rectangle matrix
	fill(0,0,mouseX/3,20);
	rect(centerX,centerY,mouseX-i,mouseY-i); 
	rect(centerX,centerY,mouseY-i,mouseX-i);
//circles
    fill(255-(mouseY/3),0,255-(mouseX/3),10);
    //top left
	    ellipse(50,50,width-(mouseX-i),height-(mouseY-i));
	    ellipse(50,50,mouseY-i,mouseX-i);
	//top right
	    ellipse(550,50,width-(mouseX-i),height-(mouseY-i));
	    ellipse(550,50,mouseY-i,mouseX-i);
	//bottom right
	    ellipse(550,400,width-(mouseX-i),height-(mouseY-i));
	    ellipse(550,400,mouseY-i,mouseX-i);
	//bottom left
	    ellipse(50,400,width-(mouseX-i),height-(mouseY-i));
	    ellipse(50,400,mouseY-i,mouseX-i);
//gray bars
    fill(0,0,0,7);
    //left vert
        rect(150,centerY,300-(mouseY-(i/2)),height);
    //right vert
        rect(450,centerY,300-(mouseY-(i/2)),height);
//white bars
    fill(255);
    rect(centerX, centerY-i,width, i/20);
    rect(centerX, centerY+i,width, i/20);
//black twisting lines, use i to determine degree
    stroke(0);
    line(50,50+(i/2),550,400-(i/2));
    line(550-(i/2),50,50+(i/2),400);
	i+=50;
    }
//white ellipses
    strokeWeight(10);
    stroke(255);
    noFill();
    let j=0;
    while(j<15){
    	strokeWeight(5/j);
    	 ellipse(centerX, centerY+i,mouseX+(50*j), mouseX+(50*j));
    	 ellipse(centerX, centerY-i,mouseX+(50*j), mouseX+(50*j));
    	j++;
    }
}