Dynamic Drawing-Lydia Jin

sketch

var offset=50;
var barX=offset
var barY;
var barW;
var barH=30;
var sliderX = offset
var sliderY;
var sliderW=50;
var sliderH=30;
var modify=50;
var colorR=133;
var colorG=209;
var colorB=228;

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

function draw() {
	background(colorR,colorG,colorB);
	fill(255);
	barY=height-50;
	barW=width-2*offset;
	rect(barX,barY,barW,barH);
	//draw slider box
	fill(247,176,193);
	sliderY=barY
	rect(sliderX,sliderY,sliderW,sliderH);
	//draw slider
	fill(144,217,148);
	ellipse(modify,modify,modify/2);
	//draw circle in the top left corner
	fill(116,100,185);
	ellipse(640-modify,480-modify,modify/2);
	//draw circle in the bottom right corner
	fill(255,204,222);
	ellipse(640-modify,modify,modify/2);
	//draw circle in bottom left corner
	fill(255,107,29);
	ellipse(modify,480-modify,modify/2);
	//draw circle in top right corner
	push();
	translate(width/2,height/2);
	rotate(millis()/sliderX);
	fill(62+sliderX/5,116,44);
	rotate(radians(0));
	ellipse(50,50,50,100);
	rotate(radians(50));
	ellipse(100,100,50,100);
	rotate(radians(100));
	ellipse(150,150,50,100);
	rotate(radians(150));
	ellipse(200,200,50,100);
	pop();
	//draw leaves falling down, leaves rotate in different speeds. 
	//Leaves turn from green to brown as slider moves.
}

function mouseMoved(){
	var sliderMax=width-offset-sliderW;
	if (mouseY>=barY & mouseY<=barY+barH){
        sliderX=max(min(mouseX,sliderMax),barX);
	    modify=sliderX/0.8+50;
	// if statement restrains that mouse can only be moved within the slider bar. The modify changes shapes of the circles. 
	}


}

The drawing I am presenting is named falling leaves. The user can put their mouse on the slider and move the mouse within the slider bar to see changes of how the tornado turned leaves from green to brown. The leaves spin really fast in the beginning and slows down once the slider is at the right end. The 4 circles represent people as they come and go and disappear. It should leave a sad feeling in the end as the leaves slowly whirls.

zhuoyinl-Project-03

my-sketch.js

//Zhuoying Lin
//section A
//zhuoyinl@andrew.cmu.edu
//project03


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

function draw() {
	background('lightPink');

	//box
	fill(255-(0.1*mouseX));
	noStroke();
	rect(0, 400-(0.75*mouseX), 0.125*mouseX, 0.125*mouseX);
	rect(mouseX, 0, 0.125*mouseX, 0.125*mouseX);
	rect(560-mouseX, 400, 0.125*mouseX, 0.125*mouseX);
	rect(560, 0.75*mouseX, 0.125*mouseX, 0.125*mouseX);

	//circles
	push();
	fill(255-(0.5*mouseX));
	noStroke();
	translate(320, 240);
	rotate((millis())/(mouseX*10));
	ellipse(-50, 0, 100, 100);
	fill(0+(0.5*mouseX));
	ellipse(50, 0, 100, 100);
	pop();

}

I tried to make some uniformed variables that changing with mouse movement and form a pattern. Here is my solution.

SiminLi- Project 3 One Point Perspective Dynamic Drawing

siminl-project3

// Simin Li
// Section C
// siminl@andrew.cmu.edu
// Project 3
var sqrMin = 20;
var sqrMax = 180; //limitations to size of square
var vanishX = 320;
var vanishY = 240;
var X1 = 200;
var Y1 = 120;
var A1 = 20; //coordinates and length of top left large square

var X2 = 440;
var Y2 = 120;
var A2 = 20; //coordinates and length of top right large square

var X3 = 200;
var Y3 = 360;
var A3 = 20;//coordinates and length of bottom left large square

var X4 = 440;
var Y4 = 360;
var A4 = 20;//coordinates and length of bottom right large square

var light = 255; //control brightness of large suqares and background

function setup() {
    createCanvas(640, 480);
}
function draw() {
    colorMode(RGB);
	background(255 - light);//changes the color of the background with respect to distance from 
    //vanishing points to center of canvas
    rectMode(CENTER); 
    noCursor();//remove mouse

var from14 = color(255,255 ,0);//"Yellow"; first base color for squares 1 and 4
var to14 = color(65,105,225);//"RoyalBlue"; second base color for squares 1 and 4
var from23 = color( 0,191,255); //"Deepskyblue"; first base color for squares 2 and 3
var to23 = color(255,255 ,0);//"Yellow"; second base color for squares 2 and 3
	
    A1 = map(dist(vanishX,vanishY,X1,Y1),0, dist(X1,Y1,640,480),sqrMin,sqrMax);
	var a1 = A1 * 2 / 3; //length of small squares is always a third of the large squares
	A2 = map(dist(vanishX,vanishY,X2,Y2),0, dist(X2,Y2,0,480),sqrMin,sqrMax);
    var a2 = A2 * 2 / 3;
    A3 = map(dist(vanishX,vanishY,X3,Y3),0, dist(X3,Y3,640,0),sqrMin,sqrMax);
    var a3 = A3 * 2 / 3;
    A4 = map(dist(vanishX,vanishY,X4,Y4),0, dist(X4,Y4,0,0),sqrMin,sqrMax);
    var a4 = A4 * 2 / 3;
    // length of sqaures is correlated to the distance from square center to farthest corner

    light = map(dist(vanishX,vanishY,width / 2,height / 2),0, dist(width / 2,height / 2,0,0),0,255);
    //changes the color of the background with respect to distance from vanishing points to center of canvas
  
    fill(light);
    rect(X1,Y1,A1,A1);
    rect(X2,Y2,A2,A2);
    rect(X3,Y3,A3,A3);
    rect(X4,Y4,A4,A4); // draw large squares

	vanishX = min( max(0,mouseX),640);
    vanishY = min(max(0,mouseY), 480);//vanish point of one point perspective
    
    var x1 = (2 * X1 + vanishX) / 3; 
    var y1 = ((vanishY - Y1) / (vanishX - X1)) * (x1 - X1) + Y1; //position of small squares are at
    // a third of vanishing point and center of large square
    var X1L = X1 - A1 / 2;
    var X1R = X1 + A1 / 2;
    var Y1T = Y1 - A1 / 2;
    var Y1B = Y1 + A1 / 2;// coordinates of 4 corners of large squares(used later to draw lines)
    var x1L = x1 - a1 / 2;
    var x1R = x1 + a1 / 2;
    var y1T = y1 - a1 / 2;
    var y1B = y1 + a1 / 2; // coordinates of 4 corners of small squares
	

	
	
	strokeWeight(4);
	line(X1L, Y1T, x1L, y1T);//top left connect 
    line(X1R, Y1T, x1R, y1T);//top right connect
    line(X1L, Y1B, x1L, y1B);//bottom left connect
    line(X1R, Y1B, x1R, y1B);//bottom right connect

    var x2 = (2 * X2 + vanishX) / 3; 
    var y2 = ((vanishY - Y2) / (vanishX - X2)) * (x2 - X2) + Y2;
    var X2L = X2 - A2 / 2;
    var X2R = X2 + A2 / 2;
    var Y2T = Y2 - A2 / 2;
    var Y2B = Y2 + A2 / 2;
    var x2L = x2 - a2 / 2;
    var x2R = x2 + a2 / 2;
    var y2T = y2 - a2 / 2;
    var y2B = y2 + a2 / 2;
    

	strokeWeight(4);
	line(X2L, Y2T, x2L, y2T);//top left connect 
    line(X2R, Y2T, x2R, y2T);//top right connect
    line(X2L, Y2B, x2L, y2B);//bottom left connect
    line(X2R, Y2B, x2R, y2B);//bottom right connect

    var x3 = (2 * X3 + vanishX) / 3; 
    var y3 = ((vanishY - Y3) / (vanishX - X3)) * (x3 - X3) + Y3;
    var X3L = X3 - A3 / 2;
    var X3R = X3 + A3 / 2;
    var Y3T = Y3 - A3 / 2;
    var Y3B = Y3 + A3 / 2;
    var x3L = x3 - a3 / 2;
    var x3R = x3 + a3 / 2;
    var y3T = y3 - a3 / 2;
    var y3B = y3 + a3 / 2;

	strokeWeight(4);
	line(X3L, Y3T, x3L, y3T);//top left connect 
    line(X3R, Y3T, x3R, y3T);//top right connect
    line(X3L, Y3B, x3L, y3B);//bottom left connect
    line(X3R, Y3B, x3R, y3B);//bottom right connect

    var x4 = (2 * X4 + vanishX) / 3; 
    var y4 = ((vanishY - Y4) / (vanishX - X4)) * (x4 - X4) + Y4;
    var X4L = X4 - A4 / 2;
    var X4R = X4 + A4 / 2;
    var Y4T = Y4 - A4 / 2;
    var Y4B = Y4 + A4 / 2;
    var x4L = x4 - a4 / 2;
    var x4R = x4 + a4 / 2;
    var y4T = y4 - a4 / 2;
    var y4B = y4 + a4 / 2;

    strokeWeight(4);
    line(X4L, Y4T, x4L, y4T);//top left connect 
    line(X4R, Y4T, x4R, y4T);//top right connect
    line(X4L, Y4B, x4L, y4B);//bottom left connect
    line(X4R, Y4B, x4R, y4B);//bottom right connect
    
    colorMode(RGB);
    inter1 = lerpColor(from14, to14,dist(vanishX,vanishY,X1,Y1) / dist(X1,Y1,height,width));// far right corner is(640,480)
    inter4 = lerpColor(from14, to14,dist(vanishX,vanishY,X4,Y4) / dist(X4,Y4,0,0));// far left corner is(0,0)
    inter2 = lerpColor(from23, to23,dist(vanishX,vanishY,X2,Y2) / dist(X2,Y2,0,height));//far left corner is(0,640)
    inter3 = lerpColor(from23, to23,dist(vanishX,vanishY,X3,Y3),0, dist(X3,Y3,width,0)); //fills squares based 
    //their distance from their furthest corner(according to x, y position)
    //far right corner is(640,0)
    fill(inter1);         
    rect(x1,y1,a1,a1);
    fill(inter4); 
    rect(x4,y4,a4,a4); 
    fill(inter2); 
	rect(x2,y2,a2,a2);
    fill(inter3); 
	rect(x3,y3,a3,a3); //draw and fill small squares 
  
    
     push();  //draw rotating flower to replace cursor
    translate(mouseX,mouseY);
    scale(2, 1); //stretched horizontally to 2 times
    rotate(millis() / 1000) ;
    noStroke();

    fill(255);
    ellipse(0,0,20,4);
    ellipse(0,0,4,20);//white petals 

    push();
    rotate(PI/4.0);
    ellipse(0,0,20,4);
    ellipse(0,0,4,20);//white petals that are rotated 45 degrees 
    fill("Gold");
    ellipse(0,0,5,5);//center
    pop(); 
    pop();
}

The idea for this project was inspired by learning about one point perspective, two point perspective and three point perspective images in drawing class. In one point perspective images all lines on the yz plane intersect at one point called the vanishing point. the rest of the lines are parallel. The vanishing point in this dynamic drawing is the flower and the boxes are leaves.

project-3-2project-3

mdambruc-Project-03-Dynamic Drawing

project-03

//Mairead Dambruch
//mdambruc@andrew.cmu.edu
//Section C
//Project-03
var xT;// x value for turquoise circles
var yT; // y value for turquoise circles

var diamx = 30; //x value diameter
var diamy = 30; // y value diameter

var diffx = 0;
var diffy = 0;// x and y values to get dragging effect

var drag = .05; //speed of dragging effect

var swarmX = 300;
var swarmY = 300;// original ball orientation

var swarmXA = 200;
var swarmYA = 200;//copy A ball orientation

var swarmXB = 100;
var swarmYB = 100;//copy B ball orientation

var swarmXC = 400;
var swarmYC = 400;//copy C ball orientation

function setup() {
    createCanvas(640, 480);
    xT = width/2;
    yT = height/2; // original orientation of turqoise circles
}

function draw() {

  var colR = map(mouseY, 0, height, 0, 255);
  var colG = map(mouseY, 0, height, 95, 95);
  var colB = map(mouseY, 0, height, 120, 120); //magic numbers are being used for color
    background(colR, colG, colB);

  diffx = mouseX - swarmX;
  diffy = mouseY - swarmY; // subtracting to get same position

  swarmX = swarmX + drag*diffx;
  swarmY = swarmY + drag*diffy; //specific speed of drag

  noStroke();
  fill(255);
  ellipse(swarmX, swarmY, diamx, diamy);//original circle

  diffx = mouseX - swarmXA;
  diffy = mouseY - swarmYA;
  swarmXA = swarmXA + (drag*2) *diffx;
  swarmYA = swarmYA + (drag*2) *diffy;
  noStroke();
  fill(255);
  ellipse(swarmXA, swarmYA, diamx, diamy);//altered circle A

  diffx = mouseX - swarmXB;
  diffy = mouseY - swarmYB;
  swarmXB = swarmXB + (drag/2)*diffx;
  swarmYB = swarmYB + (drag/2)*diffy;
  noStroke();
  fill(255);
  ellipse(swarmXB, swarmYB, diamx, diamy);//altered circle B

  diffx = mouseX - swarmXC;
  diffy = mouseY - swarmYC;
  swarmXC = swarmXC + (drag/4) *diffx;
  swarmYC= swarmYC + (drag/4) *diffy;
  noStroke();
  fill(255);
  ellipse(swarmXC, swarmYC, diamx, diamy);//altered circle C

  if (mouseIsPressed) //changes x diameter of ellipses
   diamx = 50;
   else {
     diamx = 30;
   }

  noStroke();
  fill("Turquoise");
  ellipse(xT, yT, diamx, diamy); //original turquoise circle
  noStroke();
  fill("Turquoise");
  ellipse(xT, yT/2, diamx, diamy); // altered position
  noStroke();
  fill("Turquoise");
  ellipse(xT/2, yT/2, diamx, diamy);//Altered position
  noStroke();
  fill("Turquoise");
  ellipse(xT/2, yT, diamx, diamy);//altered position

  if (mouseX > xT) {
    xT -= 1;
    offset = 5;//moves circles to the left if x variable of mouse is greater
  }

  if (mouseX < xT){
    xT += 1;
    offset = 5; // moves circles to the right if x variable of mouse is lesser
  }
}

I struggled a lot with many aspects of this assignment – mostly the functions and how they are able to be used without effecting other parts of the drawing. My drawing uses a few functions to vary different aspects of the piece and I am hoping to get better at being efficient at variables and hopefully more elaborate with designs. My drawing uses both the position of the mouse and the mousePressed function.

Project-03-Dynamic Drawing

I wanted to experiment with triangles; when the first run came out okay, I gave it the company of 4 little ones. With the mouse pointer rolling around the screen, the motion is butterfly like.

I would have preferred the colors inside the triangles.

james-dynamicdrawing

//James Katungyi
//Section A 0900
//jkatungy@andrew.cmu.edu
//Assignment-Project-03

//butterfly1
var Wide = 300;
var Space = (310 - Wide);//fix space between triangles
var High = 4*Wide/5;
//butterfly 2,3,4,5
var Wide2 = 120;
var Space2 = (130 - Wide2); //fix space between triangles
var High2 = 4*Wide2/5;

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

function draw() {
//map canvas background color to mouse X position
    var colR = map(mouseX,0,width,0,255);
    var colG = map(mouseX,0,width,0,0);
    var colB = map(mouseX,0,width,255,0);
    background (colR,colB,colG);
//map triangle base to mouse X & Y position on canvas
//when mouse X is in left half, triangle width reduces
	if (mouseX<=320){
	Wide = map(mouseX,10,320,30,150);
    Wide2 = map(mouseX,10,320,20,60);
    } 
//when mouse X is in right half, triangle width increases
    if ((mouseX>320) & (mouseX<640)){	
	Wide = map(mouseX,320,620,150,300);
    Wide2 = map(mouseX,320,620,60,120);
    }
//when mouse Y is in top half, triangle height reduces
    if (mouseY<=240){
	High = map(mouseY,0,240,20,120);
    High2 = map(mouseY,0,240,10,48);
    } 
//when mouse Y is in bottom half, triangle height increases
    if ((mouseY>240) & (mouseY<480)){	
	High = map(mouseY,240,480,120,240);
    High2 = map(mouseY,240,480,48,96);
    }
//butterfly 1 - center
    push();
    translate(width/2,height/2); //locate origin of triangle canvas at center of original canvas
    triangle(-Wide/2,-High/2,Wide/2,-High/2,0,High/2);//middle triangle
    triangle(-Wide/2-Space,-High/2,-Space-Wide,High/2,-Space,High/2);//left triangle
    triangle(Wide/2+Space,-High/2,Space+Wide,High/2,Space,High/2); //right triangle
    pop();
//butterfly 2 - top left
    push();
    translate(width/4,60); //relocate canvas origin to top left
    triangle(-Wide2/2,-High2/2,Wide2/2,-High2/2,0,High2/2);//middle triangle
    triangle(-Wide2/2-Space2,-High2/2,-Space2-Wide2,High2/2,-Space2,High2/2);//left triangle
    triangle(Wide2/2+Space2,-High2/2,Space2+Wide2,High2/2,Space2,High2/2); //right triangle
    pop();
//butterfly 3 - top right
push();
    translate(width - width/4,60); //relocate canvas origin to top right
    triangle(-Wide2/2,-High2/2,Wide2/2,-High2/2,0,High2/2);//middle triangle
    triangle(-Wide2/2-Space2,-High2/2,-Space2-Wide2,High2/2,-Space2,High2/2);//left triangle
    triangle(Wide2/2+Space2,-High2/2,Space2+Wide2,High2/2,Space2,High2/2); //right triangle
    pop();
//butterfly 4 - bottom left
    push();
    translate(width/4,420); //relocate canvas origin to bottom left
    triangle(-Wide2/2,-High2/2,Wide2/2,-High2/2,0,High2/2);//middle triangle
    triangle(-Wide2/2-Space2,-High2/2,-Space2-Wide2,High2/2,-Space2,High2/2);//left triangle
    triangle(Wide2/2+Space2,-High2/2,Space2+Wide2,High2/2,Space2,High2/2); //right triangle
    pop();
//butterfly 5 - bottom right
push();
    translate(width - width/4, 420); //relocate canvas origin to top bottom right
    triangle(-Wide2/2,-High2/2,Wide2/2,-High2/2,0,High2/2);//middle triangle
    triangle(-Wide2/2-Space2,-High2/2,-Space2-Wide2,High2/2,-Space2,High2/2);//left triangle
    triangle(Wide2/2+Space2,-High2/2,Space2+Wide2,High2/2,Space2,High2/2); //right triangle
    pop();
}

Michal Luria – Project 03 – Dynamic Drawing

mluria-project03

/*  Submitted by: Michal Luria
	Section A: 9:00AM - 10:20AM
	mluria@andrew.cmu.edu
	Assignment-03-A
*/

var space = 130; //space between squares 

function setup() {
    createCanvas(640, 480);
}
 
function draw() {
 
    noStroke();
    
    //pink square location determined by blue square
    var pinkSqX = width - mouseX; 
    var pinkSqY = height - mouseY;

    //map mouse movement to background range
    var bg = map(mouseY, 0, height, 150, 255);

    //map distance from center to square size
    var distCenter = dist(mouseX, mouseY, width/2, height/2);
    var sqSize = map(distCenter, 0, 300, 50, 400);
    
    background(bg);
    rectMode(CENTER);

    //top square
    fill("LightBlue");
    rect(mouseX, mouseY, sqSize, sqSize); 

    //bottom square
    fill("LightPink");
    rect(pinkSqX, pinkSqY, sqSize, sqSize);

    rectMode(CORNER);
    //top rect
    fill("DarkBlue");
    rect(0, 30, mouseX - space, 200);  

    fill("DeepPink");
    //bottom rect
    rect(pinkSqX + space, 250, mouseX - space, 200); 

}

Project 3: Dynamic Drawing

sketch

/*Emma Shi
Section B
eyshi@andrew.cmu.edu
Project 3
*/

function setup() {
    createCanvas(640, 480);
}
function draw() {
    var ellipseR = map(0, mouseX, height, 255, 254);
    var ellipseG = map(0, mouseX, height, 203, 138);
    var ellipseB = map(0, mouseX, height, 2, 5);
    var backR = map(0, mouseX, height, 15, 139);
    var backG = map(0, mouseX, height, 19, 237);
    var backB = map(0, mouseX, height, 37, 255);

    background(backR, backG, backB);
    //background changes from navy to light blue as mouse moves across
    fill(ellipseR, ellipseG, ellipseB);
    ellipse(320, 240, 100, 100);
    //circle changes from yellow to orange as mouse moves across

    var xHeight = map(0, mouseX, height, 640, 480);
    var xWidth = map(0, mouseX, height, 640, 480);
    ellipse(width/2, height/2, xWidth, xHeight);
    //changes size (height) of circle 

    fill(255);
    rect(width-mouseX, height/500, 50, 50);
    rect(width-mouseX, height/8, 50, 50);
    rect(width-mouseX, height/4, 50, 50);
    rect(width-mouseX, height/2.67, 50, 50);
    rect(width-mouseX, height/2, 50, 50);
    rect(width-mouseX, height/1.6, 50, 50);
    rect(width-mouseX, height/1.33, 50, 50);
    rect(width-mouseX, height/1.14, 50, 50);
    //transition rectangles that change direction with mouseX

    fill(248, 221, 136);
    noStroke();
    angleMode(DEGREES);
    var rot = atan2(mouseY-height/2, mouseX-width/2);
    push();
    translate(width/2, height/2);
    rotate(rot);
    rect(130, 150, 60, 60);
    rect(-190, 150, 60, 60);
    rect(-250, -100, 60, 60);
    rect(-80, -250, 60, 60);
    rect(160, -170, 60, 60);
    rect(200, -10, 60, 60);
    pop();
    //changes rotation of rectangles around the circle

    }

For this project, I had for the screen to switch from an abstract, simplistic version of nighttime to daytime. As the user moves the mouse from left to right, the background changes from navy to light blue, and the “sun” (circle in the middle) changes from yellow to orange. The rotating rectangles around can represent craters of the moon or rays of sun.

I also took the idea of a changing “slide” (the column of rectangles that moves through the image) as a transition aide that allows the viewer to move from seeing the “night” to “day” (and vice versa).

Jessica Medenbach – Dynamic Drawing

dynamicdrawing

var x= 320;
var y= 240;
var d=200;
var ballR= 238;
var ballB= 135;
var ballG= 131;
var ball2=2;
var ball3=4;

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

function draw() {
    background(232, 167, 0);
    noStroke(0);

    //eye

    fill(255);
    ellipse(x,y,2*d,2*d);
    fill(ballR,ballB,ballG);
    ellipse(x,y,d,d);
    fill(ball2*ballR,ball2*ballB,ball2*ballG);
    ellipse(x,y,d/3,d/3);

}
 function mousePressed() {
  if (dist(mouseX, mouseY, x, y) < d/2) {
    ballG=random(50,250);
  }

 if (dist(mouseX, mouseY, x, y) < d/2) {
    ballR=random(50.250);

}
 
 if (dist(mouseX, mouseY, x, y) < d/2) {
    ballB=random(50,250);
}

 if (dist(mouseX, mouseY, x, y) < d/2) {
    d=random(20,400);
}

 if (dist(mouseX, mouseY, x, y) < d/2) {
 	x=(random(200,400));

}


 if (dist(mouseX, mouseY, x, y) < d/2) {
 	y=(random(0,480));

}

}

Exploring randomizing color and position through mouse control while keeping an object in tact.

Dynamic Drawing – sehenry

While working on this project, I had a lot of trouble figuring out what the boundaries and positions of my shapes would be and which actions should they do. With a couple of restarts, I finally decided what my art would look like and I am very happy with the result. It took me a little bit but I got it done!

sketch

//Seth Henry

//Section B 10:30 Tuesday

//sehenry@andrew.cmu.edu

//Assignment- Dynamic Drawing





var cirDiam = 200
var sqLength = 200
var B = 100
var sizeR = 60
var sizeE =60



function setup() {
    createCanvas(640, 480);
    
    text("p5.js vers 0.5.2 test.", 10, 15);
}

function draw() {
	colR = map(mouseX, 0, width, 0, 100); //sliding left and right will change background from black to blue
	colG = map(mouseX, 0, width, 20, 150);
	colB = map(mouseX, 0, width, 10, 200);
	background(colR, colG, colB);


	if (mouseX > width/2) { //if mouse is on the right half of the screen, an ellipse will apear
		fill(B);
		ellipse(width/2, height/2, cirDiam, cirDiam);
	} 

	if (mouseX < width/2){ //if mouse is on the left half of the screen, a rect will appear
	fill(B); 
	rectMode(CENTER);
	rect(width/2, height/2, sqLength, sqLength);
	}


push(); //small circle spinning clockwise
	fill(random(0,255));
	rotate(millis()/1000);
	ellipse(160, 360, sizeE, sizeE);
	pop(); 

	push(); //small circle spinning counterclockwise
	fill(random(0,255));
	rotate(-millis()/1000);
	ellipse(480, 360, sizeE, sizeE);
	pop();
	  

	var oppositeX = width-mouseX //Similar to old project (Allows circles and rectangles to be placed opposite of one another)
	var oppositeY = height -mouseY
 
    fill(255); //opposite X rectangle
    rect(mouseX, height/2, sizeR, sizeR);
 
    fill(0); //opposite X ellipse
    ellipse(oppositeX, height/2, sizeE, sizeE);

    
    fill(255); //opposite Y rectangle
   	rect(width/2, mouseY, sizeR, sizeR);
	

    fill(0); //opposite Y ellipse
    ellipse(width/2, oppositeY, sizeE, sizeE);

    textAlign(CENTER); //allows my name to follow the mouse and grow or shrink depending on placement
    textStyle(BOLD);
    textSize(mouseY-mouseX);
    text("SethHenry", mouseX, mouseY);


    push(); //rotates the rectangle found in the middle
    fill(B);
    translate(width/2, height/2);
    rotate(radians((mouseX/2)%180));
    rect(0,0, 50, 50);
    pop();

}

function mousePressed() { //if mouse is pressed...
	if (dist(mouseX, mouseY, width/2, height/2) < 100 ) {
		B=random(0,255); //the color of the non spinning circles and the rectangles will change color
		sizeR=random(10,100); // the size of the opposite rectangle will change size
		sizeE=random(10,100); // the size of the opposite ellipse will change color


		
	}

}


ShanWang-Project-03-Dynamic-Drawing

Slide the mouse left to right to change the color and the size of the circles.

Slide the mouse up and down to change the speed of the rotation.

In this project I created a series of circles that rotates around the previous one.

The color, size and therefore position of the circles are controlled by the change in x coordinate of the mouse.
The speed of rotation is controlled by the the change in y coordinate of the mouse.

sketch

//Shan Wang
//Section A
//shanw1@andrew.cmu.edu
//Assignment-03-Project



var radius1 = 200
var angle1 = 0
var angle2 = 0
var angle3 = 0
var angle4 = 0
var angle5 = 0
var angle6 = 0
var angle7 = 0
var angle8 = 0
var angle9 = 0
var angle10 = 0
var speed = 128
var fillColor = 0


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

function mousePressed(){
    if (width/2-radius1 <= mouseX <= width/2+radius1){
        bgColor = 255-bgColor
    }
}
 
function draw() {
    background(255);
    noStroke();

    //control the speed of spining with the change in y coordinate of the mouse
    speed = map(mouseY,0,height,64,192);

    //control the color of circles with the change in x coordinate of the mouse
    bgColor = map(mouseX,0,width,0,255);

    //control the size of all the circles with the change in x coordinate of the mouse
    radius1 = map(mouseX,0,width,100,200);

    //position of first big circle
    var cenX1 = width/2;
    var cenY1 = height/2;
    fill(bgColor);
    ellipse(cenX1, cenY1, radius1*2, radius1*2);

    //draw second circle
    translate(cenX1,cenY1);
    fill(255-bgColor);
    angle1 += PI/speed;
    var radius2 = 2/3*radius1;
    var dis2 = radius1 - radius2;
    var cenX2 = dis2*cos(angle1);
    var cenY2 = dis2*sin(angle1);
    ellipse(cenX2, cenY2,radius2*2, radius2*2);

    //draw third circle
    translate(cenX2,cenY2);
    fill(bgColor);
    angle2 += PI/(0.5*speed);
    var radius3 = 2/3*radius2;
    var dis3 = radius2 - radius3;
    var cenX3 = dis3*cos(angle2);
    var cenY3 = dis3*sin(angle2);
    ellipse(cenX3, cenY3, radius3*2,radius3*2);

    //draw 4th circle
    translate(cenX3,cenY3);
    fill(255-bgColor);
    angle3 += PI/((0.5*speed));
    var radius4 = 2/3*radius3;
    var dis4 = radius3 - radius4;
    var cenX4 = dis4*cos(angle3);
    var cenY4 = dis4*sin(angle3);
    ellipse(cenX4, cenY4, radius4*2,radius4*2);

    //draw 5th circle
    translate(cenX4,cenY4);
    fill(bgColor);
    angle4 += PI/(0.4375*speed);
    var radius5 = 2/3*radius4;
    var dis5 = radius4 - radius5;
    var cenX5 = dis5*cos(angle4);
    var cenY5 = dis5*sin(angle4);
    ellipse(cenX5, cenY5, radius5*2,radius5*2);


    //draw 6th circle
    translate(cenX5,cenY5);
    fill(255-bgColor);
    angle5 += PI/(0.375*speed);
    var radius6 = 2/3*radius5;
    var dis6 = radius5 - radius6;
    var cenX6 = dis6*cos(angle5);
    var cenY6 = dis6*sin(angle5);
    ellipse(cenX6, cenY6, radius6*2,radius6*2);

    //draw 7th circle
    translate(cenX6,cenY6);
    fill(bgColor);
    angle6 += PI/(0.25*speed);
    var radius7 = 2/3*radius6;
    var dis7 = radius6 - radius7;
    var cenX7 = dis7*cos(angle6);
    var cenY7 = dis7*sin(angle6);
    ellipse(cenX7, cenY7, radius7*2,radius7*2);

    //draw 8th circle
    translate(cenX7,cenY7);
    fill(255-bgColor);
    angle7 += PI/(0.125*speed);
    var radius8 = 2/3*radius7;
    var dis8 = radius7 - radius8;
    var cenX8 = dis8*cos(angle7);
    var cenY8 = dis8*sin(angle7);
    ellipse(cenX8, cenY8, radius8*2,radius8*2);

    //draw 9th circle
    translate(cenX8,cenY8);
    fill(bgColor);
    angle8 += PI/(0.125*speed);
    var radius9 = 1/2*radius8;
    var dis9 = radius8 - radius9;
    var cenX9 = dis9*cos(angle8);
    var cenY9 = dis9*sin(angle8);
    ellipse(cenX9, cenY9, radius9*2,radius9*2);

    //draw 10th circle
    translate(cenX9,cenY9);
    fill(255-bgColor);
    angle9 += PI/(0.125*speed);
    var radius10 = 1/2*radius9;
    var dis10 = radius9 - radius10;
    var cenX10 = dis10*cos(angle9);
    var cenY10 = dis10*sin(angle9);
    ellipse(cenX10, cenY10, radius10*2,radius10*2);

    //draw 11th circle
    translate(cenX10,cenY10);
    fill(bgColor);
    angle10 += PI/(0.25*speed);
    var radius11 = 1/2*radius10;
    var dis11 = radius10 - radius11;
    var cenX11 = dis11*cos(angle10);
    var cenY11 = dis11*sin(angle10);
    ellipse(cenX11, cenY11, radius11*2,radius11*2);

}