cchau1 – Project03 – Dynamic Drawing

sketch

var rectT = 300;
var rectB = 500;
var rectW = 80;
var blackH = 10;
var blackW = 80;
var boxH = 150;
var crayonPos = 10;
var windowW = 20;
var angle = 0;

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

}

function draw() {
    var color1 = color(60,200,255);
    var color2 = color(200,212,240);
    var t = map(mouseY,0,width,0,1);
    var bgColor = lerpColor(color1,color2,t);
  // wanted to try the lerpColor function and the hues are controlled
  // by the mouseY function; supposedly represents a sky

    background(bgColor);

  //mock sun
     push();
     fill(255,240,20);
     rotate(radians(mouseX));
     rectMode(CENTER); // center rect around 0,0
     rect(10,10, 200,200);
     pop();
     angle = angle + 5;

  //windows to emulate a classroom
    fill(255);
    rect(0,0,windowW,height);
    rect(0,0,width,windowW);
    rect(height/2,0,windowW,height);
    rect(width-40,0,windowW,height);
    rect(0,height/2,width,windowW);

//these if-statements are to control the height of the specific crayon
//when the cursor is within the range of that specific crayon
//controls red crayon
    if (10<=mouseX & mouseX<=100){
      fill(255,0,0);
      rect(10, mouseY,rectW,height-boxH-mouseY);

    }
//controls orange crayon
    if (110<=mouseX & mouseX<=200){
      fill(255,165,2);
      rect(110, mouseY,rectW,height-boxH-mouseY);

//controls yellow crayon
    }
    if (210<=mouseX & mouseX<=300){
      fill(255,252,17);
      rect(210, mouseY,rectW,height-boxH-mouseY);

//controls green crayon
    }
    if (310<=mouseX & mouseX<=400){
      fill(48,201,63);
      rect(310, mouseY,rectW,height-boxH-mouseY);

//controls blue crayon
    }
    if (410<=mouseX & mouseX<=500){
      fill(45,76,255);
      rect(410, mouseY,rectW,height-boxH-mouseY);
//controls purple crayon
    }
    if (510<=mouseX & mouseX<=600){
      fill(132,21,255);
      rect(510, mouseY,rectW,height-boxH-mouseY);

//draws all the crayons by calling it (mostly for practice calling functions)
    }
    Red();
    Orange();
    Yellow();
    Green();
    Blue();
    Purple();

    //crayon box remains constant
    fill(243,201,48);
    rect(0,height-boxH,width,boxH);

    //symbol
    fill(51,141,62);
    ellipse(width/2,height-75,200,80)

    //green lines on box
    fill(51,141,62);
    rect(0,height-boxH,width,10);
    rect(0,height-boxH+20,width,10);

}

 //crayon functions:
function Red() {
  noStroke();
  fill(255,0,0);
  rect(crayonPos,height-(rectB-rectT),rectW,rectB-rectT)
  fill(0);
  rect(crayonPos,rectT+20,blackW,blackH);
}

function Orange() { //orange crayon
  fill(255,165,2);
  rect(crayonPos + 100,height-(rectB-rectT),rectW,rectB-rectT);
  fill(0);
  rect(crayonPos+100,rectT+20,blackW,blackH);
}

function Yellow() {
  fill(255,252,17);
  rect(crayonPos + 200,height-(rectB-rectT),rectW,rectB-rectT);
  fill(0);
  rect(crayonPos+200,rectT+20,blackW,blackH);
}

function Green() {
  fill(48,201,63);
  rect(crayonPos + 300,height-(rectB-rectT),rectW,rectB-rectT);
  fill(0);
  rect(crayonPos+300,rectT+20,blackW,blackH);
}

function Blue() {
  fill(45,76,255);
  rect(crayonPos + 400,height-(rectB-rectT),rectW,rectB-rectT);
  fill(0);
  rect(crayonPos+400,rectT+20,blackW,blackH);
}

function Purple() {
  fill(132,21,255);
  rect(crayonPos + 500,height-(rectB-rectT),rectW,rectB-rectT);
  fill(0);
  rect(crayonPos+500,rectT+20,blackW,blackH);
}

I got the idea from looking at a crayon box as I was finishing the Autolab assignments and had an idea about “selecting” crayons from a crayon box. It was a little difficult to try and alter the parameter using the mouseX function so that each individual crayon will go up to mouseY height. I had wanted to use an array but decided to work with using just if statements using the “width” of crayons.
I wanted to experiment with other options with color, which using lerpColor() to combine the two rgb hues and controlling that with the mouseY.

This is the rough draft of the process. I illustrated how many crayons and listed the various r,g,b values and how where the mouse would be to trigger an event (that is, the height of the crayon).

Project 3, odh

odhP3

//Owen D Haft
//Section D
//odh@andrew.cmu.edu
//Project 3

var R = 100; //"R" of RGB
var G = 100; //"G" of RGB
var W = 50; //Width of the ellipse
var H = 50; //height of the ellipse

function setup() {
    createCanvas(600, 480);
}
 
function draw() {
    background(50, 50, 100);
    noStroke();

    rectMode(CENTER);

    fill(100, 0, 0);
    rect(150, 240, 100, mouseX);

    fill(0, 100, 0);
    rect(450, 240, mouseY, 100);

    fill(R, G, 0);
    ellipse(mouseX, mouseY, W, H);

    H = mouseX;
    W = mouseY;


    //Changes the color of the ellipse depending on its location
    if (mouseX > 100) {
        G = 200;
    };
    if (mouseY > 100) {
        R = 200;
    };

}

I based all my changes on the location of the mouse, the change of size of the rectangles, the size of the ellipse, the color of the ellipse, and the location of the ellipse.

Matthew Erlebacher Project 3 Dynamic Drawing

Interactive Drawing

// Matthew Erlebacher
// Section B
// merlebac@andrew.cmu.edu
// Project-03

var mouseX
var mouseY
// Allows the location of the mouse to be a variable

var squareSide = 50
// Creates a variable to control the size of the square

function setup() {
    createCanvas(640, 480);
    // Creates a blank canvas

}

function draw() {
    background(125);
    // Creates a blue background

    fill(mouseX - mouseY, mouseX, mouseY);
    rectMode(CENTER);
    rect(0, height / 2, 30, height);
    // Creates a vertical rectangle to the far left

    fill(mouseX / 1.25 - mouseY / 0.95, mouseX / 1.25,
        mouseY / 0.95);
    rectMode(CENTER);
    rect(width / 4, height / 2, 30, height);
    // Creates a vertical rectangle a quarter to the left

    fill(mouseX / 2.5 - mouseY / 1.9, mouseX / 2.5, mouseY / 1.9);
    rectMode(CENTER);
    rect(width / 2, height / 2, 30, height);
    // Creates a vertical rectangle that splits the canvas

    fill(mouseX / 1.25 - mouseY / 0.95, mouseX / 1.25,
        mouseY / 0.95);
    rectMode(CENTER);
    rect(3 * width / 4, height / 2, 30, height);
    // Creates a vertical rectangle a quarter to the right

    fill(mouseX - mouseY, mouseX, mouseY);
    rectMode(CENTER);
    rect(width, height / 2, 30, height);
    // Creates a vertical rectangle to the far right

    fill(mouseX - mouseY, mouseY, mouseX);
    rectMode(CENTER);
    rect(width / 2, 0, width, 30);
    // Creates a horizontal rectangle at the top

    fill(mouseX / 2.5 - mouseY / 1.9, mouseY / 1.9, mouseX / 2.5);
    rectMode(CENTER);
    rect(width / 2, height / 2, width, 30);
    // Creates a horizontal rectangle that splits the canvas

    fill(mouseX - mouseY, mouseY, mouseX);
    rectMode(CENTER);
    rect(width / 2, 480, width, 30);
    // Creates a horizontal rectangle at the bottom

    fill(125);
    rectMode(CENTER);
    rect(0, 0, 30, 30);
    // Creates a gray square in the upper left corner

    fill(125);
    rectMode(CENTER);
    rect(width / 4, 0, 30, 30);
    // Creates a gray square in the left quarter  top

    fill(125);
    rectMode(CENTER);
    rect(width / 2, 0, 30, 30);
    // Creates a gray square in the middle top

    fill(125);
    rectMode(CENTER);
    rect(3 * width / 4, 0, 30, 30);
    // Creates a gray square in the quarter right top

    fill(125);
    rectMode(CENTER);
    rect(width, 0, 30, 30);
    // Creates a gray square in the upper right corner

    fill(125);
    rectMode(CENTER);
    rect(0, height / 2, 30, 30);
    // Creates a gray square in the far left middle of the canvas

    fill(125);
    rectMode(CENTER);
    rect(width / 4, height / 2, 30, 30);
    // Creates a gray square in the quarter left middle of the canvas

    fill(125);
    rectMode(CENTER);
    rect(width / 2, height / 2, 30, 30);
    // Creates a gray square in the middle of the canvas

    fill(125);
    rectMode(CENTER);
    rect(3 * width / 4, height / 2, 30, 30);
    // Creates a gray square in the quarter right middle of the canvas

    fill(125);
    rectMode(CENTER);
    rect(width, height / 2, 30, 30);
    // Creates a gray square in the far right middle

    fill(125);
    rectMode(CENTER);
    rect(0, height, 30, 30);
    // Creates a gray square in the quarter far left bottom of the canvas

    fill(125);
    rectMode(CENTER);
    rect(width / 4, height, 30, 30);
    // Creates a gray square in the lower left corner

    fill(125);
    rectMode(CENTER);
    rect(width / 2, height, 30, 30);
    // Creates a gray square in the middle bottom of the canvas

    fill(125);
    rectMode(CENTER);

    rect(3 * width / 4, height, 30, 30);
    // Creates a gray square in the quarter right bottom of the canvas

    fill(125);
    rectMode(CENTER);
    rect(width, height, 30, 30);
    // Creates a gray square in the upper right corner

    fill(0, 0, 255);
    ellipse(width / 4, height / 2, mouseX / 5, mouseX / 5);

    fill(255, 0, 0);
    ellipse(3 * width / 4, height / 2, width / 5 - mouseX / 5, width / 5 - mouseX / 5);

    fill(255);
    rectMode(CENTER);
    rect(mouseX, height - mouseY, squareSide * (2 * mouseY / 1000), squareSide * (2 * mouseY / 1000));
    // Creates a white square that follows mouseX and opposes mouseY

    fill(255);
    rectMode(CENTER);
    rect(width - mouseX, mouseY, squareSide * (2 * mouseY / 1000), squareSide * (2 * mouseY / 1000));
    // Creates a white square that follows mouseY and opposes mouseX

    fill(0);
    rectMode(CENTER);
    rect(width - mouseX, height - mouseY, squareSide * (1 - 2 * mouseY / 1000), squareSide * (1 - 2 * mouseY / 1000));
    // Creates a black square that opposes location of mouse

    fill(0);
    rectMode(CENTER);
    rect(mouseX, mouseY, squareSide * (1 - 2 * mouseY / 1000), squareSide * (1 - 2 * mouseY / 1000));
    // Creates a black square that follows the mouse
}

This project was fairly difficult for me. Apart from struggling with how to make it interactive, it was very hard for me to come up with something to create. I ended up making a transforming light show.

ifv-Project-03

sketch

//Isabelle Vincent
//Section E
//ifv@andrew.cmu.edu
//Project-03
function setup() {
    createCanvas(480, 640);
}

function draw() {
  background(189,246,255);
//background color change
  if (mouseX >= 180 & mouseX <= 280) {
    background(211,255,255);
  }
  var centerX = constrain(mouseX,100,380);
  var centerY = constrain(mouseY,180,460);
//multi-layed rotating square which follows the cursor as its pressed
  if(mouseIsPressed) {
    push();
    translate(centerX, centerY);
    rotate(radians(frameCount));
    fill(255);
    rectMode(CENTER)
    rect(0, 0, 700, 700);
    pop();

    push();
    translate(centerX, centerY);
    rotate(radians(frameCount));
    fill(255);
    rectMode(CENTER)
    rect(0, 0, 600, 600);
    pop();

    push();
    translate(centerX, centerY);
    rotate(radians(frameCount));
    fill(255);
    rectMode(CENTER)
    rect(0, 0, 500, 500);
    pop();

    push();
    translate(centerX, centerY);
    rotate(radians(frameCount));
    fill(255);
    rectMode(CENTER)
    rect(0, 0, 400, 400);
    pop();

    push();
    translate(centerX, centerY);
    rotate(radians(frameCount));
    fill(255);
    rectMode(CENTER)
    rect(0, 0, 300, 300);
    pop();

    push();
    translate(centerX, centerY);
    rotate(radians(frameCount));
    fill(255);
    rectMode(CENTER)
    rect(0, 0, 200, 200);
    pop();

    push();
    translate(centerX, centerY);
    rotate(radians(frameCount));
    fill(255);
    rectMode(CENTER)
    rect(0, 0, 100, 100);
    pop();
  }
//white dots that change size according to mouseX
  fill(255);
  stroke(255);
  strokeWeight(mouseX/10);
  point(centerX + 50, centerY);
  point(centerX - 50, centerY);
  point(centerX + 100, centerY);
  point(centerX - 100, centerY);
  point(centerX + 150, centerY);
  point(centerX - 150, centerY);
  point(centerX + 200, centerY);
  point(centerX - 200, centerY);
//Color and shape-changing Triangle
  fill(mouseX/5,mouseY/7,mouseX/2 + 5,mouseY);
  stroke(mouseX/5,mouseY/7,mouseX/2 + 5,mouseY);
  strokeWeight(3);
  triangle(100,0,centerX,centerY-70,380,0);
  triangle(100,640,centerX,centerY+70,380,640);

//lines orig from each corner and connect at cursor
  stroke(mouseX/4,mouseY/4,mouseX,mouseX + 0.2);
  strokeWeight(6);
  fill(mouseX/4,mouseY/4,mouseX,mouseX + 0.2);
  line(0,0,centerX,centerY);
  line(0,640,centerX,centerY);
  line(480,0,centerX,centerY);
  line(480,640,centerX,centerY);
//Centercircle
  fill(mouseX/4,mouseY/4,mouseX,mouseX + 0.2);
  stroke(mouseX/4,mouseY/4,mouseX,mouseX + 0.2);
  ellipseMode(CENTER);
  ellipse(centerX,centerY,50,50);

}

MouseX and MouseY are used to change the position of the center circle and the intersection of the four lines along with their color. These coordinates also affect the shape of the two triangles and the color of their stroke and fill. The white dots also follow these points and the stroke weight changes in thickness based on mouseX. When the Mouse is pressed multiple overlapped rotating squares appear. The position in which the mouse X&Y can effect the above elements is restrained. Transparency of certain elements is also affected. The background color lightens when the mouse is near the middle x-coordinates.

aboyle-Project 03-Dynamic Drawing

aboyle-Dynamic drawing

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

//Snow variables
    var snow=0
    var snowTwo=0
    var snowThree=0

function draw() {
    background(45,138,185)

//Tree variables
    var trunkWidth=30
    var trunkHeight=430-mouseY
    var leafHeight=mouseY-40
    var leafWidth=70+mouseY
    strokeWeight(0);

//Limits the trees' growth
    if(mouseY<250){
      trunkHeight=180
      leafHeight=210
      leafWidth=320}

//Summer sun
    if(mouseX<=160){
      fill(63,147,169);
      triangle(660,-30,0,480,400,480)
      fill(78,156,155);
      triangle(650,-10,100,480,300,480);
      fill(45,138,185)
      rect(575,0,90,90)
      fill(255,252,0);
      ellipse(575,70,60);
    }


//Trunks--as mouse moves up, the trunks grow
    fill(115,72,22);
    rect(75,480-trunkHeight,trunkWidth,trunkHeight);
    rect(210,480-trunkHeight,trunkWidth,trunkHeight);
    rect(345,480-trunkHeight,trunkWidth,trunkHeight);
    rect(480,480-trunkHeight,trunkWidth,trunkHeight);

//Leaves--as mouse moves up, position of leaves moves up
    fill(21,148,42)
    //tree one
    triangle(25,leafWidth,90,leafHeight,155,leafWidth);
    triangle(30,leafWidth-70,90,leafHeight-70,150,leafWidth-70);
    triangle(35,leafWidth-140,90,leafHeight-140,145,leafWidth-140);
    triangle(40,leafWidth-210,90,leafHeight-210,140,leafWidth-210);
    //tree two
    triangle(160,leafWidth,225,leafHeight,290,leafWidth);
    triangle(165,leafWidth-70,225,leafHeight-70,285,leafWidth-70);
    triangle(170,leafWidth-140,225,leafHeight-140,280,leafWidth-140);
    triangle(175,leafWidth-210,225,leafHeight-210,275,leafWidth-210);
    //tree three
    triangle(295,leafWidth,360,leafHeight,425,leafWidth);
    triangle(300,leafWidth-70,360,leafHeight-70,420,leafWidth-70);
    triangle(305,leafWidth-140,360,leafHeight-140,415,leafWidth-140);
    triangle(310,leafWidth-210,360,leafHeight-210,410,leafWidth-210);
    //tree four
    triangle(430,leafWidth,495,leafHeight,560,leafWidth);
    triangle(435,leafWidth-70,495,leafHeight-70,555,leafWidth-70);
    triangle(440,leafWidth-140,495,leafHeight-140,550,leafWidth-140);
    triangle(445,leafWidth-210,495,leafHeight-210,545,leafWidth-210);

//Summer birds--change position depending on mouse
    if(mouseX<=160){
      strokeWeight(5);
      line(mouseX,mouseY-50,mouseX+10, mouseY-40);
      line(mouseX+10,mouseY-40,mouseX+20,mouseY-50);
      line(mouseX-30,mouseY-30,mouseX-20,mouseY-20);
      line(mouseX-20,mouseY-20, mouseX-10,mouseY-30);
      line(mouseX-30,mouseY-70,mouseX-20,mouseY-60);
      line(mouseX-20,mouseY-60, mouseX-10,mouseY-70);
      line(mouseX-60,mouseY-90,mouseX-50,mouseY-80);
      line(mouseX-50,mouseY-80,mouseX-40,mouseY-90);
      line(mouseX-60,mouseY-10,mouseX-50,mouseY);
      line(mouseX-50,mouseY,mouseX-40,mouseY-10);

//Summer text
      textSize(30)
      fill(0);
      text("Summer", 40,40)
    }

//Autumnn
      if(mouseX>160 & mouseX<=320){
      //pumpkins
      fill(205,123,28)
      ellipse(0,460,80,90)
      ellipse(95,460,75,75)
      ellipse(170,460,50,50);
      ellipse(250,460,100,100)
      ellipse(345,460,60,60)
      ellipse(450,460,120,100)
      ellipse(560,460,75,75)
      ellipse(640,460,60,60)
      //ghost--changes position depending on mouse
      //and the mouth changes shape depending on x coordinates
      fill(256);
      rect(mouseX,mouseY-90,60,80);
      ellipse(mouseX+30,mouseY-95,60)
      fill(0);
      ellipse(mouseX+15,mouseY-100,20)
      ellipse(mouseX+45,mouseY-100,20)
      ellipse(mouseX+30,mouseY-60,40,mouseX-250)
      text("Autumn",40,40)
            }

//Snow and rain
    //three different speeds for snow
    snow+=6;
    snowTwo+=5;
    snowThree+=3;

    if(mouseX>320){
      //if it's winter, make snow on the ground
      if(mouseX<=480){
        fill(256);
        ellipse(320,480,640,100);}
      //if it's spring, make rainclouds in the sky
      else{
        fill(100);
        ellipse(0,0,130,70);
        ellipse(100,20,150,80);
        ellipse(200,10,140,90);
        ellipse(300,0,130,70);
        ellipse(400,10,140,80);
        ellipse(500,0,130,90);
        ellipse(600,20,150,70)
      }
      //if it's winter, make snow white
      if(mouseX<=480){
        fill(256);}
      //if it's spring, make rain blue
      else{
        fill(18,38,169)
      }
      //droplets of snow/rain
      ellipse(10,snow,10);
      ellipse(10,snowTwo+30,10);
      ellipse(40,snow+30,10);
      ellipse(40,snowThree,10);
      ellipse(70,snowTwo+30,10);
      ellipse(70,snowThree,10);
      ellipse(100,snow+60,10);
      ellipse(100,snowTwo+30,10);
      ellipse(130,snow+60,10);
      ellipse(130,snowThree+30,10);
      ellipse(160,snowThree+60,10);
      ellipse(160,snowTwo+40,10);
      ellipse(190,snow,10);
      ellipse(190,snowTwo+70,10);
      ellipse(220,snow+20,10);
      ellipse(220,snowThree,10);
      ellipse(250,snowTwo+60,10);
      ellipse(250,snowThree,10);
      ellipse(280,snowThree+60,10);
      ellipse(280,snowTwo+10,10);
      ellipse(310,snowTwo,10);
      ellipse(310,snow+30,10);
      ellipse(340,snow,10);
      ellipse(340,snowThree+60,10);
      ellipse(370,snowThree+20,10);
      ellipse(370,snowTwo,10);
      ellipse(400,snowTwo+30,10);
      ellipse(400,snowThree+50,10);
      ellipse(430,snow+30,10);
      ellipse(430,snowTwo+60,10);
      ellipse(500,snowThree,10);
      ellipse(500,snow+60,10);
      ellipse(530,snowTwo+30,10);
      ellipse(530,snowThree,10);
      ellipse(560,snow+20,10);
      ellipse(560,snowTwo,10);
      ellipse(590,snowThree+60,10);
      ellipse(590,snow+10,10);
      ellipse(620,snowTwo+20);
      ellipse(620,snowThree+40,10);

//Winter text
      if(mouseX<=480){
        fill(0);
        text("Winter",40,40);}
      if(mouseX>480){

//Spring flowers
      //stems
      fill(52,108,8)
      rect(145,575-trunkHeight,10,trunkHeight);
      rect(295,575-trunkHeight,10,trunkHeight);
      rect(420,575-trunkHeight,10,trunkHeight);
      //petals--mouseX makes color change
      fill(215,mouseX-500,32);
      ellipse(140,580-trunkHeight,20);
      ellipse(145,565-trunkHeight,20);
      ellipse(153,585-trunkHeight,20);
      ellipse(160,573-trunkHeight,20);
      ellipse(290,580-trunkHeight,20);
      ellipse(295,565-trunkHeight,20);
      ellipse(303,585-trunkHeight,20);
      ellipse(310,573-trunkHeight,20);
      ellipse(415,580-trunkHeight,20);
      ellipse(420,565-trunkHeight,20);
      ellipse(427,585-trunkHeight,20);
      ellipse(435,573-trunkHeight,20);
      //centers
      fill(85,47,27);
      ellipse(150,575-trunkHeight,15);
      ellipse(300,575-trunkHeight,15);
      ellipse(425,575-trunkHeight,15);

//Spring text
      textSize(30);
      fill(0);
      text("Spring",40,40)
        }
    }

//Loops the snow
    if(snow>480){
      snow=-60}
    if (snowTwo>480){
      snowTwo=-60}
    if(snowThree>480){
      snowThree=-60}

  }

This assignment was very cool! I didn’t use as many variables as I thought I would, mainly because I thought it made more sense to input mouseX and mouseY instead of setting them equal to a variable and then inputting that variable. I forgot that wordpress doesn’t allow a width of 640, which unfortunately means that you can’t see the sun or the flowers change color on the blog. I also wish I had been able to make the rain and snow look more random, but since that wasn’t the point of the exercise I decided to spend more time on adding aspects that changed according to the mouse–the birds, the ghost, the flowers, etc. Overall I’m pretty pleased with how it came out!

gyueunp – Project-03: Dynamic Drawing

Dynamic Drawing

//GyuEun Park
//15-104 B
//gyueunp@andrew.cmu.edu
//Project-03-Dynamic-Drawing

var x1;
var backgroundColor;
var spot = {
  x: 100,
  y: 50
}
var size = {
  w: 10,
  h: 10
}
var col = {
  r: 162,
  g: 174,
  b: 185
}
var angle = 0;

function setup() {
  createCanvas (480,640);
  backgroundColor = 0;
}
 
function draw() {
  background(backgroundColor);
  backgroundColor = map(mouseX,0,width,0,200);

//set points for ellipse
  spot.x = x1
	spot.y = 530
	size.w = 70
	size.h = 70

	x1 = map(mouseY,0,height,width/2,mouseX);
  
  fill(255,100);
 	stroke(255,50);
 	strokeWeight(4);
//black center ellipse
  ellipse(x1,spot.y,size.w,size.h);
  push();
  fill(0,2)
  ellipse(x1,spot.y,size.w-20,size.h-20);
  pop();
//ellipse with ring
  ellipse(x1-100,spot.y-100,size.w-10,size.h-10)
 	ellipse(x1-100,spot.y-100,size.w-0,size.h-60);

//ellipse near center of canvas
  ellipse(x1-20,spot.y-150,size.w-40,size.h-40);
 	ellipse(x1-20,spot.y-150,size.w-90,size.h-90);

//white center ellipse
  ellipse(x1+100,spot.y-370,size.w-30,size.h-30);
  ellipse(x1+100,spot.y-370,size.w-90,size.h-90);
  ellipse(x1+100,spot.y-370,size.w-110,size.h-110);

//top right simple ellipse
  ellipse(x1+160,spot.y-290,size.w-50,size.h-50);
  
//cursor 
 	angleMode(DEGREES);
 	angle = angle + 20;
 	translate(mouseX,mouseY);
 	rotate(angle);
 	rectMode(CENTER);
 	rect(0, 0, 20, 30);
 	rotate(angle);
 	rect(0, 0, 20, 30);
 	rotate(angle);
 	rect(0, 0, 20, 30);
 
//set points for function a
  	a(30,260);
  	a(10,130);
  	a(70,15);
  
//ellipses if cursor on the upper left corner
  if (mouseY < height/2){
    fill(255);
    stroke(255,10);
    strokeWeight(150);
    ellipse(width/4,height/4,50,50);
    noStroke(0);
    fill(255,40);
    ellipse(width*3/4,height*3/4,50,50);
  }
//thin lines if cursor on the lower right corner
  else if (mouseY > height/2){
    fill(col.r, col.g, col.b);
    stroke(255,5);
    strokeWeight(150);
    ellipse(width*3/4,width*3/6,2,10);
    ellipse(width/4,width/4,4,15);
}

function a(x,y) {
  	push();
  	translate(mouseX,y);
  	ellipse(40,70,20,20);
  	pop();
}
}

I decided to use a limited set of colors in order to draw further attention to the dynamic quality of the work. I focused on making factors such as shapes, sizes, transparencies, positions, and colors vary subtly, while maintaining a sense of unity.

Sheenu You-Project 03-Dynamic Drawing

sketch

//Sheenu You
//Section E
//Project-04
//sheenuy@andrew.cmu.edu
function setup() {
    createCanvas(400, 300);
    strokeWeight(2);
}

function draw() {
	background(0);
	//Line 1
	for (var i = 20; i <400; i+= 20) {
		stroke("yellow");
		line(0,i,i*mouseX/5,400);
		line(400,i,i*mouseX/5,0);
	}
	//Line 2
	for (var b = 10; b<600; b+=5){
		strokeWeight(1);
		stroke("red");
		line(0+b,0,0+b,300);
	}
	//Line 3
for (var a = 20; a <400; a+= 10) {
		stroke("blue");
		line(0,a,a,400);
		line(400,a,a,0);
	}
}

This project was a little bit tough since I had a lot of ideas and I really didn’t know which one to pick and how to actually make it happen. Some ideas were too overambitious and exceed the boundaries of my knowledge in P5. I was experimenting with lines and how variables affected them and made this discovery when I put two lines together and divided one of the lines’ X-coordinate by 2. It really reminded me of geometric 80’s art, so I picked a hot pink for the lines and a dark blue/purple for the background. The colors switch for the lines and background just to make it more interesting. I really love this and it looks like I am looking at a wave or a cylinder. It was really a great and also surprisingly simple discovery.

dnam-project-03-dynamic-drawing

dnam-Project-03-Dynamic-Drawing

// Doo Won Nam
// 15-104 :: 1 Section B
// dnam@andrew.cmu.edu
// Project-03-Dynamic-Drawing

//basic start - setting the canvas and setting a frame rate to avoid
//too many flickers
//setting the variables for Height so it can change
var rectHeight = 20;
//setting the variable angle to rotate the rectangle
var angle = 0;

function setup() {
  createCanvas(640, 480);
}
//start with a background that changes color based on the position of the mouse
function draw() {
  background(mouseX - 50, mouseY - 20, mouseX + 100);
//making flowers (left and right) that also change color based on the
//position of the mouse, left changes depending on how the mouse is located
//and right one changes depending on left/right movement of the mouse
//the mouse movement gives the two flowers contrary shades
//I make sure to reset the translate at the end of each 'set'
  push();
  translate(120, 200);
  fill(mouseY, mouseY, mouseY);
  noStroke();
  for (var i = 0; i < 10; i ++) {
    ellipse(0, 30, 40, 100);
    rotate(PI/5);
  }
  pop();
  push();
  translate(500, 200);
  fill(mouseX, mouseX, mouseX);
  noStroke();
  for (var i = 0; i < 10; i ++) {
    ellipse(0, 30, 40, 100);
    rotate(PI/5);
  }
  pop();
//making a rectangle between two flowers that change colors when the
//the mouse is right on top of the rectangle
  if ((mouseX > 210) & (mouseX < 410) &&
        (mouseY > 300) && (mouseY < 300 + rectHeight)) {
        fill(0);
    } else {
        fill(100, 200, 400, 60);
    }

  noStroke();
  rect(210, 300, 200, rectHeight);
//if mouse is on the left, the rectangle increases towards an upward direction
//if mouse is on the right, the rectangle gets bigger in height downwards
//using a boolean and the middle of the canvas (for X), I am able to
//increase the size depending on the position of the mouse
  if (mouseX > 320) {
    rectHeight += 20;  }
  else {
    rectHeight -= 20;
  }
//these two ifs are to ensure the rectangle resets instead of going way below
//or above the canvas size
  if (rectHeight > 480) {
    rectHeight = 0;
  }
  if (rectHeight < -480) {
    rectHeight = 0;
  }
//rectangle that does not fully follow the movement of the mouse, but slowly
//rotate around the mouse. Moving the mouse will affect it's angle, speed, and
//position.
  push();
  translate(mouseX, mouseY);
  rectMode(CENTER);
  rotate(radians(angle));
  rect(mouseX, mouseY, 20, 20);
  pop();
  angle = angle + .1;
//speeds up / changes angle when mouse is over 200 in the x axis.
  if (mouseX > 200) {
    angle = angle + 1;
  }
}

Making an interactive, dynamic drawing was very difficult for me. One of the aspects that I struggled with the most would be making sure the artwork would change as my mouse moves. I was not sure what to draw with the program, so I decided to create something that resembles a face (as we made faces the last two projects, making a face felt natural). By following the guidelines, I used bright colours to decorate the piece.

JDBROWN – Project 3: Pattern Party

So yeah, I know: this project was all “don’t use random elements.”

And I tried that. But no matter how hard I tried, I couldn’t stop playing around with this piece of code. It’s a dynamic pattern-maker, based on the “rect ()” command and mouse locations.

While this program may seem to be very randomly generated, there is actually a lot of user input being taken into consideration.

I have divided the screen into four quadrants. When the mouse enters each of those quadrants, different things happen. Some of these effects include: box trajectory, size of boxes, color of boxes, and more. Also, the user may click at any time to generate boxes at any location on the canvas. One unfortunate thing is that it looks a lot more interesting on a bigger canvas! It resets when the Y variable for the boxes exceeds the canvas, so that’s why it’s a bit awkward in WordPress.

Here are some photos!

I have posted two versions of this program because I did a lot of stuff with it, and I really enjoyed its versatility. Enjoy!

Vanilla pattern-maker:

Jdbrown – p3

// Joshua Brown
// Jdbrown@andrew.cmu.edu
// Section C
// Project #3

// Setting up global variables for size and location of drawn shape

var nothingX = 0;
var nothingY = 0;
var bright = 0;
var nothingA = 0;
var nothingZ = 0;

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

function draw () {

  // Making function draw more quickly (default = 30), so this doesn't take forever;

  var rate = width / mouseY * 4 + 24;
  frameRate (rate);

  // Giving program a 50% chance of drawing one of each shape (variations on rectangle);

  if (random (1) > 0.5) {
    fill (mouseX/2, mouseY/2, random (255));
    rect (nothingX, nothingY, nothingX + random (30), nothingY + random (5));
    rect (nothingX + 30, nothingY + 50 + random (30), nothingX + random (30), nothingY + random (5));
    rect (nothingX + 60, nothingY + 100 + random (30), nothingX + random (30), nothingY + random (5));
  }
  else {
    rect (nothingX, nothingY + random (30), nothingX + random (50), nothingY);
  }

  // Making the program respond to mouse position,
  // Resets when leaving the frame (horizontally);

  nothingX += 5;
  if (nothingX > width) {
    nothingX = 0;
    nothingY += random (50);
  }

  if (mouseX > width/2) {
    nothingX -= 10;
  } else {nothingX += 5;}

  if (nothingX < 0) {
    nothingX = 640;
    nothingY += random (30);
  }

  if (nothingY > height) {
    background (255);
  }

  /* this piece of code makes the rectangles move up or down depending on mouse position;
  if (mouseY > height/2) {
    nothingY += 5;
  }

  if (mouseY < height/2) {
    nothingY -= 5;
  }
  */

  // Resets when leaving the frame (vertically);

  if (nothingY > height) {
    nothingX = 0;
    nothingY = 0;
  }
}

function mousePressed () {

  // When clicked, the program will relocate the "brush" (location at which DRAW is working)
  // to wherever the click occurred (mouse location at click);
  nothingX = mouseX;
  nothingY = mouseY;
}

Random fun stuff version, for example:

Jdbrown – p3

// Joshua Brown
// Jdbrown@andrew.cmu.edu
// Section C
// Project #3

// Setting up global variables for size and location of drawn shape

var nothingX = 0;
var nothingY = 0;
var bright = 0;
var nothingA = 0;
var nothingZ = 0;

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

function draw () {

  // Making function draw more quickly (default = 30), so this doesn't take forever;

  var rate = width / mouseY * 4 + 24;
  frameRate (rate);

  // Giving program a 50% chance of drawing one of each shape (variations on rectangle);

  if (random (1) > 0.5) {
    fill (mouseX/2, mouseY/2, random (255));
    rect (nothingX, nothingY, nothingX + random (30), nothingY + random (5));
    rect (nothingX + 30, nothingY + 50 + random (30), nothingX + random (30), nothingY + random (5));
    rect (nothingX + 60, nothingY + 100 + random (30), nothingX + random (30), nothingY + random (5));
  }
  else {
    rect (nothingX, nothingY + random (30), nothingX + random (50), nothingY);
  }

  // Making the program respond to mouse position,
  // Resets when leaving the frame (horizontally);

  nothingX += 5;
  if (nothingX > width) {
    nothingX = 0;
    nothingY += random (50);
  }

  if (mouseX > width/2) {
    nothingX -= 10;
  } else {nothingX += 5;}

  if (nothingX < 0) {
    nothingX = 640;
    nothingY += random (30);
  }

  if (nothingY > height) {
    background (255);
  }

  if (mouseY > height/2) {
    nothingY += 5;
  }

  if (mouseY < height/2) {
    nothingY -= 5;
  }

  // Resets when leaving the frame (vertically);

  if (nothingY > height) {
    nothingX = 0;
    nothingY = 0;
  }
}

function mousePressed () {

  // When clicked, the program will relocate the "brush" (location at which DRAW is working)
  // to wherever the click occurred (mouse location at click);
  nothingX = mouseX;
  nothingY = mouseY;
}

Thanks,
Josh

 

sntong-Project-03-Dynamic-Drawing

sketch

//Scarlet Tong
//Sectiom A
//sntong@andrew.cmu.edu
//Project-03-Dynamic-Drawing

var column = 64;
var loc = 30;
var dim = 30;
var R = 254;
var G = 254;
var B = 254;
var angle = 0;
var angleVar = 40;
var dir = 8;
var colorGo = false;

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

}

function draw(){
  background (0);
  var w = 0;
  var h = 0;

  // basic grid of square
  push();
  translate(width/2,height/2);
  angleMode(DEGREES);
  noStroke();
  rectMode(CENTER);
  fill(254);
  rect(w, h, dim,dim);//center rect
  rotate(angle);
  fill(R,G,B);//color pair 1
  rect(w-loc,h-loc,dim,dim);//rect a1
  rect(w+loc,h+loc,dim,dim);//rect a8
  //color pair 2
  fill(R+loc,G,B);
  rect(w,h-loc,dim,dim);//rect a2
  rect(w-loc,h,dim,dim);//rect A4
  //color pair 3
  fill(R,G+loc,B);
  rect(w+loc,h-loc,dim,dim);//rect a3
  rect(w-loc,h+loc,dim,dim);//rect a6
  //color pair 4
  fill(R,G,B+loc);
  rect(w+loc,h,dim,dim);//rect A5
  rect(w,h+loc,dim,dim);//rect a7
  pop();

  stepOne();
  stepTwo();
  // this resets the value for angle to make sure the squares rotate when
  //the mouse is going back and forth the canvas
  if (mouseX < column*2 || mouseX > column*9) {
    angle = 0;
  }

  stepThree();
  //this to make sur the random color generation does not continue
  if (mouseX < column) {
    colorGo = false;
  }

}

function stepOne(){
  if (mouseX >= column & mouseX <= column+column/2 && mouseX <= column*3) {
    //Translation of the sqaures away from the center
    loc = max(50);
    loc += mouseX-70;
    //scale each square larger
    dim += mouseX-140;
    dim = max(50);
  }
}

//rotation of outter squares
function stepTwo (){
  //rotating the outside squares if mouseX is between a certain range
  if (mouseX > column*4 & mouseX < column*9 && angle < 90) {
    angle += angleVar*dir;
    R = random(0,254);
    G = random(0,254);
    B = random(0,254);
  } if (angle >= 90  & colorGo == false) {//to stop rotation exceeding 90 degrees
    angle = 90;
    colorGo = true;
  } else {
    angleVar = 0.2*dir;
  }
}
//Collsping and combining the squares to make large square
function stepThree(){
  if(mouseX > column*7 & mouseX < width){
    loc += mouseX-400;
    loc = min(50);
  }
}

I had fun trying to create a simple sequence of motion starting from the idea of generating a part to whole. A large square splits into smaller modules, and there is a variety of color and rotation that makes them all different from the “original” module that is located in the middle. I had to plan out the steps by using hand sketch diagrams.