Elena-Deng-Project-03-Dynamic-Drawing

sketch

/*Elena Deng
Section E
  edeng1@andrew.cmu.edu
  Project-03
}
*/

var x=68; //position (X)
var y=240; // position (Y)





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

}

function draw() {
  background(30); //background color
  noStroke();
  rectMode(CENTER);

  if (mouseIsPressed) {
    background(255); //changes background color when mouse is pressed
  }



  fill(121,114,map(mouseY,0,height,170,190)); //changing the B value of the rectangle
  rect(x,map(mouseX,0,width,y-10,y+10),23,map(mouseY,0,height,50,80)); //(map(n,a,b,x,y))can set the range at which something changes


  fill(map(mouseY,0,height,230,250),147,map(mouseX,0,width,50,map(mouseY,0,height,90,150)));
  rect(x+28,map(mouseX,0,width,y-20,y+20),23,map(mouseY,0,height,200,100));


  fill(93,map(mouseX,0,width,80,110),166);
  rect(x+56,map(mouseX,0,width,y-20,y+20),23,map(mouseY,0,height,180,250));


  fill(map(mouseY,0,height,180,220),90,69);
  rect(x+84,y,23,map(mouseY,0,height,100,300));

  fill(map(mouseY,0,height,220,265),218,map(mouseX,0,width,115,130));
  rect(x+112,map(mouseX,0,width,y-30,y+30),23,map(mouseY,0,height,280,120));

  fill(196,map(mouseX,0,width,20,50),56); //changing the G value of the rectangle color
  rect(208,y,23,map(mouseY,0,height,10,300));

  fill(121,114,map(mouseY,0,height,150,240));
  rect(236,y,23,map(mouseY,0,height,170,300));

  fill(map(mouseY,0,height,180,220),95,map(mouseX,0,width,10,60));
  rect(264,map(mouseX,0,width,y-10,y+10),23,map(mouseY,0,height,80,150));

  fill(map(mouseX,0,width,120,150),148,186);
  rect(292,map(mouseX,0,width,y-20,y+20),23,map(mouseY,0,height,300,150));

  fill(map(mouseY,0,height,150,240),75,62);
  rect(320,y,23,map(mouseY,0,height,100,350));

  fill(map(mouseY,0,height,230,250),147,map(mouseX,0,width,40,90));
  rect(348,map(mouseX,0,width,y-30,y+30),23,map(mouseY,0,height,50,250));

  fill(93,map(mouseX,0,width,60,100),166);
  rect(376,y,23,map(mouseY,0,height,200,100));

  fill(map(mouseY,0,height,240,265),218,123);
  rect(404,map(mouseX,0,width,y-40,y+40),23,map(mouseY,0,height,100,300));

  fill(map(mouseY,0,height,180,200),map(mouseX,0,width,30,60),56);
  rect(432,y,23,map(mouseY,0,height,250,100));

  fill(209,90,map(mouseX,0,width,50,80));
  rect(460,map(mouseX,0,width,y-20,y+20),23,map(mouseY,0,height,100,200));

  fill(map(mouseX,0,width,120,140),147,186);
  rect(488,y,23,map(mouseY,0,height,250,100));

  fill(map(mouseY,0,height,195,215),95,(map(mouseX,0,width,30,50)));
  rect(516,map(mouseX,0,width,y-20,y+20),23,map(mouseY,0,height,150,50));

  fill(map(mouseY,0,height,235,255),147,69);
  rect(544,map(mouseX,0,width,y-15,y+15),23,map(mouseY,0,height,40,80));
//used the map tool to change y position
//used map tool to change Y size of rectangle
//used map tool to change various R,G,B values to make a sort of variation between colors
}

This project was really fun! At first I got a slow start because I didn’t know what my four variations would be, but I had the general idea of what I wanted the end result to be. I really like the color palette I chose and my idea to change the mouse pressed came from what I learned about color theory lately.

Kyle Leve-Project-03-Dynamic-Drawing

sketch

// Kyle Leve
// Section A
// kleve@andrew.cmu.edu
// Project-03-Dynamic-Drawing

var dirSq = 1;
var dirCir = 1;
var sqX = 150, sqY = 220;
var cirX = 400; cirY = 220;
var speed = 2;
var angleSq = 0;
var angleCir = 0;
var sqWidth = 130;
var sqHeight = 150;
var cirWidth = 150;
var cirHeight = 190;
var dirSqW = 1, dirSqH = 1, dirCirW = 1, dirCirH = 1;

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

function draw() {
	if (mouseX <= 100) { //change the background at different mouse locations
		background('red');
	}
	if (100 < mouseX & mouseX <= 200) {
		background('orange');
	}
	if (200 < mouseX & mouseX <= 300) {
		background('yellow');
	}
	if (300 < mouseX & mouseX <= 400) {
		background('green');
	}
	if (400 < mouseX & mouseX <= 500) {
		background('blue');
	}
	if (500 < mouseX & mouseX <= 600 || mouseX > 600) {
		background('purple');
	}

	fill(0); // black square around the blue square
	push();
	translate(sqX, sqY);
	rotate(radians(angleSq));
	rectMode(CENTER);
	rect(0, 0, sqWidth, sqHeight);
	pop();

	fill('blue'); //blue square
	push();
	translate(sqX, sqY);
	rotate(radians(angleSq)); //make the squares spin
	rectMode(CENTER);
	rect(0, 0, 100, 100);
	pop();
	angleSq = angleSq + 1;
	if (mouseY >= 300) { //change the spin direction of mouseY is greater than 300
		angleSq = angleSq - 2;
	}

	if (mouseX >= 300) { //makes the square go up and down and bounce off walls
		sqY += dirSq * speed;
	if (sqY > height - 100 || sqY < 0) {
		dirSq = -dirSq;
	}
	}

	if (mouseX < 300) { //makes the square go left and right and bounce off walls
		sqX += dirSq * speed;
	if (sqX > width - 100 || sqX < 0) {
		dirSq = -dirSq;
	}
	}

	sqWidth += dirSqW * speed; //makes the black square's width grow and shrink
	if (sqWidth > 300) {
		dirSqW = -dirSqW;
		sqWidth = 300;
	} else if (sqWidth < 100) {
		dirSqW = -dirSqW;
		sqWidth = 100;
	}

	sqHeight += dirSqH * speed; //makes the black square's height grow and shrink
	if (sqHeight > 300) {
		dirSqH = -dirSqH;
		sqHeight = 300;
	} else if (sqHeight < 100) {
		dirSqH = -dirSqH;
		sqHeight = 100;
	}

	fill(0); //black circle
	push();
	translate(cirX, cirY);
	rotate(radians(-angleCir)); //makes the black circle spin in the opposite direction from the square 
	ellipseMode(CENTER);
	ellipse(0, 0, cirWidth, cirHeight);
	pop();

	fill('red'); //red circle
	push();
	translate(cirX, cirY);
	rotate(radians(-angleCir)); //makes the red circle spin in the opposite direction from the blue square
	ellipseMode(CENTER);
	ellipse(0, 0, 120, 150);
	pop();
	angleCir = angleCir + 1;
	if (mouseY >= 300) { //changes spin direction
		angleCir = angleCir - 2;
	}

	if (mouseX >= 300) { //makes the circle go left and right when the square goes up and down
		cirX += dirCir * speed;
	if (cirX > width - 60 || cirX - 60 < 0) {
		dirCir = -dirCir;
	}
	}
	if (mouseX < 300) { //makes the cirle go up and down when the square goes left and right
		cirY += dirCir * speed;
	if (cirY > height - 75 || cirY - 75 < 0) {
		dirCir = -dirCir;
	}
	}

	cirWidth += dirCirW * speed; //makes the black circle's width grow and shrink
	if (cirWidth > 300) {
		dirCirW = -dirCirW;
		cirWidth = 300;
	} else if (cirWidth < 120) {
		dirCirW = -dirCirW;
		cirWidth = 120;
	}
	cirHeight += dirCirH * speed; //makes the black circle's height grow and shrink
	if (cirHeight > 300) {
		dirCirH = -dirCirH;
		cirHeight = 300;
	} else if (cirHeight < 150) {
		dirCirH = -dirCirH;
		cirHeight = 150;
	}

}

Doing the project I wanted to experiment with different movements rather than having a stationary picture. I decided to use a lot of the recent topics we learned such as rotation, motion, and variables to create two objects that behaved in contrary motion with each other. I found it very interesting to have to create one object and have the other object be based on how to first object was behaving.

Shirley Chen – Project 03 – Dynamic Drawing

sketch

// Shirley Chen
// Section B
// junfanc@andrew.cmu.edu
// Project-03



var X = 10;
var Y = 10;
var d;
var m;
var radius = 0;
var shade = 0;
var side = 0;

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

}

function draw() {
    background(253, 224, 146);
//Make a Grid
    for (i = 0; i < 24; i++){
        for (j = 0; j < 32; j++){
            X = 20 * j + 10
            Y = 20 * i + 10;
//Divide the Coordinate into Four Quadrants
//The Radius of Circles in the First Quadrant Changes According to the Distance Between Mouse and Center of the Circle
//The Color of the Circle Changes According to the Distance Between Mouse and Center of the Circle
        if (mouseX > 0 & mouseX < 320 && mouseY > 0 && mouseY < 240){
                d = dist(mouseX, mouseY, X, Y)
                m = map(d, 0, 786, 0, 20);
                shade = m * 0.5 + 200;
                radius = 20 - m;
                noStroke();
                fill(shade, 137, shade);
                ellipse(X, Y, radius, radius);
            }
//The Length of Side of the Square in the Second Quadrant Changes According to the Distance Between Mouse and Center of the Sqaures
//The Color of the Sqaures Changes According to the Distance Between Mouse and Center of the Squares
            else if  (mouseX > 320 & mouseX < 640 && mouseY > 0 && mouseY < 240){
                d = dist(mouseX, mouseY, X, Y)
                m = map(d, 0, 786, 0, 20);
                side = m + 10;
                shade = m + 200;
                noStroke();
                fill(223, shade, 138);
                rectMode(CENTER);
                rect(X, Y, side, side);
            }
//The Length of Side of the Rectangles in the Second Quadrant Changes According to the Distance Between Mouse and Center of the Rectangles
//The Color of the Rectangles Changes According to the Distance Between Mouse and Center of the Rectangles
            else if  (mouseX > 0 & mouseX < 320 && mouseY > 240 && mouseY < 480){
                d = dist(mouseX, mouseY, X, Y)
                m = map(d, 0, 786, 0, 20);
                side = m * 0.3 + 18;
                shade = m * 7 + 50;
                noStroke();
                fill(231, 100, shade);
                rectMode(CENTER);
                rect(X, Y, side + 3, side);
            }
//The Size of the Geometry Changes According to the Distance Between Mouse and Center of the Geometry
//The Color of the Geometry Changes According to the Distance Between Mouse and Center of the Geometry
            else if  (mouseX > 320 & mouseX < 640 && mouseY > 240 && mouseY < 480){
                d = dist(mouseX, mouseY, X, Y);
                m = map(d, 0, 786, 0, 20);
                side = m * 0.8 + 2;
                shade = m * 3 + 8;
                noStroke();
                fill(167, 88, shade);
                rectMode(CENTER);
                rect(X, Y, side, side, 1, 8);
            } 
//When the Mouse is not On Canvas, Text Will Show Up
            else {
                fill(89, 134, 189);
                text('PLACE THE MOUSE HERE!', 235, 240);
            }
        }
    }
}

In this assignment, I was inspired by the parametric design that I researched for the Looking Outward Assignment. Controlling by the position of the mouse, some variables like radius, color, size, shape will change accordingly. It creates interesting visual effect that when the mouse gets closer to a geometry, the geometry gets smaller. I practiced the looping command that I learned from other class.

Christine Chen-Project-03-Dynamic Drawing

Christine Chen-Project-03-Dynamic Drawing

/*
Christine Chen
Section E
cyc1@andrew.cmu.edu
Project-03-Dynamic Drawing
*/

var angle = 0; //angle for square rotation

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

function draw() {
    scale(0.95); //scaling it down so graphics won't be cut by WordPress
    //left side is for sadness
    //right side is for happiness

    //LEFT OF CANVAS IS BLUE
    if (mouseX < 320){
        background(129, 164, 235);
    }

    //RIGHT OF CANVAS IS ORANGE
    if (mouseX > 320){
        background(257, 141, 47);
    }

    //LINE OF SCALE
    fill(255);
    rect(100, 240, 440, 5); //long horizontal line for scale
    rect(320, 233, 5, 20); //line for midpoint

    //ROTATING SQUARE
    var x = mouseX
    push();
    if (x < 320){ //square turns red when on left
        fill(255, 0, 0);
    } else {
        fill(0, 255, 36);//square turns green when on right
    }

    if (x <= 100){ //restricts movement of x to be on the line of scale
        x = 100;
    } else if (x >= 540) { 
        x = 540;
    }

    translate(x, 240); //square would move horizontally according to x
    rotate(radians(angle));
    rectMode(CENTER); 
    rect(0, 0, 15, 15);
    pop();


    var squareSpeed = 0; 
    if (x < 320){ //square speeds up towards left
        squareSpeed = (320 - x + 320)/90;
    } else if (x > 320) { //square speeds up towards right
        squareSpeed = x/90;
    }

    angle = angle + squareSpeed;

    //----------EMOJI CODES----------
    var blue = color(180, 244, 255);
    var yellow = color(255, 228, 0);
    var size = 100;

    //FACE
    if (x < 320){ //emoji turns sad and increases size towards left
        noStroke();
        fill(blue); 
        var control = (320 - x + 320)/500; 
    } else { //emoji turns happy and increases size towards right
        noStroke();
        fill(yellow); 
        var control = x/500; 
    }

    ellipse(x, 170, size * control, size * control);

    //EYES
    fill(0);
    ellipse(x + 10, 155, 5, 5); //right eye
    ellipse(x - 10, 155, 5, 5); //left eye

    //MOUTH
    if (x > 320){ //happy mouth
        fill(228, 103, 126); //pink
        arc(x, 165, 35, 35, 0, PI); //arc with top opening
    } else { //sad mouth
        fill(79, 111, 203); //blue
        arc(x, 185, -35, -35, PI, TWO_PI); //arc with bottom opening
    }

    //NEGATIVE SIGN 
    let negativeColor = color(208); //resting color is gray
    if (x < 320){ //negative sign turns red 
        negativeColor = color(255, 0, 0);
    }
    fill(negativeColor);
    rect(40, 240, 20, 5);


    //POSITIVE SIGN
    let positiveColor = color(208); //resting color is gray
    if (x > 320){ //positive sign turns green
        positiveColor = color(0, 255, 36);
    }
    fill(positiveColor);
    rect(580, 240, 20, 5); //horizontal line
    rect(587.5, 233, 5, 20); //vertical line

}

I found this project quite challenging to start with as there are so many ways to address this project. In the end, I decided to create my own version of the emoji slider. I have always thought that the emoji slider on Instagram is not dramatic enough, so I took this project as a chance to create my own ideal version of the emoji slider with exaggerated features. Instead of having only one type of emotion, I used one end of the scale for sadness and the other one for happiness. I spent a lot of time figuring out how to make the face increase in size and the rotation square increase in speed on they approach the two ends of the scale. I finally figured out the equations after quite a while and it was definitely a fruitful gain for me! 🙂

Alice Fang–Project 03– Dynamic Drawing

sketch

/*
Alice Fang
Section E
acfang@andrew.cmu.edu
Project-03
*/

/*
When mouseX is > width/2, 
	-magenta circle shrinks while cyan circle grows
	-blue circle rotates clockwise, yellow circle couterclockwise

When mouseX is < width/2,
	-magenta circle grows while cyan circle shrinks
	-blue circle rotates counterclockwise, yellow circle clockwise

When mouseX is within the red circle
	-green circle rotates clockwise
	-green circle becomes smaller
	-green circle rotates more quickly
	-things become dark! goodbye light

Sometimes there is a delay with the growth/shrink of magenta and cyan circles-
neither I nor Prof. Dannenberg know exactly why 🙁 */

//circle diameters
var yellowD = 100;
var cyanD = 80;
var redD = 240;
var greenD = 80;
var magentaD = 320;
var blueD = 160;

var scale1 = 5; //constant rate of growth for cyan/magenta circles
var scale2 = -5; //constant rate of shrinking for cyan/magenta circles

//rotataion speed
var angle1 = 0; //blue circle
var angle2 = 0; //yellow circle
var angle3 = 0; //green circle (mouseX inside red circle)
var angle4 = 0; //green circle (mouseX outside red circle)
var angle5 = 0; //cyan circle
var angle6 = 0; //magenta circle

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

function draw() {
	background(255);

	if (dist(160, 280, mouseX, mouseY) < redD/2) {
		background(0); //switch background to black
	} else {
		background(255); 
	}

	var cyanS = constrain(cyanD, 40, 500); //limit growth of cyan
	var magentaS = constrain(magentaD, 40, 500); //limit growth of magenta
	
	if (mouseX > width / 2) {
		cyanD += scale1; //cyan increases in size
		magentaD += scale2; //magenta decreases in size
		angle1 += 5; //blue rotates clockwise
		angle2 -= 3; //yellow rotates counterclockwise
	} 
	if (mouseX < width /2) {
		cyanD += scale2; //cyan decrease in size
		magentaD += scale1; //magenta increase in size
		angle1 -= 3; //blue rotates counterclockwise, decreases speed 
		angle2 += 5; //yellow rotates clockwise, increases speed 
	}

	//cyan circle
	push();
	translate(width/2, height/2); 
	rotate(radians(angle5));
	angle5 -= 1; //rotation speed
	fill('rgba(0, 255, 255, 0.5)'); 
	ellipse(200, 160, cyanS, cyanS);
	pop();

	//magenta circle
	push();
	translate(width/2, height/2);
	rotate(radians(angle6));
	angle6 += 1; //rotation speed, 
	fill('rgba(255, 0, 255, 0.5)'); 
	ellipse(80, 40, magentaS, magentaS);
	pop();

	//red circle
	if (dist(160, 280, mouseX, mouseY) < redD/2) { //if mouse is inside red circle
		fill('rgba(0, 0, 0, 0.7)'); //become black
		ellipse(160, 280, redD, redD);
	} else {
		fill('rgba(255, 0, 0, 0.7)');
		ellipse(160, 280, redD, redD);
	}

	//blue circle
	push();
	translate(360, 240);
	rotate(radians(angle1));
	ellipseMode(CORNER);
	fill('rgba(0, 0, 255, 0.5)'); 
	ellipse(0, 0, blueD, blueD);
	pop();

	//yellow circle
	push();
	translate(360, 240);
	rotate(radians(angle2));
	ellipseMode(CORNER);
	fill('rgba(255, 255, 0, 0.7)');
	ellipse(80, 80, yellowD, yellowD);
	pop();

	//green circle
	if (dist(160, 280, mouseX, mouseY) < redD/2) { //if mouse is inside red circle
		push();
	    translate(160, 280);
	    rotate(radians(angle3));
	    angle3 += 8; //rotation speed, clockwise
	    fill('rgba(0, 255, 0, 0.7)');
	    ellipse(180, 0, greenD/2, greenD/2);
	    pop();
	} else { 
		push();
		translate(160, 280);
		rotate(radians(angle4));
		angle4 += -1; //rotation speed, counterclockwise
		fill('rgba(0, 255, 0, 0.7)'); 
	    ellipse(180, 0, greenD, greenD);
	    pop();
	}

	textSize(20);
	fill(255);
	if (dist(160, 280, mouseX, mouseY) < redD/2) { //if mouse is inside red circle
		text("goodbye!", mouseX, mouseY);
	} else {
		text("hello!", mouseX, mouseY);
	}
}

For this project, I was inspired by the RGB overlay. Originally, I wanted to set a condition where if two circles overlapped, the intersection would fill white, as would happen if you overlay-ed real RGB values. In the end, I decided to create something that was bright and bubbly, playing with opacity and color.

RGB colors! My inspiration for this project.

Also, a quick note. I sort of mentioned this in the comments, but nothing is random. Everything is dependent on the position of mouseX relative to the canvas (width/2), or to the red circle. The growth of the cyan and magenta circles lag a little, but will respond.

Lingfan Jiang-Project-03-Dynamic-Drawing

lingfanj-project03

var position = -30; // set a standard position for the rectangles
var ssize = 10; // set a standard size for the rectangles
var rectcolor; //call a variable for the color of rectangles

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

}

function draw(){
    background(0);
    
    var m = max(min(mouseX, 640),0); //create a new variable "m" that give mouseX a range between 0 to 640
    var angle = m * 360 / 640; //remap the domain from 0-640 to 0-360 for angle
    var rectcolor = m * 255 / 640; // remap the domain from 0-640 
    var p = position * (1 + m / 500); //make the positions bigger over time
    var rectsize = ssize * (1 + m / 1000); //make the sizes of the rectangles bigger 

    stroke(255, rectcolor, rectcolor); //set stroke color for all the squares
    strokeWeight(0.5);
    translate(width/2, height/2); //translate the origin to the center of the canvas
    rotate(radians(angle));
    fill(255, rectcolor, rectcolor); //fill the special square 
    rect(p * 0.5,p,rectsize,rectsize); 

    //create other white squares to form a bigger square ring
    fill("white");
    rect(p,p,rectsize,rectsize);
    rect(0,p,rectsize,rectsize);
    rect(-p * 0.5,p,rectsize,rectsize);
    rect(-p,p,rectsize,rectsize);

    rect(p,p * 0.5,rectsize,rectsize);
    rect(p,0,rectsize,rectsize);
    rect(p,-p * 0.5,rectsize,rectsize);
    rect(p,-p,rectsize,rectsize);

    rect(p * 0.5,-p,rectsize,rectsize);
    rect(0,-p,rectsize,rectsize);
    rect(-p * 0.5,-p,rectsize,rectsize);
    rect(-p,-p,rectsize,rectsize);

    rect(-p,p * 0.5,rectsize,rectsize);
    rect(-p,0,rectsize,rectsize);
    rect(-p,-p * 0.5,rectsize,rectsize);


    //use the scale and rotate syntax to offset a smaller ring and rotate in a different direction
    push();
    scale(0.5);
    rotate(radians(-2 * angle));
    fill(255, rectcolor, rectcolor);
    rect(p * 0.5,p,rectsize,rectsize);

    fill("white");
    rect(p,p,rectsize,rectsize);
    rect(0,p,rectsize,rectsize);
    rect(-p * 0.5,p,rectsize,rectsize);
    rect(-p,p,rectsize,rectsize);

    rect(p,p * 0.5,rectsize,rectsize);
    rect(p,0,rectsize,rectsize);
    rect(p,-p * 0.5,rectsize,rectsize);
    rect(p,-p,rectsize,rectsize);

    rect(p * 0.5,-p,rectsize,rectsize);
    rect(0,-p,rectsize,rectsize);
    rect(-p * 0.5,-p,rectsize,rectsize);
    rect(-p,-p,rectsize,rectsize);

    rect(-p,p * 0.5,rectsize,rectsize);
    rect(-p,0,rectsize,rectsize);
    rect(-p,-p * 0.5,rectsize,rectsize);
    pop();

    //use the scale and rotate syntax to offset a bigger ring and rotate in different direction
    push();
    scale(2.2);
    rotate(radians(-2 * angle));
    fill(255, rectcolor, rectcolor);
    rect(p * 0.5,p,rectsize,rectsize);

    fill("white");
    rect(p,p,rectsize,rectsize);
    rect(0,p,rectsize,rectsize);
    rect(-p * 0.5,p,rectsize,rectsize);
    rect(-p,p,rectsize,rectsize);

    rect(p,p * 0.5,rectsize,rectsize);
    rect(p,0,rectsize,rectsize);
    rect(p,-p * 0.5,rectsize,rectsize);
    rect(p,-p,rectsize,rectsize);

    rect(p * 0.5,-p,rectsize,rectsize);
    rect(0,-p,rectsize,rectsize);
    rect(-p * 0.5,-p,rectsize,rectsize);
    rect(-p,-p,rectsize,rectsize);

    rect(-p,p * 0.5,rectsize,rectsize);
    rect(-p,0,rectsize,rectsize);
    rect(-p,-p * 0.5,rectsize,rectsize);
    pop();

    //use the scale and rotate syntax to offset a bigger ring
    push();
    scale(5);
    fill(255, rectcolor, rectcolor);
    rect(p * 0.5,p,rectsize,rectsize);

    fill("white");
    rect(p,p,rectsize,rectsize);
    rect(0,p,rectsize,rectsize);
    rect(-p * 0.5,p,rectsize,rectsize);
    rect(-p,p,rectsize,rectsize);

    rect(p,p * 0.5,rectsize,rectsize);
    rect(p,0,rectsize,rectsize);
    rect(p,-p * 0.5,rectsize,rectsize);
    rect(p,-p,rectsize,rectsize);

    rect(p * 0.5,-p,rectsize,rectsize);
    rect(0,-p,rectsize,rectsize);
    rect(-p * 0.5,-p,rectsize,rectsize);
    rect(-p,-p,rectsize,rectsize);

    rect(-p,p * 0.5,rectsize,rectsize);
    rect(-p,0,rectsize,rectsize);
    rect(-p,-p * 0.5,rectsize,rectsize);
    pop();

    //use the scale and rotate syntax to offset the biggest ring rotate in different direction
    push();
    rotate(radians(-2 * angle));
    scale(12);
    fill(255, rectcolor, rectcolor);
    rect(p * 0.5,p,rectsize,rectsize);

    fill("white");
    rect(p,p,rectsize,rectsize);
    rect(0,p,rectsize,rectsize);
    rect(-p * 0.5,p,rectsize,rectsize);
    rect(-p,p,rectsize,rectsize);

    rect(p,p * 0.5,rectsize,rectsize);
    rect(p,0,rectsize,rectsize);
    rect(p,-p * 0.5,rectsize,rectsize);
    rect(p,-p,rectsize,rectsize);

    rect(p * 0.5,-p,rectsize,rectsize);
    rect(0,-p,rectsize,rectsize);
    rect(-p * 0.5,-p,rectsize,rectsize);
    rect(-p,-p,rectsize,rectsize);

    rect(-p,p * 0.5,rectsize,rectsize);
    rect(-p,0,rectsize,rectsize);
    rect(-p,-p * 0.5,rectsize,rectsize);
    pop();


}

I got the composition idea from another elective I am taking called communication design. The assignment was to just use squares and to create different kinds of compositions. Since the composition has a strong motion in it, I thought it would be a good idea to do it in this project as well.

Catherine Coyle – Project 03 – Dynamic Drawing

catherine drawing

// Catherine Coyle
// Section C
// ccoyle@andrew.cmu.edu
// Project-03 Dynamic Drawing


var skyColor = 80;
var sunColor = 0;
var cloudPosition = 1;
var oldX = 0;
var currX = 1;
var dir = 'right';
var angle = 0;
var targetX = 0;
var targetY = 0;
var diffX = 1;
var diffY = 1;


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

function draw() {
	// sky darkens
	background(skyColor, skyColor * 2, skyColor * 4);
	noStroke();
	// sun/moon
	fill(255, 212 + (sunColor / 5), sunColor);
	ellipse(width / 2, height, 250, 250);
	fill(255, 212 + (sunColor / 5), sunColor, 50);
	ellipse(width / 2, height, 300, 300);
	fill(255, 212 + (sunColor / 5), sunColor, 25);
	ellipse(width / 2, height, 400, 400);
	// rays will rotate based on mouseY value
	push();
	translate(width / 2, height);
	rotate(angle);
	fill(255, 212 + (sunColor / 5), sunColor, 70);
	rect(145, 0, 25, 40);
	rect(-145, 0, 25, 40);
	rect(0, 145, 40, 25);
	rect(0, -145, 40, 25);
	pop();
	// bird will change the way its facing based on the mouse
	currX = mouseX
	if (currX > oldX) {
		dir = 'right';
	} else if (currX < oldX) {
		dir = 'left';
	}
	// drawing it based on direction
	if (dir == 'right') {
		// beak
		fill(252, 194, 118);
		triangle(mouseX, mouseY, mouseX - 20, mouseY + 10, mouseX - 20, mouseY - 10,)
		// bird body
		fill(232, 95, 117);
		ellipse(mouseX - 20, mouseY, 20, 20);
		triangle(mouseX - 30, mouseY, mouseX - 40, mouseY + 10, mouseX - 40, mouseY - 10)
		fill(0);
		ellipse(mouseX - 20, mouseY, 10, 10);
	} else {
		// beak
		fill(252, 194, 118);
		triangle(mouseX, mouseY, mouseX + 20, mouseY + 10, mouseX + 20, mouseY - 10,)
		// bird body
		fill(232, 95, 117);
		ellipse(mouseX + 20, mouseY, 20, 20);
		triangle(mouseX + 30, mouseY, mouseX + 40, mouseY + 10, mouseX + 40, mouseY - 10)
		fill(0);
		ellipse(mouseX + 20, mouseY, 10, 10);
	}
	// flock of birds trails the main one
	// i got the basic format for this 'easing' from the class website
	diffX = mouseX - targetX;
    diffY = mouseY - targetY;
    targetX = targetX + 0.1 * diffX;
    targetY = targetY + 0.1 * diffY;
    fill(155, 29, 44);
    if (dir == 'right') {
    ellipse(targetX - 75, targetY - 30, 15, 15);
    ellipse(targetX - 75, targetY + 30, 15, 15);
    ellipse(targetX - 150, targetY - 60, 15, 15);
    ellipse(targetX - 150, targetY + 60, 15, 15);
	} else {
		ellipse(targetX + 75, targetY - 30, 15, 15);
    	ellipse(targetX + 75, targetY + 30, 15, 15);
   		ellipse(targetX + 150, targetY - 60, 15, 15);
    	ellipse(targetX + 150, targetY + 60, 15, 15);
	}
	// clouds move opposite to the bird
	fill(227, 235, 239);
	rectMode(CENTER);
	cloudPosition = width - mouseX
	rect(cloudPosition + 50, 350, 100, 40);
	rect(cloudPosition + 30, 370, 100, 40);
	rect(cloudPosition - 150, 200, 100, 40);
	rect(cloudPosition - 180, 180, 100, 40);
	rect(cloudPosition - 350, 275, 120, 30);
	rect(cloudPosition - 380, 290, 80, 20);
	// sky darkens as bird moves
	skyColor = 80 - (mouseX / 10);
	sunColor = mouseX / 2.5;
	// adjusting various variables for the next frame (movement)
	oldX = currX
	angle = mouseY / 50;
}

I was not really sure what to do when starting this project. I started doodling a little bit and just came up with the idea of a migrating flock of birds. I wanted it to be cute and simple, but also incorporate some of the things we learned this week. I’m still not the biggest fan of rotation, but I think this project helped me get the hang of it a little better.

 

Here is my doodle from when I came up with the idea:

Jisoo Geum – Project 03 – Dynamic Drawing

Move the cursor vertically

sketch

// Jisoo Geum
// Section B
// jgeum@andrew.cmu.edu 
// Project-03
var bgr = 221;
var bgb = 212;
var bgg = 197;
var shW = 122; //shoulder width
var shH = 110; //shoulder height
var shX = 261; // x axis of shoulder
var shY = 313; // y axis of shoulder 
var lfteyeX1 = 297.91;
var lfteyeY1 = 254.05;
var lfteyeX2 = 316.61;
var lfteyeY2 = 254.05;
var rgteyeX1 = 326.4;
var rgteyeY1 = 254.05;
var rgteyeX2 = 345.1;
var rgteyeY2 = 254.05;

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

function draw(){
var my = 300 + mouseY*0.02 ; // shoulders' position change when cursor moves vertically 
var mthW = 4 + -mouseY * 0.05; // mouth width changes when cursor moves vertically
var haloSize = mouseY * .8; // size of the halo increases as the cursor moves down 
var transparencyL = mouseY * 0.3; // to make lines (and arcs) appear as the cursor moves down
var transparencyH = mouseY * 0.7; // to make the halo appear as the cursor moves down 
var relaxX = mouseY * 1.2; // to make text 'relax' moves horizontally
var transparencyT = mouseY * 0.5; //changes transpareny for the text 
var circleSizea = mouseY * .85; // the radius of the arcs changes as they rotate 
var circleSizeb = mouseY * .95;
var circleSizec = mouseY * 1.05;
var circleSized = mouseY * 1.15;
var circleSizee = mouseY * 1.25;
var circAngle = mouseY *1; // angle of which the circles in the background rotate

	background(bgr,bgb,bgg); // background color turns to white 
	if (mouseY > 0  & mouseY < height) {
	bgr = 221 + mouseY/10
	bgb = 212 + mouseY/8
	bgg = 197 +  mouseY/5
}
	//lines around the halo 
	stroke(242,187,161, transparencyL)
	strokeWeight(4);
	push();
	translate(320,240);
	rotate(mouseY/150);
	line(0,0,0,-180);
	line(0,0,86,-166);
	line(0,0,160,-100);
	line(0,0,180,0);
	line(0,0,160,100);
	line(0,0,86,166);
	line(0,0,0,180);
	line(0,0,-86,166);
	line(0,0,-160,100);
	line(0,0,-188,0);
	line(0,0,-160,-100);
	line(0,0,-86,-166);
	pop();

	//halo 
	noStroke();
	ellipseMode(CENTER);
	fill(242,187,161,transparencyH);
	ellipse (320,240,haloSize,haloSize);

	// arcs (or circles ) around the halo 
	push();
	noFill();
	stroke(242,187,161, transparencyL);
	translate(320,240);
	rotate(radians(circAngle));
	arc(0,0,circleSizea,circleSizea,PI,PI/2);
	arc(0,0,circleSizeb,circleSizeb,PI/2,TWO_PI);
	arc(0,0,circleSizec,circleSizec,TWO_PI,PI-QUARTER_PI);
	arc(0,0,circleSized,circleSized,PI-QUARTER_PI,PI);
	arc(0,0,circleSizee,circleSizee,PI,PI/2);
	pop();


	//text
	fill(255);
	textSize(50);
	textFont('impact');
	text('Relax',relaxX,100);


	//water on the floor
	fill(203,224,224);
	ellipse(320,440,530,70);
	noFill();

	//wave thingy 
	stroke(255); 
	strokeWeight(2);
	arc(320,435,320,20,PI,0);
	arc(312,438,445,52,PI, 0);
	arc(320,445,390,40, 0,PI);


	//bath tub legs 
	noStroke(); 
	fill(181);
	ellipse(176,420,15,58);
	ellipse(457,420,15,58);

	//neck
	fill(236,118,118);
	rect(311.481,282.847,20,34);

	//towel 
	fill(215,237,217);
	rect(275.37,212.36,90,60,50);

	//face
	fill(255,129,129);
	ellipse(321.06,261.31,65,75);

	//shoulder
	fill(255,129,129);
	rect(shX,my,shW,shH,20);

	// eyes
	stroke(90,129,129);
	strokeWeight(2) ;
	line(lfteyeX1, lfteyeY1,lfteyeX2,lfteyeY2);
	line(rgteyeX1,rgteyeY1,rgteyeX2,rgteyeY2);

	//mouth
	fill(236,76,119);
	noStroke();
	ellipse(321.06,282.92,mthW,4);

	//tub
	fill(255);
	arc(320,340,407,250,TWO_PI,PI);




}

This project was very fun to do but challenging at the same time since the prompt was open-ended. I wanted to give a theme to the project but also incorporate an abstract element. I ended up drawing a person resting in the bathtub whose shoulders move up and down while the cursor moves vertically. I thought I would need to use a lot of ‘if’ statements but I figured that assigning a lot of variables would be more simple. I definitely think that I could have improved the movements in the background and add more shapes to it.

Initial sketches on Adobe illustrator.

Jenna Kim (Jeeyoon Kim)- Project 3- Dynamic Drawing

jennakim03

/* Jenna Kim (Jeeyoon Kim)
Section E
jeeyoonk@andrew.cmu.edu
Project 03
*/

var xpan = 200;
var ypan = 130;
var panWidth = 145;
var panHeight = 83;
var xhandle = 44;
var yhandle = 120;
var handleWidth = 84;
var handleHeight = 12;

var xegg = 200;
var yegg = 87;
var eggWidth = 71;
var eggHeight = 100;

var xnewpan = 456; 
var ynewpan = 324;
var newpanWidth = 277;
var newpanHeight = 161;
var newxhandle = 155;
var newyhandle = 320;
var newhandleWidth = 164;
var newhandleHeight = 24;

var angle1 = 6;
var distance = 0.1;

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


function draw() {
	//background color "change" when you move the cursor
	background(234, 210, 249);
	colorMode(RGB);
	R = (mouseX / width) * 255;
	G = (mouseY / width) * 255;
	var c = color(R, G, 200);
	background(c);

  //egg rotating around mouse
  noStroke(0);
  fill(255); //
  stroke(0);
  push();
  translate(mouseX, mouseY);
  rotate(radians(angle1));
  ellipse(50, 50, eggWidth, eggHeight);
  pop();
  angle1 = angle1 + 6;
  distance = distance + 0.1;

//when you drag to the right, the egg size increase!!
if (mouseX > 420) {
    eggWidth += 0.5;
    eggHeight +=0.5
}

	//if mouse is Pressed, Fried Egg appears (size change/position change)
if (mouseIsPressed) {
	//new pan drawing
	noStroke(0);
  	fill(114, 114, 114);
  	ellipse(xnewpan, ynewpan, newpanWidth, newpanHeight);
  	fill(94, 94, 94);
  	ellipse(xnewpan, ynewpan - 10, newpanWidth, newpanHeight);
  	rect(newxhandle, newyhandle, newhandleWidth, newhandleHeight);

  	//Fried Egg
  noStroke(0);
  	fill(256);
  	ellipse(456, 316, 160, 110);
  	fill(249, 183, 65);
  	ellipse(447, 306, 71, 42);
  } else {
	push();
  	//pan drawing
  	fill(114, 114, 114);
  	ellipse(xpan, ypan, panWidth, panHeight);
  	fill(94, 94, 94);
  	ellipse(xpan, ypan - 10, panWidth, panHeight);
  	rect(xhandle, yhandle, handleWidth, handleHeight);
  	pop();
}
  print(mouseIsPressed);

  textSize(17);
  fill(50);
  text('dancing egg', mouseX + 5, mouseY, 100, 100);

}

“DON’T FORGET TO PRESS THE CANVAS”

For this project, I put five interactions in total; swinging of the egg, egg transforming to another position, and size of the pan changing when mouse is clicked, egg size increasing slowly as the mouse moves to the right, and color change of the background when mouse is moved around the canvas. Through this project, I learned that there are so many different interactions you can do just by moving, dragging, clicking the mouse.

Jenni Lee — Project 03 — Dynamic Drawing

jenni-variable-drawing

var ballDiam = 50;
var ballDiamChange = 1;
var flowerCenterX = 400;
var flowerCenterY = 300;

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

var rotation = 0;
var rotdir = 1;
var rotdirChange = 2;
var speedOldX = 2;
var speedOldY = 2;
var speedX = 2;
var speedY = 2;

var isMouseMoved = 0;
var ballPosition = 0;

function draw() {

  background(216, 216, 206);
  if (isMouseMoved == 1) {
    speedX = 0;
    speedY = 0;
    flowerCenterX = mouseX;
    flowerCenterY = mouseY;
    frameRate(10);
  } else {
    speedX = speedOldX;
    speedY = speedOldY;
    frameRate(30);
  }
  rotation += rotdir;

  flowerCenterX = flowerCenterX + speedX;
  flowerCenterY = flowerCenterY + speedY;

  // check if the ball is touching the top, 
  // reverse vertical direction
  if (flowerCenterY < ballDiam * 3 / 2) {
    flowerCenterY = ballDiam*3/2;
    speedY = 2;
  }

  if (flowerCenterY + ballDiam*3/2 > height) {
    flowerCenterY = height - ballDiam*3/2;
    speedY = -2;
  }

  // check if the ball is touching the right, 
  // reverse horizontal direction
  if (flowerCenterX + ballDiam * 3 / 2 > width) {
    flowerCenterX = width - ballDiam*3/2;
    speedX = -2;
  }

  // check if the ball is touching the left, 
  // reverse horizontal direction
  if (flowerCenterX < ballDiam * 3 / 2) {
    flowerCenterX = ballDiam*3/2;
    speedX = 2;
  }

  createFlower();
  isMouseMoved = 0;
  if (speedX != 0 & speedY != 0) {
    speedOldX = speedX;
    speedOldY = speedY;
  }
}

function mouseMoved() {
  ballDiam += ballDiamChange;

  // change ball size when mouse moves
  if (ballDiam >= 100) {
    ballDiam = 100;
    ballDiamChange = -1;
  } else if (ballDiam <= 25) {
    ballDiam = 25;
    ballDiamChange = 1
  }

  // change rotation speed and direction when ball moves
  rotdir += rotdirChange;
  if (rotdir >= 10) {
    rotdir = 10;
    rotdirChange = -2;
  } else if (rotdir <= -10) {
    rotdir = -10;
    rotdirChange = 2;
  }

  // change ball color location when mouse moves
  ballPosition++;
  if (ballPosition == 6) {
    ballPosition = 0;
  }

  isMouseMoved = 1;
}

//create center of flower
function createFlower() {

  push();
  fill(251, 246, 178);
  noStroke();
  ellipseMode(CENTER);
  translate(flowerCenterX, flowerCenterY)
  ellipse(0, 0, ballDiam, ballDiam);

  // using sin and cos to determine coordinates 
  // of the surrounding balls
  angleMode(DEGREES); 
  rotate(rotation);
  fill(85, 78, 104);
  ellipse(ballDiam * cos(60 * ballPosition), ballDiam * sin(60 * ballPosition), ballDiam, ballDiam);
  fill(135, 133, 142);
  ellipse(ballDiam * cos(60 * (ballPosition + 1)), ballDiam * sin(60 * (ballPosition + 1)), ballDiam, ballDiam);
  fill(173, 169, 182);
  ellipse(ballDiam * cos(60 * (ballPosition + 2)), ballDiam * sin(60 * (ballPosition + 2)), ballDiam, ballDiam);
  fill(196, 194, 198);
  ellipse(ballDiam * cos(60 * (ballPosition + 3)), ballDiam * sin(60 * (ballPosition + 3)), ballDiam, ballDiam);
  fill(241, 239, 243,);
  ellipse(ballDiam * cos(60 * (ballPosition + 4)), ballDiam * sin(60 * (ballPosition + 4)), ballDiam, ballDiam);
  fill(49, 44, 66);
  ellipse(ballDiam * cos(60 * (ballPosition + 5)), ballDiam * sin(60 * (ballPosition + 5)), ballDiam, ballDiam);
  pop();
}

For this dynamic drawing, I wanted to experiment with the abstraction of a flower. Using dynamic movements, I wanted to convey the feeling of a flower floating through the breeze. Through the dynamic elements of size, position, color, rotation, and speed rotation direction, I was able to execute this idea. This project required a lot of effort for me, as not only did I have to look up many references on the p5 website and experiment with those features, but it also took me a while to figure out the positioning of the circles on this flower. Although it was difficult to accomplish, as I decided to take on the task of utilizing various features which I had previously never used before, such as using sin and cos, it ultimately was a good learning experience.

Related image

Here is the flower which I abstracted.