ikrsek-Section C-Project-03-Dynamic Drawing

“Broken Telly”

(Note:If you expand your browser to fit your computer screen, you should be able to see the whole program)

sketch

//Isadora Krsek 
//Section C
//IKrsek@andrew.cmu.edu
//Project 03: Dynamic Drawings 
//Title: "Broken Telly"
   
//global variables
    var rotX = (453); //center of rotation for red ball (x-coordinate)
    var rotY = (390); //center of rotation for red ball (y-coordinate)
    var row = (50);
    var turnOffX = 1;
    var turnOffY = 1;
    var RB; //stands for "red-bit" as in the metal dial's indicator 
    var antLength = (166);
    var antX; 
    var antY; 
    var antX2;
    var antY2;
    var angle1;
    var angle2;
    var Bri;
    var ThiccThin;
    var Ang; 
    var Spacing; 
    var staticX = (0);
    var staticY = (0);
    var staticX2 = (0); 
    var staticY2 = (0);
    var staticX3 = (0); 
    var staticY3 = (0);
    var staticX4 = (0); 
    var staticY4 = (0);
    var staticX5 = (0); 
    var staticY5 = (0);
    var staticX6 = (0); 
    var staticY6 = (0);
    var last = -1; 
    var current; 
    
    
function setup() {
    createCanvas (640, 480);
    background(51,52,44);
    RB = new RedBit(rotX, rotY, 16); // (x,y,diameter) --> x,y represent the center of rotation
    antX = width/2-30;//origin point of left antennae's x
    antY = height/2-55;//origin point of left antennae's y
    antX2 = width/2-30;//origin point of right antennae's x
    antY2 = height/2-55;//origin point of right antennae's y
}

function tvFrame() {
    stroke(135,77,32); //the color of wood edge
    strokeWeight(16);
    line(600,400,600,0); //vertical right wood line
    line(0,0,600,0); //horizontal top wood line
    line(0,0,0,400); //vertical left wood line
    line(0,400,600,400); //horizontal bottom wood line
  //beggining of white OUTER plastic part ...  subtract each x/y value by 14
    strokeCap(PROJECT);
    stroke(236,221,188);
    strokeWeight(12);
    line(586,386,586,14); //vertical right white plastic line 
    line(14,14,586,14); //horizontal top white line
    line(14,14,14,386); //vertical left white line
    line(14,386,586,386); //horizontal bottom white line
  //beggining of black plastic part (no stroke) ... subtract each x/y value by 
    stroke(7,7,7);
    strokeWeight(150);
    line(505,225,505,95); // right side black big panel
    strokeWeight(22);
    line(31,31,564,31); // top black plastic line
    strokeWeight(20);
    line(31,31,31,290); // vertical left black plastic line
  //big plastic white part alternating with black (below)
    stroke(178,163,134);
    strokeWeight(80);
    line(60,340,540,340);
  //control panel
    stroke(208,207,187); 
    strokeWeight(4); // metal panel frame
    fill(166,162,150); // metal panel color
    rect(455,30,100,330); // metal panel 
    //sound holes 
    noStroke();
    fill(60);
    rect(468,row+10,75,5);
    rect(468,row+20,75,5);
    rect(468,row+30,75,5);
    rect(468,row+40,75,5);
    rect(468,row+50,75,5);
    rect(468,row+60,75,5);
    rect(468,row+70,75,5);
    rect(468,row+80,75,5);
    rect(468,row+90,75,5);
    rect(468,row+100,75,5);
    rect(468,row+110,75,5);
    rect(468,row+120,75,5);
    rect(468,row+130,75,5);
    rect(468,row+140,75,5);
    rect(468,row+150,75,5);
    rect(468,row+160,75,5);
    rect(468,row+170,75,5);
    rect(468,row+180,75,5);
    rect(468,row+190,75,5);
    rect(468,row+200,75,5);
    //back to the rest of the dial 
    stroke(208,207,187);
    fill(199,197,193); // metal dial color
    strokeWeight(3);
    ellipse(504,300,50,50); // metal dial
    rect(492,336,25,10); // small metal button 
  //beginning of inner white plastic part 
    noFill();
    stroke(200,188,166);
    strokeWeight(20);
    rect(51,51,370,264);
  //round rect frame for TV should have no fill but should have frame (add stroke back) 
    strokeWeight(10);
    stroke(0);
    rect(66,60,340,244,2);
}

//for left antennae movement 
function dragAntLeft(i, xin, yin) {
    if (mouseX<width/2-60 & mouseY<150 && mouseX>100){
        dx = mouseX - antX;
        dy = mouseY - antY;
        angle1 = atan2(dy, dx); //controls how the antennae moves 
      }
    ant(antX, antY, angle1); //the left antennae is born 
}

//for right antennae movement
function dragAntRight(iz, xin, yin) {
    if (mouseX>width/2+10 & mouseY<150 && mouseX<460){
        dx2 = mouseX - antX2;
        dy2 = mouseY - antY2;
        angle2 = atan2(dy2, dx2); //controls how the antennae moves 
          
        
      }
    ant2(antX2, antY2, angle2); //the left antennae is born 
    
}

//for left antennae configuration
function ant(x, y, a) {
    push();
    translate(x, y);
    rotate(a);
    line(0, 0, antLength, 0); // first two numbers are the starting point, lenght , and 
    pop();
}

//for right antennae configuration
function ant2(x, y, b) {
    push();
    translate(x, y);
    rotate(b);
    line(0, 0, antLength, 0); // first two numbers are the starting point, lenght , and 
    pop();
}

//other controls that change image 
function TVonoff (){
//tv power off black screen
    fill(51,52,44);
    noStroke();
    push();
    rectMode(CENTER);
    rect(width/2-60,290,turnOffX,turnOffY);//the size that it increases to when hovering over area that the metal button is in 
//the rect will increase to size (width/2-60,290,300,210)
    pop();
    if (dist(mouseX,mouseY,450,414)<8){
      turnOffX = 300;
      turnOffY = 210;
    }    else if(dist(mouseX,mouseY,450,425)>10){ //when mouse not near, TV powered ON 
           turnOffX = 1;
           turnOffY = 1;
          }
}

//specifics for the red circle/dial thigny
function RedBit(tx, ty, ts) {
    this.x = tx; //x-value of point you want ball to rotate around
    this.y = ty; //y-value of point you want ball to rotate around
    this.size = ts; //balls's diameter
    this.angle = 0; 
    this.update = function (mx, my) {
      this.angle = atan2(my - this.y, mx - this.x);
    }
    this.display = function () {
      push();
      translate(this.x, this.y);
      rotate(this.angle);
      fill(255, 0, 0);
      ellipse(this.size/1.4, 0, this.size / 2, this.size / 2); //control the diamete that the circle travels by dividing this.size by something
      pop();
    }
}

//mapping values for controls stuff
function Mapping(){
    //mapping strokeweight
    if (mouseX>width/2+10 & mouseY<150 && mouseX<460){
    ThiccThin = map(mouseX,300,510,2,20);
    }
    //mapping angle of static
    if(mouseX>width/2+10 & mouseY<150 && mouseX<460 && mouseY>30){
    Ang = map(mouseY,20,150,.01,.05);
    }
    //mapping position of static (space between)
    if (mouseX<width/2-60 & mouseY<150 && mouseX>100){
    Spacing = map(mouseX,100,260,200,400);
    }
    //mapping color brightness to dial 
    if(dist(mouseX,mouseY,453,390)<25){
    Bri= map(mouseY,375,423,0,180);
    }
}

//The Tv static     
  function drawStatic(){
  noFill();
  //row 0 of static shit 
  beginShape();
  vertex(150,200);
  vertex(160,180);
  vertex(170,200);
  vertex(180,180);
  vertex(190,200);
  vertex(200,180);
  vertex(210,200);
  vertex(220,180);
  vertex(230,200);
  vertex(240,180);
  vertex(250,200);
  vertex(260,180);
  vertex(270,200);
  vertex(280,180);
  vertex(290,200);
  vertex(300,180);
  vertex(310,200);
  vertex(320,180);
  vertex(330,200);
  vertex(340,180);
  vertex(350,200);
  vertex(360,180);
  vertex(370,200);
  vertex(380,180);
  vertex(390,200);
  vertex(400,180);
  vertex(410,200);
  vertex(420,180);
  vertex(430,200);
  vertex(440,180);
  vertex(450,200);
  vertex(460,180);
  vertex(470,200);
  vertex(480,180);
  vertex(490,200);
  vertex(500,180);
  vertex(510,200);
  vertex(520,180);
  vertex(530,200);
  vertex(540,180);
  vertex(550,200);
  vertex(560,180);
  vertex(570,200);
  vertex(580,180);
  vertex(590,200);
  vertex(600,180);
  endShape();
  //row 1 of static shit 
  beginShape();
  vertex(150,240);
  vertex(160,220);
  vertex(170,240);
  vertex(180,220);
  vertex(190,240);
  vertex(200,220);
  vertex(210,240);
  vertex(220,220);
  vertex(230,240);
  vertex(240,220);
  vertex(250,240);
  vertex(260,220);
  vertex(270,240);
  vertex(280,220);
  vertex(290,240);
  vertex(300,220);
  vertex(310,240);
  vertex(320,220);
  vertex(330,240);
  vertex(340,220);
  vertex(350,240);
  vertex(360,220);
  vertex(370,240);
  vertex(380,220);
  vertex(390,240);
  vertex(400,220);
  vertex(410,240);
  vertex(420,220);
  vertex(430,240);
  vertex(440,220);
  vertex(450,240);
  vertex(460,220);
  vertex(470,240);
  vertex(480,220);
  vertex(490,240);
  vertex(500,220);
  vertex(510,240);
  vertex(520,220);
  vertex(530,240);
  vertex(540,220);
  vertex(550,240);
  vertex(560,220);
  vertex(570,240);
  vertex(580,220);
  vertex(590,240);
  vertex(600,220);
  endShape();
  //row 2 of static shit 
  beginShape();
  vertex(150,280);
  vertex(160,260);
  vertex(170,280);
  vertex(180,260);
  vertex(190,280);
  vertex(200,260);
  vertex(210,280);
  vertex(220,260);
  vertex(230,280);
  vertex(240,260);
  vertex(250,280);
  vertex(260,260);
  vertex(270,280);
  vertex(280,260);
  vertex(290,280);
  vertex(300,260);
  vertex(310,280);
  vertex(320,260);
  vertex(330,280);
  vertex(340,260);
  vertex(350,280);
  vertex(360,260);
  vertex(370,280);
  vertex(380,260);
  vertex(390,280);
  vertex(400,260);
  vertex(410,280);
  vertex(420,260);
  vertex(430,280);
  vertex(440,260);
  vertex(450,280);
  vertex(460,260);
  vertex(470,280);
  vertex(480,260);
  vertex(490,280);
  vertex(500,260);
  vertex(510,280);
  vertex(520,260);
  vertex(530,280);
  vertex(540,260);
  vertex(550,280);
  vertex(560,260);
  vertex(570,280);
  vertex(580,260);
  vertex(590,280);
  vertex(600,260);  
  endShape();
  //row 3 of static shit 
  beginShape();
  vertex(150,320);
  vertex(160,300);
  vertex(170,320);
  vertex(180,300);
  vertex(190,320);
  vertex(200,300);
  vertex(210,320);
  vertex(220,300);
  vertex(230,320);
  vertex(240,300);
  vertex(250,320);
  vertex(260,300);
  vertex(270,320);
  vertex(280,300);
  vertex(290,320);
  vertex(300,300);
  vertex(310,320);
  vertex(320,300);
  vertex(330,320);
  vertex(340,300);
  vertex(350,320);
  vertex(360,300);
  vertex(370,320);
  vertex(380,300);
  vertex(390,320);
  vertex(400,300);
  vertex(410,320);
  vertex(420,300);
  vertex(430,320);
  vertex(440,300);
  vertex(450,320);
  vertex(460,300);
  vertex(470,320);
  vertex(480,300);
  vertex(490,320);
  vertex(500,300);
  vertex(510,320);
  vertex(520,300);
  vertex(530,320);
  vertex(540,300);
  vertex(550,320);
  vertex(560,300);
  vertex(570,320);
  vertex(580,300);
  vertex(590,320);
  vertex(600,300);
  endShape();
  //row 4 of static shit 
  beginShape();
  vertex(150,360);
  vertex(160,340);
  vertex(170,360);
  vertex(180,340);
  vertex(190,360);
  vertex(200,340);
  vertex(210,360);
  vertex(220,340);
  vertex(230,360);
  vertex(240,340);
  vertex(250,360);
  vertex(260,340);
  vertex(270,360);
  vertex(280,340);
  vertex(290,360);
  vertex(300,340);
  vertex(310,360);
  vertex(320,340);
  vertex(330,360);
  vertex(340,340);
  vertex(350,360);
  vertex(360,340);
  vertex(370,360);
  vertex(380,340);
  vertex(390,360);
  vertex(400,340);
  vertex(410,360);
  vertex(420,340);
  vertex(430,360);
  vertex(440,340);
  vertex(450,360);
  vertex(460,340);
  vertex(470,360);
  vertex(480,340);
  vertex(490,360);
  vertex(500,340);
  vertex(510,360);
  vertex(520,340);
  vertex(530,360);
  vertex(540,340);
  vertex(550,360);
  vertex(560,340);
  vertex(570,360);
  vertex(580,340);
  vertex(590,360);
  vertex(600,340);
  endShape();
  //row 5 of static shit 
  beginShape();
  vertex(150,400);
  vertex(160,380);
  vertex(170,400);
  vertex(180,380);
  vertex(190,400);
  vertex(200,380);
  vertex(210,400);
  vertex(220,380);
  vertex(230,400);
  vertex(240,380);
  vertex(250,400);
  vertex(260,380);
  vertex(270,400);
  vertex(280,380);
  vertex(290,400);
  vertex(300,380);
  vertex(310,400);
  vertex(320,380);
  vertex(330,400);
  vertex(340,380);
  vertex(350,400);
  vertex(360,380);
  vertex(370,400);
  vertex(380,380);
  vertex(390,400);
  vertex(400,380);
  vertex(410,400);
  vertex(420,380);
  vertex(430,400);
  vertex(440,380);
  vertex(450,400);
  vertex(460,380);
  vertex(470,400);
  vertex(480,380);
  vertex(490,400);
  vertex(500,380);
  vertex(510,400);
  vertex(520,380);
  vertex(530,400);
  vertex(540,380);
  vertex(550,400);
  vertex(560,380);
  vertex(570,400);
  vertex(580,380);
  vertex(590,400);
  vertex(600,380);
  endShape();
  }











function draw() {
  background(245);  
  Mapping();
    
    push();
    strokeWeight(1+ThiccThin);
    stroke(Bri+40)
    translate(200-Spacing,0)
    rotate(Ang);
    drawStatic()
    pop();
  
//blocks to cover movement of the static behind TV 
    fill(245)
    push();
    noStroke();
    rectMode(CORNER);
    rect(0,170,140,280);
    rect(520,180,200,280);
    rect(0,140,width,50)
    pop();
    
//antennae shit (movement & base)
    fill(10);
    noStroke();
    ellipse(width/2-30,height/2-55,100,70); //antennae base
    strokeWeight(4.2);
    stroke(10);
  //left antennae
    dragAntLeft(0, mouseX, mouseY);
    for( var i=0; i<antX.length-1; i++) {
    dragAntLeft(i+1, antX[i], antY[i]);
    }
  //right antennae
     dragAntRight(0, mouseX, mouseY);
    for( var iz=0; iz<antX2.length-1; iz++) {
    dragAntRight(iz+1, antX2[iz], antY2[iz]);
    }
    
//turns tv on and off 
  TVonoff();
    
//TV frame/illustration 
    push();
    translate(100,180); 
    scale(0.7,0.7); //scaling down the size of the TV so that antennae can fit on screen 
    tvFrame();
    pop();
  
//the red dial will only spin if the mouse gets close to it
    noStroke();
    if(dist(mouseX,mouseY,453,390)<25){
    RB.update(mouseX, mouseY);
    }
    RB.display();
    fill(255,0,0);
    ellipse(164,185,1,1);
  
}






*the left and right antennae do not appear until they are in vicinity of the mouse
The left antennae controls the position of the static, and moving it appears to animate it
the right antennae controls both the rotation and the thickness of the static
The little red-studded dial controls the brightness/color
and the button below the dial controls the size of a minuscule black square in the middle of the screen which gets large when you hover over it, simulating the tv turning off.

(Explanation coming soon)

ctv-project-02

sketch

//Ty Van de Zande
//Section B
//ctv@andrew.cmu.edu
//Assignment-03-A

var wid = 640;
var hgt = 480;
var colo = 0;

function setup() {
    createCanvas(wid, hgt);
}
 
function draw() {
    //rota variable must be defined 
    //in the draw loop, so it updates every frame
    var rota = mouseX/200;
    background(170, 190, 200);
    fill(colo);
    
    //starts a shape to apply features (eye)
    push(); 
    translate(width/3, height/3); //place on canvas
    rotate(rota);
    rect(-26, -26, 52, 52); //square
    rect(0, -26, 52, 52); //makes it a rectangle
    pop(); // ends shape features
    
    //starts a shape to apply features (eye)
    push(); 
    translate(width/3*2, height/3);
    rotate(rota);
    rect(-26, -26, 52, 52);
    rect(0, -26, 52, 52);
    pop();
    
    //starts a shape to apply features (mouth)
    push(); 
    translate(width/2, height/3*2);
    //changes openness of mouth based on mouseY
    arc(0, 50, 90, mouseY, 0, PI, OPEN);
    pop(); 
    
    //starts nose with features
    push();
    translate(mouseX, mouseY);
    //draws nose
    beginShape();
    curveVertex(0, 0);
    curveVertex(10, 10);
    curveVertex(40, 40);
    curveVertex(80, 80);
    curveVertex(100, 120);
    curveVertex(80, 140);
    curveVertex(40, 130);
    curveVertex(10, 100);
    curveVertex(0, 0);
    
    // change direction of nose, based on cursor
    if (mouseX <= width/2) { 
        scale(-.75, .75);

    } else { //scales down nose shape
        scale(.75,.75);
    }
    endShape(); 
    pop();
}

//if you click, it changes black to white!
function mousePressed(){
    if(colo == 0){
        colo = 255;
    noStroke();
    } else {
        colo = 0;
    }
}

 

This project was fun because it was cool to play with the shapes while programming each line. I wish I had spent more time on it, but I spent wayyyy too much time trying to figure out coordinates for the nose. The nose still looks horrible, so I just need to spend more time using curveVertex() for drawing.

Sarah Kim – Dynamic Drawing

sketch

// the height of the moon&lines stay constant.
//the lines and day and night should change colors.
var start = 20;
var angle = 0;
var y = 100;
var night = (0, 0, 0);
var r = 25; // colors for the background.
var g = 25;
var b = 112;

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

function draw() {
    background(r,g,b);
    noStroke();
    //largest ring
    fill(255);
    ellipse(pmouseX, y, 700, 700);
    fill(night);
    ellipse(pmouseX, y, 698, 697);
    //pink ring
    fill("pink");
    ellipse(pmouseX, y, 310, 310);
    fill(night);
    ellipse(pmouseX, y, 303, 303);
    //smaller white ring
    fill(255);
    ellipse(pmouseX, y, 300, 300);
    fill(night);
    ellipse(pmouseX, y, 299, 299);
    //blue ring
    fill("skyblue");
    ellipse(pmouseX, y, 150, 150);
    fill(night);
    ellipse(pmouseX, y, 149, 149);
    //moon
    fill(255,250,205);
    ellipse(pmouseX, y, 50, 50);
    fill(night);
    arc(pmouseX+30, y-10, 50,50,0,PI+QUARTER_PI, PIE);
    //mountains at night. some change colors randomly.
    fill(pmouseX, pmouseY, 255);
    triangle(120, 300, 0, 480, 240, 480);
    fill(pmouseX, pmouseY, 210);
    triangle(520, 480, 620, 205, 700, 500);
    fill("blue");
    triangle(400, 480, 520, 210, 640, 480);
    fill("skyblue");
    triangle(520, 210, 520, 480, 640, 480);
    fill("white");
    triangle(140, 480, 250, 225, 500, 480);
    fill("lavender");
    triangle(250, 225, 250, 480, 500, 480);
    //bug in left
    push();
    translate(300,250);
    rotate(radians(angle+90));
    fill("yellow")
    ellipse(-start, start, 3, 3);
    pop();
    angle = angle + 1;
    start = start + .05;
    //bug in the middle
    push();
    translate(100,100);
    rotate(radians(angle));
    fill("white")
    ellipse(start, -start, 5, 5);
    pop();
    angle = angle + 1;
    start = start + .05;
    //bug on the right
    push();
    translate(500,80);
    rotate(radians(angle));
    fill("yellow")
    ellipse(start, start, 5, 5);
    pop();
    angle = angle + 0.2;
    start = start + .0003;
    //bugs with changing colors with mouse movement.
    push();
    translate(320,200);
    rotate(radians(angle));
    fill(pmouseX, pmouseY, 213);
    ellipse(-start, start, 5, 5);
    pop();
    angle = angle + 0.2;
    start = start + .001;

    push();
    translate(600,76);
    rotate(radians(angle));
    fill(pmouseX, pmouseY, 143);
    ellipse(start, -start, 5, 5);
    pop();
    angle = angle + 0.2;
    start = start + .00001;
    // as mouse moves to the right, night changes to day.
    if (pmouseX >= night+320) {
     night = night + 5;
    }
    if (pmouseX < night+320) {
     night = night - 2;
    }
    //background changes color along with the movement of the moon.
    if (pmouseX >= 320) {
     r = 230;
    }
    if (pmouseX >= 320) {
     g = 230;
    }
    if (pmouseX >= 320) {
     b= 250;
   }
    if (pmouseX < 320) {
     r = 25;
   }
   if (pmouseX < 320) {
    g = 25;
   }
   if (pmouseX < 320) {
    b = 112;
  }

}

I used color transitions and the spiral rotation that we learned this week to create the image. The moon is created with an arc and ellipse.

Bettina-Project03-SectionC

sketch
To interact: slowly move mouse Y up and down the top half of the image.
I was interested in experimenting with color palettes I usually don’t use in my work for this project. After making the code, I realize my approach doesn’t quite take advantage of “code’s grain”– that is, this interaction may have been better executed in a platform that uses keyframes such as after effects. While the growth of blocks are smooth, the color change is abrupt because I couldn’t quite math out how to change the particular RGB values to match mouse Y.

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

//colors
var ochre='#D0B268'
var LightSalmon='#F8ADA3'
var DarkSalmon='#D06870'
var Navy='#213468'
var Navy9='#213468'
var Green='#084E5A';
var Navy10=Navy;
var DarkSalmon31315=DarkSalmon;
var LightSalmon12=LightSalmon;
var LightSalmon4=LightSalmon;
var LightSalmon2=LightSalmon
var rectXone=0;
var ochre17=ochre;
var rectXtwo=480;
var ochreStripe=LightSalmon;

//shape variables
var rectX=0;
var rectY=0;

function draw() {
  var myc= constrain(mouseY,0,142.5);
  var rectX=myc/.53;
  var rectY=myc*2.5;
  var rectXone=myc*.753;
  var rectXtwo=480-(myc*1.495);
  noStroke();
  rectMode(CORNER);
  fill(ochre);
  rect(0,0,267,71); //box 1
  fill(LightSalmon2);
  rect(267,0,273,284); //box 2
  fill(DarkSalmon31315);
  rect(0,71,160,143); //box 3
  fill(LightSalmon4);
  rect(160,71,53,71); //box 4
  fill(Navy);
  rect(213,71,54,71); //box 5
  rect(0,214,160,71);//box 6
  fill(255);
  rect(160,142,107,142);
  fill(ochre);
  push();
  rect(160,160,107,13); //box 7 stripe 1
  translate(0,30);
  rect(160,160,107,13); //box 7 stripe 2
  translate(0,30);
  rect(160,160,107,13); //box 7 stripe 3
  translate(0,30);
  rect(160,160,107,13); //box 7 stripe 4
  pop();
  fill(LightSalmon); 
  rect(0,284,160,213.5) //box 8
  fill(Navy9);
  if (mouseY>142.5) {
    Navy9='#86B5C6';
    Navy10=ochre;
    DarkSalmon31315='#ECA1C0';
    LightSalmon12=ochre;
    LightSalmon4=Green;
    DarkSalmonGreen=Green;
    LightSalmon2=Green;
    ochre17='#ECA1C0';
    ochreStripe=Navy;
  }
  if (mouseY<=142.5) {
    Navy9=Navy;
    Navy10=Navy;
    DarkSalmon31315=DarkSalmon;
    LightSalmon12=LightSalmon;
    LightSalmon4=LightSalmon;
    DarkSalmonGreen=DarkSalmon;
    LightSalmon2=LightSalmon;
    ochre17=ochre;
    ochreStripe=LightSalmon;
  }
  push();
  translate(0,-myc);
  rect(160,284,214,142.5); //box 9
  pop();
  push();
  fill(Navy10);
  rect(397,284,18,70.5); //box 10 stripe 1
  translate(40,0);
  rect(397,284,18,70.5); //box 10 stripe 2
  pop();
  fill(ochre);
  rect(160,426,107,71.5); //box 11
  fill(LightSalmon12);
  rect(267,426,107,142); //box 12
  fill(DarkSalmon31315);
  rect(374,354.5,107,213.5); //box 13
  fill(Navy);
  rect(0,497,267,143); //box 14
  fill(DarkSalmon31315);
  rect(267,568,107,72); //box 15
  fill(Navy);
  rect(374,568,107,72); //box 16
  fill(DarkSalmonGreen);
  rect(0,284,rectX,rectY);
  fill(ochre17);
  rect(267,71,rectXone,71);
  fill(255);
  rect(rectXtwo,0,213.5,71);
  fill(ochreStripe);
  rect(285,0,18,71);
  push();
  translate(50,0);
  rect(285,0,18,71);
  translate(50,0);
  rect(285,0,18,71);
  translate(50,0);
  rect(285,0,18,71);
  translate(50,0);
  rect(285,0,18,71);
  
  
}

project3-keuchuka

project 3

//Fon Euchukanonchai
//15-105 SECTION A
//keuchuka@andrew.cmu.edu
//Project-03

//variables for face
var eyeX = 314;
var righteyeY = 132;
var lefteyeY = 305;
var eyeWidth = 100;

var smileAngle1 = -50;
var smileAngle2 = smileAngle1 - 260;

//variables for bankground
var leftrectX = 128;
var rightrectX = 384;
var rectY = 0;
var rectWidth = 148;
var rectHeight = 480;



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

// constraining eye width, right eye and left eye Y and X axis positions, 

	var eyeWidth = constrain(mouseX/100, 20, 150);
	var conrighteyeY = constrain(righteyeY, 190, 220);
	var conlefteyeY = constrain(lefteyeY, 280, 300);
	var coneyeX = constrain(eyeX, 40, 600);
	var conmouseX = constrain(mouseX, 40, 450);

// base yellow background

	background(255, 233, 141);


// when mouse moves past first recteangle to the right, the eyes increase in size and the
// distance between them increases, but is constrained to not fall of the canvas

 	if (mouseX>256) {
 		eyeWidth = eyeWidth + mouseX/10;
 		righteyeY = conrighteyeY - mouseX/300;
 		lefteyeY = conlefteyeY + mouseX/300;
 		lefteyeY = conlefteyeY - mouseX/200;
 	}
 		
 // configures the smile arc angle runs freely wehn mouse is moving in between the two ends
 	if (256<mouseX<600) {
 		smileAngle1 = mouseX;

 	}

// fixes larger smile arc angle when mouse is on the right

 	if (mouseX>600) {
 		smileAngle1 = -50;
 	}
 	
 // fixes smaller smile arc angle when mouse is on the left

 	if (mouseX<130) {
 		smileAngle1 = 165;
 		smileAngle2 = 195;
 	}

 // when mouse moves past the rectangle to the left

 	if (mouseX<256) {
 		eyeWidth = eyeWidth - mouseX/100;
  		righteyeY = conrighteyeY + mouseX/200;
 		lefteyeY = conlefteyeY - mouseX/200;

 	}


// variables to change colors on face and rectangle
	
 	R=(480-mouseX)/3;
	G=(mouseY)/3;
	B=mouseY*(100,255);


//eye graphic configurations
	strokeWeight(10);
	stroke(R, G, B, 150);
	fill(R, G, B, 150); 

//left eye
 	ellipse(eyeX, lefteyeY, eyeWidth/2, eyeWidth/2);

//right eye
 	ellipse(eyeX, righteyeY, eyeWidth/2, eyeWidth/2);

//mouth graphic configurations
	angleMode(DEGREES)
	noFill();
	strokeWeight(25);

//mouth
	stroke(R, G, B, 150);
	arc(330, 240, 480, 480, smileAngle1, smileAngle2);

//rectangle graphic configurations
	strokeWeight(25);
	stroke(R, B, G, 100);
	fill(B, R, G, 150);

//rectangles
	rect(leftrectX, rectY, rectWidth, rectHeight);
	rect(rightrectX, rectY, rectWidth, rectHeight);

//eyes move 
 	eyeX = conmouseX;
 	smileAngle2 = smileAngle1 - 260;


}

I wanted to create an understandable narrative using primitive shapes, which led to me to using the arc command. With the set idea of turning a frown upside down, I then proceeded to vary different variables within the face itself as well as the background.

Project 3

sketch

var radius=40;
var shape="cir";
var startX = 120;
var startY = 40;
var coorX = 0;
var coorY = 0;
var radChange = 0;
var shade = 255;

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

function draw() {
	background(0);
	//rectangle mode
	if (shape == "rect"){
		//make a grid
    	for(var row=0;row<10;row++){
   			for(var col=0;col<10;col++){
   				coorX=startX+radius*col
           		coorY=startY+radius*row
           		//the mouse inside control the size and the color of the rectangle
 				if(mouseX<520 & mouseX>120 && mouseY<440 && mouseY>40){
 					dis = dist(coorX,coorY,mouseX,mouseY)
 					radChange = dis*0.08
 					shade = dis*0.4
 				}else{
 					radChange = radius
 					shade=shade+20
 					if (shade>=230){
 						shade=0
 					}
 				}
 				fill(shade,shade,255)
   				rect(coorX,coorY,radChange,radChange);
           	}
        }
    //circle mode
    }else{
    	for(var row=0;row<10;row++){
   			for(var col=0;col<10;col++){
           		coorX=startX+radius/2+radius*col
           		coorY=startY+radius/2+radius*row
           		//the mouse inside control the size and color of the circle
 				if(mouseX<520 & mouseX>120 && mouseY<440 && mouseY>40){
 					dis = dist(coorX,coorY,mouseX,mouseY)
 					radChange = dis*0.08
 					shade = dis*0.4
 				}else{
 					radChange = radius
 					shade=shade+20
 					if (shade>=230){
 						shade=0
 					}
 				}
 				fill(shade,shade,255)
 				ellipse(coorX, coorY,radChange);
 			}
 		}
 	}
}
    

function mousePressed() {
	//mouse press control the shape of the objects
    if (shape != "rect"){
        shape = "rect";
    } else{
        shape = "cir";
    }
}

 

I was inspired by the grasshopper plug-in in rhino that we are learning right now in architecture generative modeling class. Therefore, I made this interactive drawings.

hqq-secE-project03-dynamic-drawing

hamza

//hamza qureshi
//section e
//project 03
//hqq@andrew.cmu.edu

var newX = 320;  //starting point at center
var newY = 240;
var dirX = 1; //directional vector
var speedX = 3; //horizontal speedX
var dirY = 1;
var speedY = 2; //vertical speed
var eyeDy = 0; //additive value for pupil position
var eyeDx = 0;
var drag = false; //calls drag abilities

function setup(){
    createCanvas(640,480);
    //noCursor();
    angleMode(DEGREES);
    cursor(CROSS); //preferred cursor
}

function draw(){
    background(0);
    noStroke();
    rectMode(CORNER);
    ellipseMode(CENTER);
    var newColor1 = mouseX/1;  //these variables are to be used
    var newColor2 = mouseX/2;  //to control how the color changes
    var newColor3 = mouseX/3;  //relative to the mouse position
    var newColor4 = mouseX/4;
    var newColor5 = mouseY/1;
    var newColor6 = mouseY/2;
    var newColor7 = mouseY/3;
    var newColor8 = mouseY/4;

//row 1
    fill(newColor1, newColor2, newColor3);
    rect(0,0,40,40);
    fill(newColor4, newColor5, newColor6);
    rect(40,0,40,40);
    fill(newColor7, newColor8, newColor7);
    rect(80,0,40,40);
    fill(newColor6, newColor5, newColor4);
    rect(120,0,40,40);
    fill(newColor3, newColor2, newColor1);
    rect(160,0,40,40);
    fill(newColor1, newColor8, newColor2);
    rect(200,0,40,40);
    fill(newColor7, newColor6, newColor6);
    rect(240,0,40,40);
    fill(newColor4, newColor5, newColor8);
    rect(280,0,40,40);
    fill(newColor1, newColor8, newColor1);
    rect(320,0,40,40);
    fill(newColor2, newColor7, newColor2);
    rect(360,0,40,40);
    fill(newColor3, newColor8, newColor3);
    rect(400,0,40,40);
    fill(newColor4, newColor5, newColor4);
    rect(440,0,40,40);
    fill(newColor5, newColor4, newColor5);
    rect(480,0,40,40);
    fill(newColor6, newColor3, newColor6);
    rect(520,0,40,40);
    fill(newColor7, newColor2, newColor7);
    rect(560,0,40,40);
    fill(newColor8, newColor1, newColor8);
    rect(600,0,40,40);
    fill(newColor1, newColor7, newColor1);
    rect(640,0,40,40);

//row 2
    fill(newColor2, newColor2, newColor3);
    rect(0,40,40,40);
    fill(newColor1, newColor5, newColor6);
    rect(40,40,40,40);
    fill(newColor1, newColor8, newColor7);
    rect(80,40,40,40);
    fill(newColor1, newColor5, newColor4);
    rect(120,40,40,40);
    fill(newColor1, newColor4, newColor1);
    rect(160,40,40,40);
    fill(newColor3, newColor8, newColor2);
    rect(200,40,40,40);
    fill(newColor1, newColor3, newColor6);
    rect(240,40,40,40);
    fill(newColor1, newColor5, newColor8);
    rect(280,40,40,40);
    fill(newColor2, newColor8, newColor1);
    rect(320,40,40,40);
    fill(newColor1, newColor7, newColor2);
    rect(360,40,40,40);
    fill(newColor1, newColor3, newColor3);
    rect(400,40,40,40);
    fill(newColor1, newColor5, newColor4);
    rect(440,40,40,40);
    fill(newColor1, newColor4, newColor5);
    rect(480,40,40,40);
    fill(newColor1, newColor3, newColor6);
    rect(520,40,40,40);
    fill(newColor1, newColor2, newColor7);
    rect(560,40,40,40);
    fill(newColor1, newColor1, newColor8);
    rect(600,40,40,40);
    fill(newColor2, newColor6, newColor1);
    rect(640,40,40,40);

//row 3
    fill(newColor8, newColor2, newColor3);
    rect(0,80,40,40);
    fill(newColor2, newColor5, newColor6);
    rect(40,80,40,40);
    fill(newColor2, newColor8, newColor7);
    rect(80,80,40,40);
    fill(newColor2, newColor5, newColor4);
    rect(120,80,40,40);
    fill(newColor2, newColor2, newColor1);
    rect(160,80,40,40);
    fill(newColor2, newColor8, newColor2);
    rect(200,80,40,40);
    fill(newColor8, newColor3, newColor6);
    rect(240,80,40,40);
    fill(newColor2, newColor5, newColor8);
    rect(280,80,40,40);
    fill(newColor3, newColor8, newColor1);
    rect(320,80,40,40);
    fill(newColor2, newColor7, newColor2);
    rect(360,80,40,40);
    fill(newColor2, newColor6, newColor3);
    rect(400,80,40,40);
    fill(newColor2, newColor5, newColor4);
    rect(440,80,40,40);
    fill(newColor8, newColor4, newColor5);
    rect(480,80,40,40);
    fill(newColor2, newColor3, newColor6);
    rect(520,80,40,40);
    fill(newColor2, newColor2, newColor7);
    rect(560,80,40,40);
    fill(newColor2, newColor1, newColor8);
    rect(600,80,40,40);
    fill(newColor3, newColor7, newColor1);
    rect(640,80,40,40);

//row 4
    fill(newColor8, newColor2, newColor3);
    rect(0,120,40,40);
    fill(newColor3, newColor5, newColor6);
    rect(40,120,40,40);
    fill(newColor3, newColor8, newColor7);
    rect(80,120,40,40);
    fill(newColor3, newColor5, newColor4);
    rect(120,120,40,40);
    fill(newColor3, newColor2, newColor1);
    rect(160,120,40,40);
    fill(newColor3, newColor8, newColor2);
    rect(200,120,40,40);
    fill(newColor8, newColor3, newColor6);
    rect(240,120,40,40);
    fill(newColor3, newColor5, newColor8);
    rect(280,120,40,40);
    fill(newColor4, newColor8, newColor1);
    rect(320,120,40,40);
    fill(newColor3, newColor7, newColor2);
    rect(360,120,40,40);
    fill(newColor3, newColor6, newColor3);
    rect(400,120,40,40);
    fill(newColor3, newColor5, newColor4);
    rect(440,120,40,40);
    fill(newColor8, newColor4, newColor5);
    rect(480,120,40,40);
    fill(newColor3, newColor3, newColor6);
    rect(520,120,40,40);
    fill(newColor3, newColor2, newColor7);
    rect(560,120,40,40);
    fill(newColor3, newColor1, newColor8);
    rect(600,120,40,40);
    fill(newColor4, newColor7, newColor1);
    rect(640,120,40,40);

//row 5
    fill(newColor5, newColor2, newColor3);
    rect(0,160,40,40);
    fill(newColor8, newColor5, newColor6);
    rect(40,160,40,40);
    fill(newColor4, newColor8, newColor7);
    rect(80,160,40,40);
    fill(newColor4, newColor5, newColor4);
    rect(120,160,40,40);
    fill(newColor4, newColor2, newColor1);
    rect(160,160,40,40);
    fill(newColor4, newColor8, newColor2);
    rect(200,160,40,40);
    fill(newColor4, newColor3, newColor6);
    rect(240,160,40,40);
    fill(newColor4, newColor5, newColor8);
    rect(280,160,40,40);
    fill(newColor5, newColor8, newColor1);
    rect(320,160,40,40);
    fill(newColor4, newColor7, newColor2);
    rect(360,160,40,40);
    fill(newColor4, newColor6, newColor3);
    rect(400,160,40,40);
    fill(newColor4, newColor5, newColor4);
    rect(440,160,40,40);
    fill(newColor4, newColor4, newColor5);
    rect(480,160,40,40);
    fill(newColor8, newColor3, newColor6);
    rect(520,160,40,40);
    fill(newColor4, newColor2, newColor7);
    rect(560,160,40,40);
    fill(newColor4, newColor1, newColor8);
    rect(600,160,40,40);
    fill(newColor5, newColor7, newColor1);
    rect(640,160,40,40);

//row 6
    fill(newColor6, newColor2, newColor3);
    rect(0,200,40,40);
    fill(newColor5, newColor5, newColor6);
    rect(40,200,40,40);
    fill(newColor5, newColor8, newColor7);
    rect(80,200,40,40);
    fill(newColor5, newColor5, newColor4);
    rect(120,200,40,40);
    fill(newColor5, newColor2, newColor1);
    rect(160,200,40,40);
    fill(newColor5, newColor8, newColor2);
    rect(200,200,40,40);
    fill(newColor5, newColor3, newColor6);
    rect(240,200,40,40);
    fill(newColor5, newColor5, newColor8);
    rect(280,200,40,40);
    fill(newColor6, newColor8, newColor1);
    rect(320,200,40,40);
    fill(newColor5, newColor7, newColor2);
    rect(360,200,40,40);
    fill(newColor5, newColor6, newColor3);
    rect(400,200,40,40);
    fill(newColor5, newColor5, newColor4);
    rect(440,200,40,40);
    fill(newColor5, newColor4, newColor5);
    rect(480,200,40,40);
    fill(newColor5, newColor3, newColor6);
    rect(520,200,40,40);
    fill(newColor5, newColor2, newColor7);
    rect(560,200,40,40);
    fill(newColor5, newColor1, newColor8);
    rect(600,200,40,40);
    fill(newColor6, newColor7, newColor1);
    rect(640,200,40,40);

//row 7
    fill(newColor6, newColor2, newColor1);
    rect(0,240,40,40);
    fill(newColor5, newColor5, newColor1);
    rect(40,240,40,40);
    fill(newColor5, newColor8, newColor1);
    rect(80,240,40,40);
    fill(newColor5, newColor5, newColor1);
    rect(120,240,40,40);
    fill(newColor5, newColor2, newColor2);
    rect(160,240,40,40);
    fill(newColor5, newColor8, newColor1);
    rect(200,240,40,40);
    fill(newColor5, newColor3, newColor1);
    rect(240,240,40,40);
    fill(newColor5, newColor5, newColor1);
    rect(280,240,40,40);
    fill(newColor6, newColor8, newColor2);
    rect(320,240,40,40);
    fill(newColor5, newColor7, newColor1);
    rect(360,240,40,40);
    fill(newColor5, newColor6, newColor1);
    rect(400,240,40,40);
    fill(newColor5, newColor5, newColor1);
    rect(440,240,40,40);
    fill(newColor5, newColor4, newColor1);
    rect(480,240,40,40);
    fill(newColor5, newColor3, newColor1);
    rect(520,240,40,40);
    fill(newColor5, newColor2, newColor1);
    rect(560,240,40,40);
    fill(newColor5, newColor1, newColor1);
    rect(600,240,40,40);
    fill(newColor6, newColor7, newColor2);
    rect(640,240,40,40);

//row 8
    fill(newColor6, newColor2, newColor3);
    rect(0,280,40,40);
    fill(newColor5, newColor5, newColor6);
    rect(40,280,40,40);
    fill(newColor5, newColor8, newColor7);
    rect(80,280,40,40);
    fill(newColor5, newColor5, newColor4);
    rect(120,280,40,40);
    fill(newColor5, newColor2, newColor1);
    rect(160,280,40,40);
    fill(newColor5, newColor8, newColor2);
    rect(200,280,40,40);
    fill(newColor5, newColor3, newColor6);
    rect(240,280,40,40);
    fill(newColor5, newColor5, newColor8);
    rect(280,280,40,40);
    fill(newColor6, newColor8, newColor1);
    rect(320,280,40,40);
    fill(newColor5, newColor7, newColor2);
    rect(360,280,40,40);
    fill(newColor5, newColor6, newColor3);
    rect(400,280,40,40);
    fill(newColor5, newColor5, newColor4);
    rect(440,280,40,40);
    fill(newColor5, newColor4, newColor5);
    rect(480,280,40,40);
    fill(newColor5, newColor3, newColor6);
    rect(520,280,40,40);
    fill(newColor5, newColor2, newColor7);
    rect(560,280,40,40);
    fill(newColor5, newColor1, newColor8);
    rect(600,280,40,40);
    fill(newColor6, newColor7, newColor1);
    rect(640,280,40,40);

//row 9
    fill(newColor5, newColor2, newColor3);
    rect(0,320,40,40);
    fill(newColor8, newColor5, newColor6);
    rect(40,320,40,40);
    fill(newColor4, newColor8, newColor7);
    rect(80,320,40,40);
    fill(newColor4, newColor5, newColor4);
    rect(120,320,40,40);
    fill(newColor4, newColor2, newColor1);
    rect(160,320,40,40);
    fill(newColor4, newColor8, newColor2);
    rect(200,320,40,40);
    fill(newColor4, newColor3, newColor6);
    rect(240,320,40,40);
    fill(newColor4, newColor5, newColor8);
    rect(280,320,40,40);
    fill(newColor5, newColor8, newColor1);
    rect(320,320,40,40);
    fill(newColor4, newColor7, newColor2);
    rect(360,320,40,40);
    fill(newColor4, newColor6, newColor3);
    rect(400,320,40,40);
    fill(newColor4, newColor5, newColor4);
    rect(440,320,40,40);
    fill(newColor4, newColor4, newColor5);
    rect(480,320,40,40);
    fill(newColor8, newColor3, newColor6);
    rect(520,320,40,40);
    fill(newColor4, newColor2, newColor7);
    rect(560,320,40,40);
    fill(newColor4, newColor1, newColor8);
    rect(600,320,40,40);
    fill(newColor5, newColor7, newColor1);
    rect(640,320,40,40);

//row 10
    fill(newColor8, newColor2, newColor3);
    rect(0,360,40,40);
    fill(newColor3, newColor5, newColor6);
    rect(40,360,40,40);
    fill(newColor3, newColor8, newColor7);
    rect(80,360,40,40);
    fill(newColor3, newColor5, newColor4);
    rect(120,360,40,40);
    fill(newColor3, newColor2, newColor1);
    rect(160,360,40,40);
    fill(newColor3, newColor8, newColor2);
    rect(200,360,40,40);
    fill(newColor8, newColor3, newColor6);
    rect(240,360,40,40);
    fill(newColor3, newColor5, newColor8);
    rect(280,360,40,40);
    fill(newColor4, newColor8, newColor1);
    rect(320,360,40,40);
    fill(newColor3, newColor7, newColor2);
    rect(360,360,40,40);
    fill(newColor3, newColor6, newColor3);
    rect(400,360,40,40);
    fill(newColor3, newColor5, newColor4);
    rect(440,360,40,40);
    fill(newColor8, newColor4, newColor5);
    rect(480,360,40,40);
    fill(newColor3, newColor3, newColor6);
    rect(520,360,40,40);
    fill(newColor3, newColor2, newColor7);
    rect(560,360,40,40);
    fill(newColor3, newColor1, newColor8);
    rect(600,360,40,40);
    fill(newColor4, newColor7, newColor1);
    rect(640,360,40,40);

//row 11
    fill(newColor8, newColor2, newColor3);
    rect(0,400,40,40);
    fill(newColor2, newColor5, newColor6);
    rect(40,400,40,40);
    fill(newColor2, newColor8, newColor7);
    rect(80,400,40,40);
    fill(newColor2, newColor5, newColor4);
    rect(120,400,40,40);
    fill(newColor2, newColor2, newColor1);
    rect(160,400,40,40);
    fill(newColor2, newColor8, newColor2);
    rect(200,400,40,40);
    fill(newColor8, newColor3, newColor6);
    rect(240,400,40,40);
    fill(newColor2, newColor5, newColor8);
    rect(280,400,40,40);
    fill(newColor3, newColor8, newColor1);
    rect(320,400,40,40);
    fill(newColor2, newColor7, newColor2);
    rect(360,400,40,40);
    fill(newColor2, newColor6, newColor3);
    rect(400,400,40,40);
    fill(newColor2, newColor5, newColor4);
    rect(440,400,40,40);
    fill(newColor8, newColor4, newColor5);
    rect(480,400,40,40);
    fill(newColor2, newColor3, newColor6);
    rect(520,400,40,40);
    fill(newColor2, newColor2, newColor7);
    rect(560,400,40,40);
    fill(newColor2, newColor1, newColor8);
    rect(600,400,40,40);
    fill(newColor3, newColor7, newColor1);
    rect(640,400,40,40);

//row 12
    fill(newColor2, newColor2, newColor3);
    rect(0,440,40,40);
    fill(newColor1, newColor5, newColor6);
    rect(40,440,40,40);
    fill(newColor1, newColor8, newColor7);
    rect(80,440,40,40);
    fill(newColor1, newColor5, newColor4);
    rect(120,440,40,40);
    fill(newColor1, newColor4, newColor1);
    rect(160,440,40,40);
    fill(newColor3, newColor8, newColor2);
    rect(200,440,40,40);
    fill(newColor1, newColor3, newColor6);
    rect(240,440,40,40);
    fill(newColor1, newColor5, newColor8);
    rect(280,440,40,40);
    fill(newColor2, newColor8, newColor1);
    rect(320,440,40,40);
    fill(newColor1, newColor7, newColor2);
    rect(360,440,40,40);
    fill(newColor1, newColor3, newColor3);
    rect(400,440,40,40);
    fill(newColor1, newColor5, newColor4);
    rect(440,440,40,40);
    fill(newColor1, newColor4, newColor5);
    rect(480,440,40,40);
    fill(newColor1, newColor3, newColor6);
    rect(520,440,40,40);
    fill(newColor1, newColor2, newColor7);
    rect(560,440,40,40);
    fill(newColor1, newColor1, newColor8);
    rect(600,440,40,40);
    fill(newColor2, newColor6, newColor1);
    rect(640,440,40,40);

//row 13
    fill(newColor1, newColor2, newColor3);
    rect(0,480,40,40);
    fill(newColor4, newColor5, newColor6);
    rect(40,480,40,40);
    fill(newColor7, newColor8, newColor7);
    rect(80,480,40,40);
    fill(newColor6, newColor5, newColor4);
    rect(120,480,40,40);
    fill(newColor3, newColor2, newColor1);
    rect(160,480,40,40);
    fill(newColor1, newColor8, newColor2);
    rect(200,480,40,40);
    fill(newColor7, newColor6, newColor6);
    rect(240,480,40,40);
    fill(newColor4, newColor5, newColor8);
    rect(280,480,40,40);
    fill(newColor1, newColor8, newColor1);
    rect(320,480,40,40);
    fill(newColor2, newColor7, newColor2);
    rect(360,480,40,40);
    fill(newColor3, newColor8, newColor3);
    rect(400,480,40,40);
    fill(newColor4, newColor5, newColor4);
    rect(440,480,40,40);
    fill(newColor5, newColor4, newColor5);
    rect(480,480,40,40);
    fill(newColor6, newColor3, newColor6);
    rect(520,480,40,40);
    fill(newColor7, newColor2, newColor7);
    rect(560,480,40,40);
    fill(newColor8, newColor1, newColor8);
    rect(600,480,40,40);
    fill(newColor1, newColor7, newColor1);
    rect(640,480,40,40);

//allows newX and newY to be changed to the mouse position when dragged
    if (drag){
      newX = mouseX;
      newY = mouseY;
    }

    ellipseMode(CORNER);
//draws body and eyes of carl
    fill(32,120,240);
    ellipse(newX,newY,100,100);
    ellipseMode(CENTER);
    fill(255);
    stroke(0);
    strokeWeight(2);
    ellipse(newX+30,newY+30,15,15);
    ellipse(newX+70,newY+30,15,15);
    fill(0);
    ellipse(newX+30+eyeDx,newY+27+eyeDy,6,6);
    ellipse(newX+70+eyeDx,newY+27+eyeDy,6,6);
  //divides canvas into quadrants and shifts pupils based on
  //which quadrant it's in
    if (newY < 240){
      eyeDy = 6;
    }
    if (newY > 240){
      eyeDy = 0;
    }
    if (newX < 320){
      eyeDx = 2;
    }
    if (newX > 320){
      eyeDx = -2;
    }
//drawing the mouth and speech bubble
    fill(190,20,86);
    strokeWeight(3);
    stroke(235,30,100);
    rect(newX+20,newY+50,60,10,5);
    fill(255);
    noStroke();
    triangle(newX-10,newY+10, newX-10,newY,newX-20,newY);
    rect(newX-120,newY-40,110,40);

//creating directional text
    fill(0);
    textSize(20);
    text("press any key to accelerate!", 30, 455);
    text("drag carl for a new starting point!", 30, 475);
    textSize(15);

//changes speech bubble statement based on where he is
    if (newY >240){
      text("wow so pretty",newX-110,newY-18);
    }
    if (newY <= 240){
      text("cool, i guess",newX-110,newY-18);
    }
//allows carl to bounce off edges of canvas
    newX += dirX * speedX;
    if (newX > width - 100 || newX < 0){
      dirX = -dirX;
    }
    newY += dirY * speedY;
    if (newY > height - 100 || newY < 0){
      dirY = -dirY;
    }
//accelerates when any key is pressed.
    if (keyIsPressed){
        speedX = speedX + 0.25;
    }

}

//allows carl to be draged to slow him down
function mousePressed(){
    if (dist(newX, newY, mouseX, mouseY) < 150){
    drag = true;
    }
}
function mouseReleased(){
    drag = false;
    speedX = speedX*0.4;  //deccerates
    speedY = speed*0.4;
}

Carl’s back and ready to play in a colorful landscape. Wave your mouse around to adjust the color while Carl bounces around to observe. Press any key to accelerate Carl, and stop and drag him to tell him to slow down.

sketch

//Dana Kim
// danakim@andrew.cmu.edu
//Section D
// Project-03

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

var x = 320;
var y = 240;
var w = 4;
var angle = 0;

function draw() {
  //ColorChoice1
  if ((mouseY < y) & (mouseX < x)){
    c1 = "#FFA977"; //color for left cube
    c2 = "#FF3C38"; //color for top cube
    c3 = "#FF8D38"; //color for right cube
  }
  //ColorChoice2
  if ((mouseY > y) & (mouseX > x)){
    c1 = "#7A5C61";
    c2 = "#FF3C38";
    c3 = "#A23E48";
  }
  //ColorChoice3
  if ((mouseY > y) & (mouseX < x)){
    c1 = "#BB7279";
    c2 = "#68282E";
    c3 = "#A23E48";
  }

  //Rectangles change size, angle, and color
  push();
  noStroke();
  fill(c1);
  rotate(radians(angle));
  rect(318, 225, w, 30);
  translate(0, 100);
  fill(c2);
  rect(318, 225, w, 30);
  translate(0, -200);
  fill(c3);
  rect(318, 225, w, 30);
  pop();
  angle = angle + 50;

  //width of rectangles change
  if(mouseX>320){
    w = mouseX-300;
  }
  //circles change color and size
  if(mouseX < 320){
  fill(mouseX-200, mouseX+100, mouseY-200);
  stroke(265);
  ellipse(160, mouseY, mouseX-10, mouseX-10);
  }



}

I had originally planned on making a sandwich that would come apart and rotate. However, due to time constraints I decided to go with something simpler. The only problem I really bumped into was that the script kept redrawing the shapes. However, I thought it looked better with the redrawn parts.

atraylor – Project 03 – section B

At first I really wanted to make something symmetrical but that just wasn’t working for me. So I decided to make a scribble star. It was a challenge working with the curves. I find myself constantly comparing the capabilities of p5 with Photoshop, which just makes me miss Photoshop. I did my best to hint at the qualities of stars while constrained to childlike scribbles.

sketch


// atraylor@andrew.cmu.edu
// Project 03 section B 


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

}

function draw() {

    var color1 = color(255, 249, 0); //first color for background
    var color2 = color(101, 25, 204); // second color
    var num = map(mouseX, 0, width, 0, .80); // making a number based on mouse
    var backColor = lerpColor(color1, color2, num); // lerp between color 1 and 2

    background(backColor); // color from above

    // first squiggle star
    var bend = map(mouseX, 0, width, -5, 5); //setting the mouseX output to a new scale from -5 to 5
    curveTightness(bend); // a value from -5 to 5 determines curve for vertex points
    noFill();
    stroke(255, 249, 0);
    beginShape();
    curveVertex(204,89);
    curveVertex(102, 515);
    curveVertex(462, 251);
    curveVertex(102, 515);
    curveVertex(204, 89);
    curveVertex(378, 515);
    curveVertex(18, 251);
    curveVertex(462, 251);
    curveVertex(102, 515);

    endShape();

    //second star
    push();
    var sScale = map(mouseX, 0, width, 0, -60);
    var bend2 = map(mouseX, 0, width, 5, -5); //setting the mouseX output to a new scale from -5 to 5
    curveTightness(bend2); // a value from -5 to 5 determines curve for vertex points
    noFill();
    stroke(255, 249, 0);
    beginShape();
    curveVertex(204,89 - sScale); //transforming points based on sScale variable
    curveVertex(102 - sScale, 515 + sScale);
    curveVertex(462 + sScale, 251);
    curveVertex(102 - sScale, 515 + sScale);
    curveVertex(204, 89 - sScale);
    curveVertex(378 + sScale, 515 + sScale);
    curveVertex(18 - sScale, 251);
    curveVertex(462 + sScale, 251);
    curveVertex(102 - sScale, 515 + sScale);
    endShape();
    pop();

    // first square
    push();
    var rot = map(mouseY, 0, height, 45, 360); // rotation based on mouseY
    var recScale = map(mouseX, 0, width, 1, .75); // scale from 1 to .75 based on mouseX
    stroke(255, 249, 0);
    rectMode(CENTER);
    translate(240, 320);
    scale(recScale);
    rotate(radians(rot));
    rect(0,0,400,400);
    pop();
    //second square
    push();
    var rot2 = map(mouseY, 0, height, -45, -360);
    stroke(255, 249, 0);
    rectMode(CENTER);
    translate(240, 320);
    scale(recScale);
    rotate(radians(rot2));
    rect(0,0,400,400);
    pop();
    // ellipse
    push();
    var cScale = map(mouseX, 0, width, 1, .75);// scale based on mouseX
    stroke(255, 249, 0);
    fill(255, 249, 0, 40);
    translate(240, 320);
    scale(cScale);
    ellipse(0, 0, 410, 410);
    pop();



}

dnoh-sectionD-project3-dynamicdrawing

sketch

// red = 205, 63, 63
// green = 63, 205, 63

var liney = 20;
var redX = -15;
var redX2 = 655;
var blueY = -15;
var blueY2 = 495;
var lineT = 0;
var lineB = 480;
var lineL = 0;
var lineR = 640;
var whiteFill = 255;
var lineStrokeR = 63;
var lineStrokeG = 205;
var lineStrokeB = 63;

function setup() {
  createCanvas(640,480);
  background(39,48,47);
}

function draw() {
  background(39,48,47);
//refreshing background

//blinking effect in background
  stroke(39,64,47);
  line(0,liney,width,liney);
  line(0,liney+40,width,liney+40);
  line(0,liney+80,width,liney+80);
  line(0,liney+120,width,liney+120);
  line(0,liney+160,width,liney+160);
  line(0,liney+200,width,liney+200);
  line(0,liney+240,width,liney+240);
  line(0,liney+280,width,liney+280);
  line(0,liney+320,width,liney+320);
  line(0,liney+360,width,liney+360);
  line(0,liney+400,width,liney+400);
  line(0,liney+440,width,liney+440);
  line(0,liney+480,width,liney+480);
  line(0,liney+520,width,liney+520);
  line(0,liney+560,width,liney+560);
  line(0,liney+600,width,liney+600);
  line(0,liney+640,width,liney+640);
  liney = liney + 80;

  if (liney > height) {
    liney = 0;
  }
//reset green lines to make it blink

//color blocks that shoot out
  noStroke();
  rectMode(CENTER);
  fill(0,255,255); //c
  rect(redX,mouseY,20,20);
  redX = redX - 25;
  fill(255,0,255); //m
  rect(redX2,mouseY,20,20);
  redX2 = redX2 + 25;
  fill(255,255,0); //y
  rect(mouseX,blueY,20,20);
  blueY = blueY - 25;
  fill(0); //k
  rect(mouseX,blueY2,20,20);
  blueY2 = blueY2 + 25;

//green crooshair
  stroke(lineStrokeR,lineStrokeG,lineStrokeB);
  strokeWeight(2);
  line(mouseX,lineB,mouseX,lineT);
  line(lineL,mouseY,lineR,mouseY);

  var rectX = 20;
//white box in crosshair
  fill(whiteFill);
  rect(mouseX,mouseY,rectX,rectX);

//white box enlarges when pressed, white box becomes gray, green becomes red
  if (mouseIsPressed) {
    lineM1 = mouseX-50;
    lineV1 = mouseY-50;
    lineM2 = mouseX+50;
    lineV2 = mouseY+50;
    lineM3 = mouseX+50;
    lineV3 = mouseY-50;
    lineM4 = mouseX-50;
    lineV4 = mouseY+50;
    line(lineM1,lineV1,lineM2,lineV2);
    line(lineM3,lineV3,lineM4,lineV4);

    ellipse(mouseX,mouseY,70,70);
    lineStrokeR = 255;
    lineStrokeG = 63;
    lineStrokeB = 63;
    whiteFill = 80;
  } else {
    whiteFill = 255;
    lineStrokeR = 63;
    lineStrokeG = 205;
    lineStrokeB = 63;
  }
  print(mouseIsPressed);
}



function mouseClicked() { //when mouse is clicked, the color squares jump to mouse and start moving again
  redX = mouseX;
  redX2 = mouseX;
  blueY = mouseY;
  blueY2 = mouseY;
}

The background lines are constantly blinking to add an effect of constant movement. The mouse is followed by a vertical and horizontal line that changes colors from green to red when clicked. When clicked, the square in the center changes colors and shapes. Finally, four color blocks jump out of the crosshair when clicked.

Initially I wanted to create a code that would print a square wherever I clicked and the four blocks would collide into that square. However, I could not figure out a code that would let me keep the square after I clicked it.