Jonathan Perez Project 3

sketch



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

function draw() {
    background(255);
    fill(255);
    stroke(0);
    ellipse(width/2, height/2, 50, 50); //outer center ring

    translate(width/2, height/2);
    for (var i = 0; i < 8; i++) { //ring of 8 diamonds

        //first ring
        push();
        var mouseDist = dist(mouseX, mouseY, width/2, height/2); //mouse distance from center
        var bright = 225 - 225 * mouseDist * 1/230; //alters shade from 0 to 225 of the diamonds to be darker as they approach center
        var scaleAmount = 1.75 - 1.75 * mouseDist * 1/230; //scales diamonds from 0 to 1.75 to be larger as they move outwards
        if (mouseX > 240) {
            rotate(-acos((mouseY - height/2)/mouseDist)/2 + TWO_PI * i/8); //sets angular distance between diamonds, and rotates proportional to mouse angle
        }
        else {
            rotate(acos((mouseY - height/2)/mouseDist)/2 + TWO_PI * i/8); //accounts for the face that arccos switches direction at PI/2 and 3PI/2
        }
        if (mouseDist < 230) { //expands and contracts diamonds until just before edge of canvas
           translate(100 - 100 * mouseDist * 1/230, 0); //diamonds move towards center as mouse moves away proportional to original translation
       }
        fill(bright);
        if (mouseDist < 230) { //if statement used so that scaling does not increase after value reaches zero
            scale(scaleAmount);
            quad(0, 10, -45, 0, 0, -10, 45, 0); //diamond
        } else {
            fill(0);
            ellipse(0,0,40,40); //center circle
        }
        pop()
        //simplified comments will be used for further iterations of the ring of diamonds, refer to first ring for more info
        //second ring of diamonds
        push();
        if (mouseX > 240) { //rotation related to mouse
            rotate(acos((mouseY - height/2)/mouseDist)/4 + TWO_PI * i/8 + PI/8);
        }
        else {
            rotate(-acos((mouseY - height/2)/mouseDist)/4 + TWO_PI * i/8 + PI/8);
        }
        if (mouseDist < 230) { //distance from center related to mouse
           translate(155 - 155 * mouseDist * 1/230, 0);
       }
        fill(bright + 40); //shading related to distance from center/mouse
        if (mouseDist < 230) {
            scale(scaleAmount - .1); //scaling of diamond related to distance from center
            quad(0, 10, -45, 0, 0, -10, 45, 0); //diamond
        } else {
            fill(0);
            ellipse(0,0,40,40); //black center
        }
        pop();

        //first half of third ring of diamonds 
        push();
        if (mouseX > 240) { //rotation related to mouse
            rotate(-acos((mouseY - height/2)/mouseDist)/8 + TWO_PI * i/8 + PI/16); 
        }
        else {
            rotate(acos((mouseY - height/2)/mouseDist)/8 + TWO_PI * i/8 + PI/16); 
        }
        if (mouseDist < 230) { //distance from center related to mouse
           translate(210 - 210 * mouseDist * 1/230, 0); 
       }
        fill(bright + 80); //shading related to distance from center/mouse
        if (mouseDist < 230) { 
            scale(scaleAmount - .2); //scaling of diamond related to distance from center
            quad(0, 10, -45, 0, 0, -10, 45, 0); //diamond
        } else {
            fill(0);
            ellipse(0,0,40,40); //black center
        }
        pop();

        //second half of third ring of diamonds 
        push();
        if (mouseX > 240) { //rotation related to mouse
            rotate(-acos((mouseY - height/2)/mouseDist)/8 + TWO_PI * i/8 + 3*PI/16);
        }
        else {
            rotate(acos((mouseY - height/2)/mouseDist)/8 + TWO_PI * i/8 + 3*PI/16); 
        }
        if (mouseDist < 230) { //distance from center related to mouse
           translate(265 - 265 * mouseDist * 1/230, 0); 
       }
        fill(bright + 80); //shading related to distance from center/mouse
        if (mouseDist < 230) { 
            scale(scaleAmount - .2); //scaling of diamond related to distance from center
            quad(0, 10, -45, 0, 0, -10, 45, 0); //diamond
        } else {
            fill(0);
            ellipse(0,0,40,40); //black center
        }
        pop();

        //fourth ring first part
        push();
        if (mouseX > 240) { //rotation related to mouse
            rotate(acos((mouseY - height/2)/mouseDist)/8 + TWO_PI * i/8 + PI/16);
        }
        else {
            rotate(-acos((mouseY - height/2)/mouseDist)/8 + TWO_PI * i/8 + PI/16);
        }
        if (mouseDist < 230) { //distance from center related to mouse
           translate(320 - 320 * mouseDist * 1/230, 0); 
       }
        fill(bright + 110); //shading related to distance from center/mouse
        if (mouseDist < 230) { 
            scale(scaleAmount - .25); //scaling of diamond related to distance from center
            quad(0, 10, -45, 0, 0, -10, 45, 0); //diamond
        } else {
            fill(0);
            ellipse(0,0,40,40); //black center
        }
        pop()

         //fourth ring second part
        push();
        if (mouseX > 240) { //rotation related to mouse
            rotate(acos((mouseY - height/2)/mouseDist)/8 + TWO_PI * i/8 + 3*PI/16); 
        }
        else {
            rotate(-acos((mouseY - height/2)/mouseDist)/8 + TWO_PI * i/8 + 3*PI/16);
        }
        if (mouseDist < 230) { //distance from center related to mouse
           translate(320 - 320 * mouseDist * 1/230, 0);
        }
        fill(bright + 110); //shading related to distance from center/mouse
        if (mouseDist < 230) {
            scale(scaleAmount - .25); //scaling of diamond related to distance from center
            quad(0, 10, -45, 0, 0, -10, 45, 0); //diamond
        } else {
            fill(0);
            ellipse(0,0,40,40); //black center
        }
        pop()

        //fifth ring first part
        push();
        if (mouseX > 240) { //rotation related to mouse
            rotate(-acos((mouseY - height/2)/mouseDist)/8 + TWO_PI * i/8 + PI/8);
        }
        else {
            rotate(acos((mouseY - height/2)/mouseDist)/8 + TWO_PI * i/8 + PI/8);
        }
        if (mouseDist < 230) { //distance from center related to mouse
           translate(375 - 375 * mouseDist * 1/230, 0);
        }
        fill(bright + 120); //shading related to distance from center/mouse
        if (mouseDist < 230) {
            scale(scaleAmount - .3); //scaling of diamond related to distance from center
            quad(0, 10, -45, 0, 0, -10, 45, 0); //diamond
        } else {
            fill(0);
            ellipse(0,0,40,40); //black center
        }
        pop()

        //fifth ring second part
        push();
        if (mouseX > 240) { //rotation related to mouse
            rotate(-acos((mouseY - height/2)/mouseDist)/8 + TWO_PI * i/8 + 4*PI/16);
        }
        else {
            rotate(acos((mouseY - height/2)/mouseDist)/8 + TWO_PI * i/8 + 4*PI/16);
        }
        if (mouseDist < 230) { //distance from center related to mouse
           translate(375 - 375 * mouseDist * 1/230, 0);
        }
        fill(bright + 120); //shading related to distance from center/mouse
        if (mouseDist < 230) {
            scale(scaleAmount - .3); //scaling of diamond related to distance from center
            quad(0, 10, -45, 0, 0, -10, 45, 0); //diamond
        } else {
            fill(0);
            ellipse(0,0,40,40); //black center
        }
        pop()

    }
    fill(0);
    ellipse(0,0,40,40); //black circle over diamonds

}

I honestly had no idea what I was going to do with this project. Given that, the creative process was pretty interesting. Honestly, the only thing I was going off of to begin with was that I wanted the diamond shape to be a central theme of the drawing. After that, the rest of the ideas sort of haphazardly tumbled together. The diamond shape led me to a sort of stylized star/space concept, so then I knew I wanted to work with concentric circles rotating alternately. Once I started drawing those, the way the circles condensed into a tight, compact star shape made me think of a supernova. So after that, I intentionally themed the drawing around a sort of explosive, supernova idea.

Although I had the theme all figured out, achieving that idea turned out to be pretty difficult. I had no idea how I was going to get the different rows of diamonds to rotate in regards to the mouses angle to the center of the canvas, not to mention to get them to rotate at different rates related the the mouses angle. The math was pretty tricky, but also I feel like that gives the code a sense of beauty. This was definitely the first thing that I have coded that I felt the code should be seen as well as the product. The code is just as much art.

If I had more time (and I might just go back and do this on my own time) I want to develop the background more. Give it a sense of depth, like a star in space.

ssontag-fireworks-Project-03-DynamicDrawing

For this project I let my knowledge of certain functions built into p5.js. I researched Perlin Noise and became pretty comfortable with the way it worked in conjunction with the rotate function to create a firework effect.

sketch


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

function draw() {
    background(220);
//these rectangles following are lined up one after the other 
//they follow the x value of the mouse, but are offset by the rectangles next to them
    fill(219, 112, 147);
    rect(mouseX + 525, 0, 300, 480);

    fill(176, 224, 230);
    rect(mouseX + 500, 0, 25, 480);

    fill(255, 218, 185);
    rect(mouseX + 350, 0, 150, 480);

    fill(135, 206, 250);
    rect(mouseX + 300, 0, 50, 480);

    fill(30, 144, 255);
    rect(mouseX, 0, 300, 480);

    fill(143, 188, 143);
    rect(mouseX - 100, 0, 100, 480);

    fill(255, 140, 0);
    rect(mouseX - 300, 0, 200, 480);

    fill(173, 216, 230);
    rect(mouseX - 350, 0, 50, 480);

    fill(224, 255, 255);
    rect(mouseX - 450, 0, 100, 480);

    fill(240, 128, 128);
    rect(mouseX - 750, 0, 300, 480);
 
//my goal was to modulate the position of the cirlces rotated around the translated orgin 
//in order to create a firework effect
//by using push, pop, and rotate i can make a circular array of ellipses
//by using the perlin noise i can make the circles ungulate based on the perlin noise number sequence
    translate(width/2, height/2);
        for (var i = 0; i < 16; i++) {
            push();
            rotate(TWO_PI * i / 16);
            var tx = 200 * noise(0.01*frameCount);
            translate(tx, 0);
            fill(255, 239, 213);
            ellipse(mouseX - 400, 0, 20, 20);
            translate();
            pop();
        }

        for (var i = 0; i < 8; i++) {
            push();
            rotate(TWO_PI * i / 8);
            var tx = 200 * noise(0.01*frameCount);
            translate(tx, 0);
            fill(102, 51, 153)
            ellipse(mouseX - 200, 0, 50, 50);
            translate();
            pop();
        }

//this translation puts a firework in the bottom right corner
    translate(width/2, height/2);
        for (var i = 0; i < 32; i++) {
            push();
            rotate(TWO_PI * i / 32);
            var tx = 200 * noise(0.01*frameCount);
            translate(tx, 0);
            fill(0, 128, 128);
            ellipse(mouseX - 200, 0, 10, 10);
            translate();
            pop();
        }
//this translation places a firework in the top left corner
    translate(-640, -480);
        for (var i = 0; i < 32; i++) {
            push();
            rotate(TWO_PI * i / 32);
            var tx = 200 * noise(0.01*frameCount);
            translate(tx, 0);
            fill(0, 128, 128);
            ellipse(mouseX - 200, 0, 10, 10);
            translate();
            pop();
        }


}


jwchou-project03-dynamicdrawing

sketch 285

//Jackie Chou
//Section E
//jwchou@andrew.cmu.edu
//Project-Week-03

var bkgndR = 241;
var bkgndG = 240;
var bkgndB = 120;
var appleR = 241;
var appleG = 98;
var appleB = 72;

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

function draw() {
	background(bkgndR, bkgndG, bkgndB);
	noStroke();

    push();
    //rotates apple at the end when mouseX >500
    if (mouseX > 500) {
        translate(670, -50);
        rotate(PI/2.01);
    }

	//stem   
	fill(96, 47, 7);
	beginShape();
	curveVertex(311, 176);
	curveVertex(325, 169);
	curveVertex(323, 137);
	curveVertex(333, 111);
	curveVertex(325, 99);
	curveVertex(315, 106);
	curveVertex(318, 115);
	curveVertex(315, 130);
	curveVertex(312, 146);
	curveVertex(312, 176);
	endShape();

	//apple
	fill(appleR - 0.046 * mouseX, appleG + 0.1109 * mouseX, appleB + 0.09166 * mouseX);
    beginShape();
    curveVertex(315, 149);
    curveVertex(308, 149);
    curveVertex(285, 143);
    curveVertex(257, 149);
    curveVertex(236, 161);
    curveVertex(201, 218);
    curveVertex(214, 311);
    curveVertex(273, 371);
    curveVertex(323, 373);
    curveVertex(354, 376);
    curveVertex(399, 358);
    curveVertex(443, 283);
    curveVertex(451, 236);
    curveVertex(430, 177);
    curveVertex(376, 141);
    curveVertex(338, 140);
    curveVertex(315, 149);
    endShape();

    //bite one when mouseX > 40
    if (mouseX > 40) {
      fill(bkgndR, bkgndG, bkgndB);
      ellipse(440, 170, 80, 80);
    }

    //bite two when mouseX > 80
    if (mouseX > 80) {
      fill(bkgndR, bkgndG, bkgndB);
      ellipse(425, 230, 70, 90);
    }

    //bite three when mouseX > 20
    if (mouseX > 20) {
      fill(bkgndR, bkgndG, bkgndB);
      ellipse (200, 260, 70, 90);
    }

    //bite four when mouseX > 60
    if (mouseX > 60) {
      fill(bkgndR, bkgndG, bkgndB);
      ellipse (210, 290, 80, 60);
    }

    //bite five when mouseX > 200
    if (mouseX > 200) {
      fill(bkgndR, bkgndG, bkgndB);
      ellipse (430, 300, 100, 100);
    }

    //bite six when mouseX > 150
    if (mouseX > 150) {
      fill(bkgndR, bkgndG, bkgndB);
      ellipse (200, 160, 130, 130);
    }

    //bite seven when mouseX > 280
    if (mouseX > 280) {
      fill(bkgndR, bkgndG, bkgndB);
      ellipse (428, 270, 120, 90);
    }

    //bite eight when mouseX and seed one > 320
    if (mouseX > 320) {
      fill(bkgndR, bkgndG, bkgndB);
      ellipse (210, 250, 110, 100);
      fill(140, 98, 57);
      ellipse (300, 235, 12, 25);
    }

    //bite nine and seed two when mouseX > 400
    if (mouseX > 400) {
      fill(bkgndR, bkgndG, bkgndB);
      ellipse (215, 300, 96, 96);
      fill(140, 98, 57);
      ellipse (315, 255, 12, 25);
    }

    //bite ten and seed three when mouseX > 450
    if (mouseX > 450) {
      fill(bkgndR, bkgndG, bkgndB);
      ellipse (415, 160, 90, 105);
      fill(140, 98, 57);
      ellipse (325, 225, 12, 25);
    
    }
    pop();




}

For this project, I started with an idea that I would have a plane take off and land as mouseX moved from left to right. However, I realized that I probably did not have the coding skill to pull it off successfully because I didn’t know how to make a complex object expand/shrink in size.

I was thinking of a good chronological visual, and the idea of having an apple being eaten made sense to me. I used mouseX and background-colored ellipses to convey bites being taken out of the apple. I tried making the background change color as well, but it ultimately distracted from the apple.

nayeonk1-Project03-Dynamic Drawing

nayeon_DynamicDrawing

//Na-yeon Kim
//15-104, B section
//nayeonk1@andrew.cmu.edu
//Project-03 (Dynamic Drawing)


var angle = 0;
var dia = 0;


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

function draw() {

//background color changing with mouse
    var bgR = map(mouseY, 0, height, 50, 100);
    var bgG = map(mouseX, 0, height, 150, 250);
    var bgB = map(mouseY, 0, height, 100, 200);

    background(bgR, bgG, bgB);

//size changing rect
    noStroke();
    fill(bgR + 100, bgG + 100, bgB + 100);
    rect(0, 0, (mouseX / 2), (mouseY / 2));
    fill(bgR - 100, bgG - 100, bgB - 100);
    rect(100, 100, (mouseX / 2), (mouseY / 2));
    fill(bgR - 50, bgG, bgB + 100);
    rect(200, 200, (mouseX / 2), (mouseY / 2));
    fill(bgR, bgG + 100, bgB + 200);
    rect(300, 300, (mouseX / 2), (mouseY / 2));


//another bg frame
    var x = 50;
    var y = 100;
    var w = 380;
    var h = 440;

    noStroke();
    if ((mouseX > x) & (mouseX < x+w) && (mouseY > y) && (mouseY < y+h)) {
      fill(0, 250);
    } else {
      fill(255, 0);
    }
    rect(x, y, w, h);

//rotating rect
    if ((mouseX > x) & (mouseX < x+w) && (mouseY > y) && (mouseY < y+h)) {
      fill(bgR, bgG, bgB);
    } else {
      fill(255, 0);
    }
    push();
    translate((width / 2), (height / 2));
    rotate(radians(angle));
    rectMode(CENTER);
    rect(0, 0, (mouseX / 2), (mouseY / 2));
    pop();
    angle = angle + 20;

//lines
    var wL = 50;
    var wR = 430;
    var hU = 100;
    var hB = 540;

    var xc = constrain(mouseX, wL, wR);
    var yc = constrain(mouseY, hU, hB);

    if ((mouseX > x) & (mouseX < x+w) && (mouseY> y) && (mouseY < y+h)) {
      stroke(255);
    } else {
      stroke(0);
    }

    strokeWeight(8);
    line((width / 2), (height / 2), xc, yc);
    var max = map(mouseX, 0, xc, yc, 100);
    line((width/ 2), (height / 2), max, yc);
    var max = map((mouseX * 0.5), 0, xc, yc, 200);
    line((width/ 2), (height / 2), max, yc);
    var max = map((mouseX * 2), 0, xc, yc, 50);
    line((width/ 2), (height / 2), max, yc);

// cursur - spinning rect
    push();
    rectMode(CENTER);
    if ((mouseX > x) & (mouseX < x+w) && (mouseY> y) && (mouseY < y+h)) {
      fill(255);
    } else {
      fill(0);
    }
    noStroke();
    translate(mouseX, mouseY);
    rotate(radians(angle * 10));
    rect(0, 0, 30, 30);
    pop();

//increasing circle
    if ((mouseX > x) & (mouseX < x+w) && (mouseY > y) && (mouseY < y+h)) {
    } else {
      dia = 0;
    }
    push();
    noStroke();
    fill(255);
    ellipse((width / 2), (height / 2), dia, dia);
    dia = dia + 1;
    pop();

    fill(0);







}

I tried to implement codes I’ve learned this week. And I wanted to try something new, I started to design abstract image as much as possible only thinking about function. It was fun to do something different with I used to do it. It was fun to play with different codes!

heeseoc-project-03-DynamicDrawing

heeseoc-dynamic

//Steph Chun
//15-104 section #A
//heeseoc@andrew.cmu.edu
//Project-03

	var dir = 1;
	var speed = 4;
	var diam = 0;
	var dot = 3;
	var o = 1;
	var oo = 1;
	var angle = 0;
	var angleo = 0;


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

function draw() {
	noStroke(); 

	var center = 135;
	var c = constrain(mouseX, -150, center);


	//background//
	background (255-c*1.5,255-c*1.5,255-c*1.5);


	//hand right//
	fill (227,200,113);
	quad (-c+615,233,-c+681,299,-c+615,365,-c+549,299);

	fill (212,180,75);
	quad (-c+690,299,-c+640,249,-c+590,299,-c+640,349);

	fill (150,132,65);
	triangle (-c+610,299,-c+660,249,-c+660,349);

	fill (227,200,113);
	triangle (-c+614.5,233,-c+690,250,-c+680,299);

	fill (241,216,141);
	rect (-c+640,250,320,75);
	triangle (-c+640,250,-c+640,325,-c+600,250);
	rect (-c+490,250,130,30);
	triangle (-c+490,250,-c+490,280,-c+455,250);

	triangle (-c+725,325,-c+695,325,-c+695,355);
	rect (-c+590,325,105,30);
	triangle (-c+590,325,-c+590,355,-c+575,325);

	//fingernails right//
	fill (255,238,189);
	rect(-c+470,250,30,13);
	triangle (-c+470,250,-c+470,263,-c+455,250);


	//rotating dots//
	if (mouseX > 100) {
	push();
    translate(320,250);
    rotate(radians(angle));
    angle = angle + 10;
    fill(255);
    ellipse(-o, o, dot, dot);
    pop();
    o = o + 0.3;
	}

	if (mouseX > 80) {
	push();
    translate(320,250);
    rotate(radians(angleo));
    angleo = angleo + 3;
    fill(255);
    ellipse(-oo, oo, dot, dot);
    pop();
    oo = oo + 0.1;
	}

	if (mouseX > 120) {
	push();
    translate(320,250);
    rotate(radians(-angleo));
    angleo = angleo + 3;
    fill(255);
    ellipse(-oo-50, oo+50, dot, dot);
    pop();
    oo = oo + 0.1;
	}

	if (mouseX < 80) {
		o = 0;
		oo = 0;
	}

	//ripples//
	stroke (255);
	noFill();
	ellipse (320,250,diam/3,diam);
	ellipse (320,250,diam/4.5,diam/1.5);

	diam += dir * speed;
    if (mouseX < 135) {
        diam = 0;
	}


	noStroke();

	//hand left//
	fill (167,157,203);
	quad (c+25,233,c+91,299,c+25,365,c-41,299);

	fill (141,129,183);
	quad (c+50,299,c,249,c-50,299,c,349);

	fill (115,107,141);
	triangle (c+30,299,c-20,249,c-20,349);

	fill (167,157,203);
	triangle (c+25.5,233,c-50,250,c-40,299);

	fill (186,178,217);
	rect (c-320,250,320,75);
	triangle (c,250,c,325,c+40,250);
	rect (c+20,250,130,30);
	triangle (c+150,250,c+150,280,c+185,250);

	triangle (c-85,325,c-55,325,c-55,355);
	rect (c-55,325,105,30);
	triangle (c+50,325,c+50,355,c+65,325);

	//fingernails left//
	fill (216,209,241);
	rect(c+140,250,30,13);
	triangle (c+170,250,c+170,263,c+185,250);

	
 }

My original idea was to make the touch convey a sense of affection between the two people, but I changed it later on so that with the interactions, it looks more like a reflection (yet the viewers may not know at their first sight which is the twist I intended to give to this piece). Getting one hand to exactly reflect the other hand was the most difficult part for me, because I calculated all the coordinating numbers since I didn’t know how to take a combination of objects and just flip it over.

dayoungl – Project03

sketch

// Sharon Lee
// Section E
// dayoungl@andrew.cmu.edu
// Project-03
var colour1 = 255;
var colour2 = 235;
var colour3 = 107;
var angle = 0;
var x = 350;
var y = 350;
var dirX = 1;
var dirY = 0.3;
var speed = 5;
var cirSize = 80;
var point1 = 650;
var point2 = 350;
var point3 = 50;
var front = 1;
var count = 0;

function setup() {
    createCanvas(640,480);
    angleMode(DEGREES);
}
function draw() {
    background(0);
    rectMode(CENTER); 
    //moon 1 in front of the planet
    if (front == 1){
        //planet
        fill(colour1,colour2,colour3);
        noStroke();
        ellipse(width/2 +50, height/2, 300,300);
        //moon1
        fill(colour1);
        noStroke();
        ellipse(x, height/2, cirSize, cirSize);
    }
    //moon 1 behind planet
    if (front == 0){
        //moon1
        fill(colour1);
        noStroke();
        ellipse(x, height/2, cirSize, cirSize);
        //planet
        fill(colour1,colour2,colour3);
        noStroke();
        ellipse(width/2 +50, height/2, 300,300);
    }
    //stars that follow mouseX and mouseY
    push();
    angle = angle + 50;
    translate(mouseX,mouseY);
    stroke(139,94,193);
    strokeWeight(10);
    rotate(angle);
    rectMode(CENTER);
    rect(0, 0, 40, 30);
    rotate(angle);
    rect(0, 0, 40, 30);
    rotate(angle);
    rect(0, 0, 40, 30);
    pop();

    //star2
    push();
    angle += 1;
    translate(mouseX -60, mouseY -60);
    stroke(73,50,102);
    strokeWeight(7);
    rotate(angle);
    rect(0,0,10,20);
    rotate(angle);
    rect(0,0,10,20);
    rotate(angle);
    rect(0,0,10,20);
    pop();

    //star3
    fill(73,111,102);
    noStroke();
    ellipse(mouseX, mouseY -100, 10,10);
    //star4
    ellipse(mouseX, mouseY,8,8);
    //star5
    ellipse(mouseX-80, mouseY-55, 15,15);
   
    //location of moon1
    if (x <= point1){  
        x += dirX * speed;
    }
    if (x <= point1 & x >= 350){
        cirSize -= 1;
    }
    if (x <= 350 & x >= point3){
        cirSize += 1;
    }
    if (x >= point1) {
        dirX = -dirX;
        front = 0;
    }
    if (cirSize <= 350 & x <= point3) {
        dirX = -dirX;
        front = 1;
        count += 1;
    }

    // planet changes color every revolution
    if (count % 10 == 1) {
        colour1 = 255;
        colour2 = 235;
        colour3 = 68;
    }
    if (count % 10 == 2) {
        colour1 = 255;
        colour2 = 215;
        colour3 = 68;

    }
    if (count % 10 == 3) {
        colour1 = 255;
        colour2 = 195;
        colour3 = 68;
    } 
    if (count % 10 == 4) {
        colour1 = 255;
        colour2 = 180;
        colour3 = 68;
    }
    if (count % 10 == 5){
        colour1 = 255;
        colour2 = 165;
        colour3 = 68;
    }
    if (count % 10 == 6){
        colour1 = 255;
        colour2 = 150;
        colour3 = 68;
    }
    if (count % 10 == 7){
        colour1 = 255;
        colour2 = 135;
        colour3 = 68;
    }
    if (count % 10 == 8){
        colour1 = 255;
        colour2 = 120;
        colour3 = 68;
    }
    if (count % 10 == 9){
        colour1 = 255;
        colour2 = 105;
        colour3 = 68;
    }
}

Orbital system
I wanted to make an image of moon orbiting the planet along with with other visual decorations that move around as the mouse moves. I had difficulty making the moon go behind the planet every revolution but I eventually figured it out.

Hannahk2-Project03-DynamicDrawing

sketch

//Hannah Kim
//Section A
//hannahk2@andrew.cmu.edu
//Assignment-01

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

function draw() {
  background(0, 0, 0);

//background color change
//as mouse moves down, color changes from blue 
//to lighter blue
    var Rc = map(mouseY, 0, height, 200, 260);
    var Gc = map(mouseY, 0, height, 240, 255);
    var Bc = map(mouseY, 0, height, 250, 255);

    noStroke();
    fill(Rc, Gc, Bc);
    rect(0, 0, 600, 600);

//circle background color change
//as mouse moves down, color changes from white
//to blue
    var circSize =map(mouseY, 0, height, 0, 400);
    var Rc1 = map(mouseY, 0, height, 260, 200);
    var Gc1 = map(mouseY, 0, height, 255, 240);
    var Bc1 = map(mouseY, 0, height, 255, 250);
noStroke();
fill(Rc1, Gc1, Bc1);
ellipseMode(CENTER);
ellipse(294, 242, circSize, circSize);

//top chopstick
var topChop = map(mouseY, 0, 400, 92, 300);
stroke(198, 58, 61);
strokeWeight(9);
line(27, 60, 291, topChop);

//noodle 1
var nood1 = map(mouseY, 0, 400, 76, 310);
stroke(221, 215, 153);
strokeWeight(6);
line(240, nood1, 240, 311);

//noodle2
var nood2 = map(mouseY, 0, 400, 76, 312);
stroke(221, 215, 153);
strokeWeight(6);
line(252, nood1, 253, 313);

//noodle3
var nood3 = map(mouseY, 0, 400, 76, 312);
stroke(221, 215, 153);
strokeWeight(6);
line(266, nood3, 266, 316);

//bottom chopstick
var bottomChop = map(mouseY, 0, 400, 107, 310);
stroke(198, 58, 61);
strokeWeight(9);
line(5, 111, 292, bottomChop);

noStroke();
//draw ramen cup
fill (233, 231, 226);
rect (164, 261, 272, 8);
quad (175, 275, 210, 560, 386, 561, 428, 277);
noStroke();
arc(297, 561, 176, 10, TWO_PI, PI);

//draw top row of yellow marks
fill(194, 198, 89);
rect(182, 300, 3, 24);
rect(188, 300, 3, 24);
rect(194, 300, 3, 24);
rect(200, 301, 3, 24);
rect(207, 301, 3, 24);
rect(214, 302, 3, 24);
rect(222, 302, 3, 24);
rect(230, 302, 3, 24);
rect(239, 303, 3, 24);
rect(248, 303, 3, 24);
rect(257, 303, 3, 24);
rect(267, 304, 3, 25);
rect(277, 304, 3, 25);
rect(287, 304, 3, 25);
rect(297, 304, 3, 25);
rect(307, 304, 3, 25);
rect(317, 303, 3, 25);
rect(326, 303, 3, 24);
rect(335, 303, 3, 24);
rect(344, 303, 3, 24);
rect(352, 303, 3, 24);
rect(361, 303, 3, 24);
rect(369, 303, 3, 24);
rect(377, 303, 3, 24);
rect(385, 302, 3, 24);
rect(392, 302, 3, 24);
rect(399, 301, 3, 24);
rect(405, 300, 3, 24);
rect(411, 300, 3, 24);
rect(417, 300, 3, 24);

//draw bottom row of yellow marks
fill(194, 198, 89);
rect(207, 501, 3, 24);
rect(214, 502, 3, 24);
rect(222, 502, 3, 24);
rect(230, 502, 3, 24);
rect(239, 503, 3, 24);
rect(248, 503, 3, 24);
rect(257, 503, 3, 24);
rect(267, 504, 3, 25);
rect(277, 504, 3, 25);
rect(287, 504, 3, 25);
rect(297, 504, 3, 25);
rect(307, 504, 3, 25);
rect(317, 503, 3, 25);
rect(326, 503, 3, 24);
rect(335, 503, 3, 24);
rect(344, 503, 3, 24);
rect(352, 503, 3, 24);
rect(361, 503, 3, 24);
rect(369, 503, 3, 24);
rect(377, 503, 3, 24);
rect(385, 502, 3, 24);

//draw red background for middle logo 
fill(198, 58, 61);
rect(272, 354, 79, 58);
arc(346, 374, 50, 40, PI+QUARTER_PI, HALF_PI);
ellipseMode(CENTER);
ellipse(263, 383, 59, 63);
quad(197, 408, 204, 462, 392, 465, 398, 408);
ellipse(248, 437, 59, 63);
ellipse(278, 437, 59, 63);

//draw text for cup
textSize(50);
textStyle(BOLD);
fill(255, 255, 255);
text("CUP", 248, 400);

//draw text for noodles
textSize(38);
textStyle(BOLD);
fill(255, 255, 255);
text("NOODLES", 203, 450);

//draw nissin logo with text
fill(177, 27, 38);
arc(208, 357, 36, 38, PI, TWO_PI);
textSize(8);
fill(255, 255, 255);
text("NISSIN", 195, 354);

//bottom red line
strokeWeight(1);
stroke(198, 58, 61);
line(210, 535, 386, 536);

//top red line
line(175, 289, 428, 291);

//white shine on cup
fill(255, 255, 255, 90);
noStroke();
quad(373, 272, 348, 568, 375, 564, 407, 272);
}

 

This project was pretty fun for me, though I did not know where to start with the commands and which commands to choose to make my code do what I wanted it to do. I enjoyed creating the cup of noodles especially, since I always eat cup noodles.

Sijings-project03-DynamicDrawing

Sijings-project

//Clair(sijing) Sun
//session C
//sijings@andrew.cmu.edu
//Project-03-Dynamic Drawing

var moonposX=540;//moon position
var moonposY=140;
var moonR=80;
var frontTX1=300;//front mountain1
var frontTY1=260;
var frontTX2=250;//front mountain2
var frontTY2=260;
var frontTX3=350;//front mountain3
var frontTY3=260;
var front2TX1=250;
var front2TY1=260;
var front2TX2=200;
var front2TY2=260;
var front2TX3=300;
var front2TY3=260;
var islandDegree1=180;//island
var islandDegree2=90;
var islandPosX1=300;
var islandPosY1=250;
var islandWidth=390;
var islandHeight=390;
var backTX1=200;//back mountain1
var backTY1=260;
var backTX2=160;
var backTY2=260;
var backTX3=240;
var backTY3=260;
var back2TX1=180;//back mountain2
var back2TY1=260;
var back2TX2=104;
var back2TY2=260;
var back2TX3=254;
var back2TY3=260;
var moonColor1=156;
var moonColor2=193;
var offsetFish=20;//for fish to follow with a distance
var color1=243;//change color when mouse arrive the moon
var color2=244;
var color3=225;
var bird=0;//a condition for mouse in and outside of the island 



function setup() {
    createCanvas(640, 480);
    
}
 
function draw() {
    background(color1,color2,color3);
    noStroke();
    fill(moonColor1,moonColor2,204);
    moonColor1+=mouseY/400;//moon color change
    //print("bird"+bird);for debugging
    if (moonColor1>=254&bird>0){//moon color changing as mouse moves
        moonColor1=mouseX;
        moonColor2=mouseY;
    }
    var moveMouse=mouseX-500;//to create moon rotatons
    moonposX+=moveMouse;
    if (moveMouse>30&bird>0){//two edge cases
        moveMouse=5;
    }
    if (moonposX<5&bird>0){
        moonposX=635;
    }
    if (moonposX>635&bird>0){
        moonposX=5;
    }

    if (mouseX>470&mouseX<530&&mouseY<163&&mouseY>93){
        color1=224;//background color change
        color2=125;
        color3=105;

    }else{
        color1=243;
        color2=244;
        color3=225;
    }
    if (bird==0&back2TY1<305){//for mountains disappear
        back2TY1+=1;
        backTY1+=1;
        frontTY1+=1;
        front2TY1+=1;
    }else{//for the mountains appear
            back2TY1-=1;
            backTY1-=1;
            frontTY1-=1;
            front2TY1-=1;
            if (back2TY1<45){//to stop mountain from moving further
                back2TY1=45;
            }
            if(backTY1<30){
                backTY1=30;
            }
            if (frontTY1<90){
                frontTY1=90;
            }
            if (front2TY1<110){
                front2TY1=110;
            }


    }

    //mountains
    ellipse(moonposX,moonposY,moonR,moonR);
    fill(222,226,227);
    triangle(back2TX1,back2TY1,back2TX2,back2TY2,back2TX3,back2TY3);
    translate(100,0);
    triangle(back2TX1,back2TY1,back2TX2,back2TY2,back2TX3,back2TY3);
    translate(-100,0);
    fill(163,180,90);
    triangle(backTX1,backTY1,backTX2,backTY2,backTX3,backTY3);
    fill(65,69,41);
    triangle(frontTX1, frontTY1, frontTX2, frontTY2, frontTX3, frontTY3);
    fill(93,105,57);
    triangle(front2TX1, front2TY1, front2TX2, front2TY2, front2TX3, front2TY3);
    fill(90,139,157);
    angleMode(DEGREES);
    arc(islandPosX1, islandPosY1, islandWidth, islandHeight, 0, islandDegree1,islandDegree2);
    

    if (mouseX>106&mouseX<494 && mouseY>251){//for determining wether the mouse is on the island
        fill(175,215,198,100);
        bird=0;
    }else{
        fill(175,215,198);
        bird=1;
    }

    //fish drawings
    arc(mouseX-offsetFish, mouseY+offsetFish, 30,30,0,100,130);
    arc(mouseX-offsetFish-9, mouseY+offsetFish+14.5, 10,10,0,100,130);
    translate(-20,5);//for multiple fishes 
    arc(mouseX-offsetFish, mouseY+offsetFish, 30,30,0,100,130);
    arc(mouseX-offsetFish-9, mouseY+offsetFish+14.5, 10,10,0,100,130);
    translate(-20,5);
    arc(mouseX-offsetFish, mouseY+offsetFish, 30,30,0,100,130);
    arc(mouseX-offsetFish-9, mouseY+offsetFish+14.5, 10,10,0,100,130);
    translate(-25,0);
    arc(mouseX-offsetFish, mouseY+offsetFish, 30,30,0,100,130);
    arc(mouseX-offsetFish-9, mouseY+offsetFish+14.5, 10,10,0,100,130);
    translate(30,35);
    arc(mouseX-offsetFish, mouseY+offsetFish, 30,30,0,100,130);
    arc(mouseX-offsetFish-9, mouseY+offsetFish+14.5, 10,10,0,100,130);
    translate(20,-25);
    arc(mouseX-offsetFish, mouseY+offsetFish, 30,30,0,100,130);
    arc(mouseX-offsetFish-9, mouseY+offsetFish+14.5, 10,10,0,100,130);
    translate(25,-10);
    arc(mouseX-offsetFish, mouseY+offsetFish, 30,30,0,100,130);
    arc(mouseX-offsetFish-9, mouseY+offsetFish+14.5, 10,10,0,100,130);
    translate(10,10);
    arc(mouseX-offsetFish, mouseY+offsetFish, 30,30,0,100,130);
    arc(mouseX-offsetFish-9, mouseY+offsetFish+14.5, 10,10,0,100,130);

    //rotating the boat on the water
    if (bird>0){
        var degree=cos(mouseX);
        rotate(degree);
        //print(degree);for debugging the boat rotation
        fill(104,76,16);
        arc(400, 220, 50,30, 0, islandDegree1,islandDegree2);
    }
    

}

For this project, my idea is to create a narrative drawing where the audience can control the pace by either putting the mouse outside of the lake and inside of the lake. The project is intended that the audience start by putting their mouses inside the lake and then gradually towards the outside. The fish group is always following the mouse. When the fish jumps out of the lake, the mountain grows up and the boat appears. The users can also manipulate the speed that the moon/the sun rotates. When the mouse(in my drawing, the fish group) meet the original point of the sun, the background color will change. Four variables here are 1. the color of the moon 2. the background color 3. the speed of moon’s rotation 4. the rotation angle of the boat (slightly to create the effect of its floating) 5. the size of the mountain 6. the location and the color of the fish.

agusman-Project03-DynamicDrawing

sketch

// Anna Gusman
// Section A
// Project 03
// This code is a bouncy-bodied, color-changing brush concept.
// Referencing properties of spring and damping forces from p5, I create a brush shape
// that organically changes dimensions as the mouse is dragged. 

var centerX = 0.0, centerY = 0.0; // center point of the polygon

var radius = 45, rotAngle = -30;
var accelX = 0.0, accelY = 0.0;
var deltaX = 0.0, deltaY = 0.0;
var springing = 0.0009, damping = 0.98;
//values of the spring and damp forces that make the triangle speed up and slow down when following the mouse.
//
var rr = 10;
var gg= 10;
var bb= 10;
var colorchange = 90;

//dictate the number of nodes
var nodes = 3;

//create zero fill arrays
var nodeStartX = [];
var nodeStartY = [];
var nodeX = [];
var nodeY = [];
var angle = [];
var frequency = [];

// soft-body dynamics
var organicConstant = 1.0;

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

  //center shape in window
  centerX = width/2;
  centerY = height/2;

  //initialize arrays to 0
  for (var i=0; i<nodes; i++){
    nodeStartX[i] = 0;
    nodeStartY[i] = 0;
    nodeY[i] = 0;
    nodeY[i] = 0;
    angle[i] = 0;
  }

  // iniitalize frequencies for corner nodes
  for (var i=0; i<nodes; i++){
    frequency[i] = random(5, 12);
  }

  frameRate(60); //increase the drawing speed
}

function draw() {
  //fade the background
  // fill(255, 10);
  // background(200, 3);
  fill(rr, gg, bb); //color of polygon
    rr = 127.5*cos(2*PI*colorchange/360) + 127.5;
    gg = 127.5*sin(2*PI*colorchange/360) + 127.5;
    bb = 127.5*sin(2*PI*(colorchange-20)/360) + 127.5;

colorchange++;
  stroke(0);
  drawShape();
  moveShape();
}

function drawShape() {
  //  calculate the locations of the nodes
  for (var i=0; i<nodes; i++){
    nodeStartX[i] = centerX+cos(radians(rotAngle))*radius;
    nodeStartY[i] = centerY+sin(radians(rotAngle))*radius;
    rotAngle += 360.0/nodes; //drawing 3 points on the circumference of the circle
  }

  // draw polygon
  curveTightness(organicConstant);
  beginShape();
  for (var i=0; i<nodes; i++){
    curveVertex(nodeX[i], nodeY[i]);
  }
  for (var i=0; i<nodes-1; i++){
    curveVertex(nodeX[i], nodeY[i]);
  }
  endShape(CLOSE);
}

function moveShape() {
  //move the center point
  deltaX = mouseX-centerX;
  deltaY = mouseY-centerY;

  // create springing effect
  deltaX *= springing;
  deltaY *= springing;
  accelX += deltaX;
  accelY += deltaY;

  // move the polygon's center
  centerX += accelX;
  centerY += accelY;

  // slow down springing so that the polygon does not continue moving infinitely
  accelX *= damping;
  accelY *= damping;

  // change the tightness of the curves using the organic constant
  organicConstant = 1-((abs(accelX)+abs(accelY))*0.1);

  //move the nodes
  for (var i=0; i<nodes; i++){
    nodeX[i] = nodeStartX[i]+sin(radians(angle[i]))*(accelX*2);
    nodeY[i] = nodeStartY[i]+sin(radians(angle[i]))*(accelY*2);
    angle[i] += frequency[i];
  }
}

For this project, I created an bouncy-bodied, color-changing brush concept. I referenced p5’s softbody dynamics example in order to see how they treated oscillating vector forces. You can find the example here

I was inspired to create a brush concept from the bit of code I wrote in this week’s recitation lab on creating a mouse controlled spiraling ellipse. I first made iterations on this to explore styling options and effects.

Example:

Example:

Still, the brush felt more controlled and predictable than I wanted to to be- I wanted there to be a larger element of surprise. Elements of the soft body dynamics example allowed me to soften the reactions of my shape/brush by giving it springing and damping properties, created by controlling the relationships between the drawn vertexes(nodes) of the shape (curveTightness and curveVertex. This makes the brush wiggle and have a pleasing, natural element to it’s movement. I then control the number of vertexes and sides of the shape and the acceleration and movement of these vertexes. (accel, delta, springing, damping, nodeStart, node).

Next I wanted to illustrate change across the movement of the brush path. I did this by creating a color system that undulates across the length of 3 sine waves, one each for red, blue and green.

I also experimented further with eliminating or altering the spring relationship between the mouse and the center of the polygon. Here is one example:

In future iterations of this brush concept, I’d like to embed customization of the brush shape so that when you click, you could alter the number of vertexes that would result in different brush trails. Definitely excited to play around with this more, as it has been a great learning experience.

adev_Project 03_Dynamic Drawing

project_03

var angle = 0;

var rectX = 0;

var r = 255;
var g = 0;
var b = 0;

var col = 0;

function setup() {
    createCanvas(640, 480);  
    background(255,225,53);
    fill(255);
    noStroke();
    rect(0,0,320,4800);
    angleMode(DEGREES);
    rectMode(CENTER);
    
}

function draw() {
    
    //rotating rectangle1
     push();
    translate (130,100);
        rotate (angle);
    fill (r,g,b);
    stroke(255);
    strokeWeight(2)
;        rect(rectX, 0,100,30);
     rect(rectX+50, 20,100,30);
    rect(rectX+100, 40,100,30);
    rect(rectX+150, 60,100,30);
    angle = mouseY + 2;
        pop();
    
    //rotating rectangle 2
     push();
    translate (300,300);
        rotate (angle);
    fill (r,g,b);
    stroke(255);
    strokeWeight(2);
        rect(rectX, 0,100,30);
     rect(rectX+50, 20,100,30);
    rect(rectX+100, 40,100,30);
    rect(rectX+150, 60,100,30);
    angle = mouseY + 2;
        pop();
    
       //rotating rectangle 3
      push();
    translate (50,400);
        rotate (angle);
    fill (r,g,b);
    stroke(255);
    strokeWeight(2);
        rect(rectX, 0,100,30);
     rect(rectX+50, 20,100,30);
    rect(rectX+100, 40,100,30);
    rect(rectX+150, 60,100,30);
    angle = mouseY + 2;
        pop();
    
    //yellow half of the composition
    fill(255,225,53);
    noStroke();
    rect(160+320,240,320,480);  
    
    //white rectangle
      if (mouseX > 480){
        fill(col);
        noStroke();
        rect(480,240,200,380);
          
          col = col +2;
    }
      
    var height1 = map(mouseY,0, 480, 0, 240);
    
    //semicricles
    fill(244, 148, 4);
    noStroke();
    arc(480, 0, 320, height1, 0,0, OPEN);
    arc(480, 480, 320, -height1 , 0,0, OPEN);
    
    //pink lines
    stroke(255, 63, 232);
    strokeWeight(20);
    line(20,0,20,mouseY);
   line(106,0,106,mouseY);
    line(212,0,212,mouseY);
    line(310,0,310,mouseY);
    
  
  
    
}