Synesthetic Color Clock

Anyway, this is where I put my time (lol clock puns) for this week’s homeworks.

clock

(ps the gif is massive and won’t play so open it in a new tab on its own)

Anyway. The way this works is that the largest square represents the hour, the medium one the minute and the smallest one the second; the secondary square inside the hour square increases in size every minute, the secondary square inside the minute square increases by the second, and so on.

The colors being used to represent each number on the “clock” are my synesthetic associations for each number; for example, the time being shown in the gif I’ve added is 4:12 into 4:13 (white being 1, blue 2, red 3, purple 4). The green square beginning to grow inside the hour square will eventually fill that entire space to represent 5 o’clock.

 

I was going to make the background change colors with the days of the week, but I couldn’t figure out how to make that work with the days function because that operates in terms of days in the month and I didn’t want to have to fill out a whole chart of color values for every single day of the month.

 

void setup(){
  size(500,500);
  background(120,210,240);
  noStroke();
  rectMode(CENTER);
    //the  reason i'm copypasting this code is because
    //it's awkward if the current  hour  isn't rendered as a square at the start
    //so this just renders the square in the correct color
    //possibly i don't need the entire code in two different places but here goes?
      float hr = hour();
        if ((hr == 1) || (hr == 13)){
          fill(255);
        } else if ((hr == 2) || (hr == 14)){
            fill(50,185,242);
        } else if ((hr == 3) || (hr == 15)){
            fill(225,80,60);
        } else if ((hr == 4) || (hr == 16)){
            fill(160,100,200);
        } else if ((hr == 5) || (hr == 17)){
            fill(100,232,80);
        } else if ((hr == 6) || (hr == 18)){
            fill(234,95,175);
        } else if ((hr == 7) || (hr == 19)){
            fill (232,113,33);
        } else if ((hr == 8) || (hr == 20)){
            fill(50,70,180);
        } else if ((hr == 9) || (hr == 21)){
            fill(60,190,100);
        } else if ((hr == 10) || (hr == 22)){
            fill(195,160,130);
        } else if ((hr == 11) || (hr == 23)){
            fill(212,242,250);
        } else if ((hr == 0) || (hr == 12) || (hr == 24)){
            fill(100,145,185);
        }
  rect(330,330, 280,280);
}

void draw(){
  //seconds
float sec = map(second(),0,59, 1,60); //I'M SO SORRY THIS IS RIDICULOUSLY LONG
    if ((sec == 1) || (sec == 11)){
      fill(255,255,255, 150);
    } else if ((sec == 2) || (sec == 12) || (sec == 20) || (sec == 22)){
        fill(50,185,242, 150);
    } else if ((sec == 3) || (sec == 13) || (sec == 30) || (sec == 33)){
        fill(225,80,60, 150);
    } else if ((sec == 4) || (sec == 14) || (sec == 40) || (sec == 44)){
        fill(160,100,200, 150);
    } else if ((sec == 5) || (sec == 15) || (sec == 50) || (sec == 55)){
        fill(100,232,80, 150);
    } else if ((sec == 6) || (sec == 16) || (sec == 60)){
        fill(234,95,175, 150);
    } else if ((sec == 7) || (sec == 17)){
        fill (232,113,33, 150);
    } else if ((sec == 8) || (sec == 18)){
        fill(50,70,180, 150);
    } else if ((sec == 9) || (sec == 19)){
        fill(60,190,100, 150);
    } else if (sec == 10){
        fill(195,160,130, 150);
    } else if (sec == 21){
        fill(120,212,240, 150);
    } else if ((sec == 23) || (sec == 32)){
        fill(138,132,151, 150);
    } else if ((sec == 24) || (sec == 42)){
        fill(105,142,221, 150);
    } else if ((sec == 25) || (sec == 52)){
        fill(75,209,161, 150);
    } else if (sec == 26){
        fill(142,140,209, 150);
    } else if (sec == 27){
        fill(141,139,148, 150);
    } else if (sec == 28){
        fill(50,128,211, 150);
    } else if (sec == 29){
        fill(55,187,171, 150);
    } else if (sec == 31){
        fill(255,167,158, 150);
    } else if ((sec == 34) || (sec == 43)){
        fill(208,90,130, 150);
    } else if ((sec == 35) || (sec == 53)){
        fill(177,156,70, 150);
    } else if (sec == 36){
        fill(244,88,117, 150);
    } else if (sec == 37){
        fill (244,97,46, 150);
    } else if (sec == 38){
        fill(152,75,120, 150);
    } else if (sec == 39){
        fill(158,135,180, 150);
    } else if (sec == 41){
        fill (208,177,228, 150);
    } else if ((sec == 45) || (sec == 54)){
        fill(130,166,140, 150);
    } else if (sec == 46){
        fill(197,97,187, 150);
    } else if (sec == 47){
        fill(196,107,116, 150);
    } else if (sec == 48){
        fill(105,85,190, 150);
    } else if (sec == 49){
        fill (110,145,150, 150);
    } else if (sec == 51){
        fill(177,244,167, 150);
    } else if (sec == 56){
        fill(167,164,129, 150);
    } else if (sec == 57){
        fill(166,173,56, 150);
    } else if (sec == 58){
        fill(75,151,130, 150);
    } else if (sec == 59){
        fill(80,211,90);
    }
  float l=map(millis()%1000,0,1000, 0,60);
  rect(70,50, l,l);
  
//minutes
      //minute color determiner
  float min = map(minute(),0,59, 1,60); //SORRY THIS ONE IS LONG ALSO
      if ((min == 1) || (min == 11)){
        fill(255,255,255, 150);
      } else if ((min == 2) || (min == 12) || (min == 20) || (min == 22)){
          fill(50,185,242, 150);
      } else if ((min == 3) || (min == 13) || (min == 30) || (min == 33)){
          fill(225,80,60, 150);
      } else if ((min == 4) || (min == 14) || (min == 40) || (min == 44)){
          fill(160,100,200, 150);
      } else if ((min == 5) || (min == 15) || (min == 50) || (min == 55)){
          fill(100,232,80, 150);
      } else if ((min == 6) || (min == 16) || (min == 60)){
          fill(234,95,175, 150);
      } else if ((min == 7) || (min == 17)){
          fill (232,113,33, 150);
      } else if ((min == 8) || (min == 18)){
          fill(50,70,180, 150);
      } else if ((min == 9) || (min == 19)){
          fill(60,190,100, 150);
      } else if (min == 10){
          fill(195,160,130, 150);
      } else if (min == 21){
          fill(120,212,240, 150);
      } else if ((min == 23) || (min == 32)){
          fill(138,132,151, 150);
      } else if ((min == 24) || (min == 42)){
          fill(105,142,221, 150);
      } else if ((min == 25) || (min == 52)){
          fill(75,209,161, 150);
      } else if (min == 26){
          fill(142,140,209, 150);
      } else if (min == 27){
          fill(141,139,148, 150);
      } else if (min == 28){
          fill(50,128,211, 150);
      } else if (min == 29){
          fill(55,187,171, 150);
      } else if (min == 31){
          fill(255,167,158, 150);
      } else if ((min == 34) || (min == 43)){
          fill(208,90,130, 150);
      } else if ((min == 35) || (min == 53)){
          fill(177,156,70, 150);
      } else if (min == 36){
          fill(244,88,117, 150);
      } else if (min == 37){
          fill (244,97,46, 150);
      } else if (min == 38){
          fill(152,75,120, 150);
      } else if (min == 39){
          fill(158,135,180, 150);
      } else if (min == 41){
          fill (208,177,228, 150);
      } else if ((min == 45) || (min == 54)){
          fill(130,166,140, 150);
      } else if (min == 46){
          fill(197,97,187, 150);
      } else if (min == 47){
          fill(196,107,116, 150);
      } else if (min == 48){
          fill(105,85,190, 150);
      } else if (min == 49){
          fill (110,145,150, 150);
      } else if (min == 51){
          fill(177,244,167, 150);
      } else if (min == 56){
          fill(167,164,129, 150);
      } else if (min == 57){
          fill(166,173,56, 150);
      } else if (min == 58){
          fill(75,151,130, 150);
      } else if (min == 59){
          fill(80,211,90);
      }
  float s=map(second(),0,59, 0,120);
  rect(190,105, s,s);
  
//hours
      // hour color determiner
float hr = map(hour(),0,23, 1,24); 
    if ((hr == 1) || (hr == 13)){
      fill(255);
    } else if ((hr == 2) || (hr == 14)){
        fill(50,185,242);
    } else if ((hr == 3) || (hr == 15)){
        fill(225,80,60);
    } else if ((hr == 4) || (hr == 16)){
        fill(160,100,200);
    } else if ((hr == 5) || (hr == 17)){
        fill(100,232,80);
    } else if ((hr == 6) || (hr == 18)){
        fill(234,95,175);
    } else if ((hr == 7) || (hr == 19)){
        fill (232,113,33);
    } else if ((hr == 8) || (hr == 20)){
        fill(50,70,180);
    } else if ((hr == 9) || (hr == 21)){
        fill(60,190,100);
    } else if ((hr == 10) || (hr == 22)){
        fill(195,160,130);
    } else if ((hr == 11) || (hr == 23)){
        fill(212,242,250);
    } else if ((hr == 0) || (hr == 12) || (hr == 24)){
        fill(100,145,185);
    }
  float m=map(minute(),0,59, 0,280);
  rect(330,330, m,m);
  
}

houseplant clock

Screen Shot 2014-10-01 at 15.15.33

I had wanted to use an element of growth to represent time, so my clock is a plant with twelve leaves, each growing depending on the hour (12 hour clock). Every time the clock rolls over from 12, the leaves fade, and the cycle restarts.
If revisited, I would create more of an animated element to the plant (leaves tilting back and forth on a fulcrum, or the leaves changing colour and then falling down to the ground after 12).

void setup () {
  size (500, 600);
}

void draw () {
  background (242, 241, 223);

  fill (222, 217, 197);
  rect (0, 500, 600, 100);
  
  // stem
  stroke (185, 222, 149);
  strokeWeight (2);
  line (300, 500, 300, 100);


  noStroke ();
  fill (209, 99, 77); 
  
  
  beginShape (); // planter pot shape

    vertex (300, 500);
  vertex (200, 500);
  vertex (270, 360);
  vertex (330, 360);


  endShape ();

 // set up time
  int hour24 = hour();
  int hour = hour24 % 12;
  int second = second();
  int minute = minute();

  
  float spacing = 25;

// leaves
  for (int i = 0; i < 12; i++) {
    float distFromStem = i * spacing;
    boolean flip = (i % 2) == 0; // boolean in order to arrange leaves in opp. order

 // @ midnight, leaves fade and reset
    if (hour24 == 0 && minute == 0) {
      float opacity = 1 - (float(second)/59.0); 
      println(opacity);
      fill(185, 222, 149, opacity*255);
      beginShape();
      if (flip == true) { 
        vertex(300, 340 - distFromStem); 
        vertex(320, 350 - distFromStem);
        vertex(320, 335 - distFromStem);
        vertex(300, 340 - distFromStem);
      } else {    
        vertex(300, 340 - distFromStem);
        vertex(280, 350 - distFromStem);
        vertex(280, 335 - distFromStem);
        vertex(300, 340 - distFromStem);
      }
      endShape();
    }

    println(hour);

    if (i <= hour) {

      

      fill (185, 222, 149);

      if (i == hour) {
        int shrink = int(20*(float(minute) / 60.0));  // leaf growth w/ hr   
        beginShape();
        if (flip == true) {
          vertex(300, 340 - distFromStem);
          vertex(300 + shrink, 350 - distFromStem);
          vertex(300 + shrink, 335 - distFromStem);
          vertex(300, 340 - distFromStem);
        } else {    
          vertex(300, 340 - distFromStem);
          vertex(300 - shrink, 350 - distFromStem);
          vertex(300 - shrink, 335 - distFromStem);
          vertex(300, 340 - distFromStem);
        }
        endShape();
      } else {
        beginShape(); //leaf
        if (flip == true) {
          vertex(300, 340 - distFromStem);
          vertex(320, 350 - distFromStem);
          vertex(320, 335 - distFromStem);
          vertex(300, 340 - distFromStem);
        } else {    
          vertex(300, 340 - distFromStem);
          vertex(280, 350 - distFromStem);
          vertex(280, 335 - distFromStem);
          vertex(300, 340 - distFromStem);
        }
      }
      endShape();
    }
  }
}

Hours by the Pigeons

PigeonClockDocumentation3

PigeonClockDocumentation2

PigeonClockDocumentation1

pigeonclockconcept

This is a 24-hour clock that allows one to tell the time by counting how many pigeons are on the roof (The gifs above are sped-up versions of the clock). The location that the pigeons fly in from and out to are randomized, in addition to the pigeon’s sizes and colors. A big thanks to Golan Levin and John Choi for tirelessly explaining the inner workings of classes to me.

To improve on this project, I’d implement behavior that would allow the pigeons to shuffle around the rooftop after landing. I’d also add some visible wings to the pigeons when they fly on and off of the screen.

 //Miranda Jacoby
//EMS Interactivity Section A
//majacoby@andrew.cmu.edu
//Copyright Miranda Jacoby 2014

//A big thanks o John Choi for walking me through OOP.

//Implement personal space
 //for i 
 //if px[i] becomes a high or low value
//Implement hour spawn/despawn
//Implement nice movement for pigeon entering/leaving screen

//Initialize pigeon
Pigeon[] pigeonArray = new Pigeon[24];//22? at 0 o'ckloc there is no pigeon.
int hours = hour();//second()% 24;
int pigeonCount = hours;
float detailOffset = width/20;
int newvar = 0;
int oldvar = 0;
boolean deleted = true;
int delay = 0;

void setup(){
  size(600, 400);

  for (int i =0; i < pigeonCount; i ++){
      pigeonArray[i] = new Pigeon(i);
  }
}


void draw(){
  background(50, 130, 230);
  hours = hour();//second()% 24;
  //Function calls!
  //draw pigeons first so that they are layered under the building
     newvar = hours;
    
    if (oldvar != newvar){
         if (oldvar == 23 && newvar == 0){
           flyAllAway();
           delay = 10;
           deleted = false;
     
        }
         else if (delay <= 0){
           createPigeon();
         }
    }
    oldvar = newvar;
    delay = delay - 1;
    
    if(deleted == false && delay <= 0){
      pigeonArray = new Pigeon[24];
      pigeonCount = 0;
      deleted = true;
    }
    
    for (int i =0; i < pigeonCount; i ++){
    pigeonArray[i].update();
    }
    drawBuilding();
    
}

void createPigeon(){
  pigeonArray[pigeonCount] = new Pigeon(hours);
  pigeonCount = pigeonCount + 1;
}

void flyAllAway(){
  for (int i =0; i < pigeonCount; i ++){       pigeonArray[i].isFlyingAway = true;   } }  class Pigeon {    //Final position    float fpx, fpy;    //Starting position    float spx = random(0, 600), spy = -30;    //Current position    float cpx, cpy;    //Fly away position    float rpx, rpy;    int hour;    float pdiam = random (12, 16);//14;    float colorPicker = random (0, 5);    float spacing = 20;    float velx = 0.1, vely = 0.1;    boolean isFlyingAway = false;    //Work on personal space    boolean isLanded = false;           //Constructor: draw the pigeon, initialize variables    Pigeon (int hour){         fpx = (hour * spacing) + 50;         fpy = 285;//height - height/3.5;         cpx = spx;         cpy = spy;         rpx = random(0, 600);//random (-600, 1200);         rpy = random (-200, -300);             }        void update(){      if (isFlyingAway == true){        flyAway();      }            if (isFlyingAway == false){        move();      }      display(cpx, cpy, colorPicker);    }        void display(float px, float py, float colPicker){            //draws individual pigeon, does not increment        noStroke();     //body      bodyColor(colPicker);      ellipse(px, py + pdiam/2, pdiam * 1.5, pdiam * 1.5);      fill(192, 190, 214);      ellipse(px, py + pdiam/1.5, pdiam * 1.2, pdiam * 1.2);     //neck     //for (colPicker >= 0){
     bodyColor(colPicker);
    //}
     ellipse(px, py, pdiam, pdiam * 1.2);
    //eyes
     fill(227, 121, 34);
    //left eye
     ellipse(px - pdiam/3, py - (pdiam - pdiam/2.7), pdiam/8, pdiam/8 );
    //right eye
     ellipse(px + pdiam/3, py - (pdiam - pdiam/2.7), pdiam/8, pdiam/8 );
    //head
     bodyColor(colPicker);
     ellipse(px, py - (pdiam - pdiam/2.5), pdiam/2, pdiam/2);
    //beak
     stroke(0);
     line(px - 1, py - (pdiam - pdiam/2.5), px - 1 + (pdiam/10), py - (pdiam - pdiam/2.5) );
     noStroke();
     fill(255);
     ellipse(px, py - (pdiam - pdiam/2.7), pdiam/10, pdiam/10 );
 
   }
 
 void move(){

   //Move pigeons between positions with easing
   cpx = cpx + velx * (fpx - cpx);
   cpy = cpy + vely * (fpy - cpy);
    //Move pigeons between positions withouy easing
    //cpx = fpx;
    //cpy = fpy;
 }
 
 void flyAway(){
   
   //Move pigeons between positions with easing
   cpx = cpx + velx * (rpx - cpx);
   cpy = cpy + vely * (rpy - cpy);
   //Move pigeons between positions without easing
   //cpx = rpx;
   //cpy = rpy;
}

void bodyColor(float colPicker){
          if ((colPicker == 0) || (colPicker < 1)){
            fill(132, 95, 137);
        }
        else if ((colPicker == 1) || (colPicker < 2)){
            fill(118, 145, 158);
        }
        else if ((colPicker == 2) || (colPicker < 3)){
            fill(118, 122, 131);
        }
        else if ((colPicker == 3) || (colPicker < 3.5)){
            fill(147, 107, 93);
          //fill(137, 91, 73);
        }
//        else if ((colPicker == 4) || (colPicker < 5)){
//            fill(245, 235, 225);
//        }
        else {
            fill(115, 101, 131);
        }
}
 
 }
void drawBuilding(){
  detailOffset = width/40;
  noStroke();
    //Orange Rect
  fill(211, 135, 58);
  rect(width/8, height - height/4, width - width/4, height - height/4);
  
  //White trapezoid
  fill(247, 225, 202);
  quad(width/10 - detailOffset          , height - height/4, 
       width - width/10  + detailOffset , height - height/4,
       width - width/10  - detailOffset , height - height/8,
       width/10 + detailOffset          , height - height/8);

  //Offwhite detail
  stroke(219, 190, 161);
  strokeCap(SQUARE);
  
   //Middle line
  strokeWeight(16);
  line(width/10        , height - height/5.75, 
       width - width/10, height - height/5.75);
       
  //Bottom line    
  strokeWeight(8);
  line(width/10 + detailOffset        , height - height/8, 
       width - width/10 - detailOffset, height - height/8);
       
  //Top line
   strokeWeight(12);
   line(width/10 - detailOffset        , height - height/4.30, 
        width - width/10 + detailOffset, height - height/4.30);
   //Middle line white detail    
   stroke(247, 225, 202);
   strokeWeight(4);
   line(width/10        , height - height/5.75, 
        width - width/10, height - height/5.75);   
 }
 

One Thousand Lines (Perlin Mess)

What a mess… experiments with Perlin Noise
Screen Shot 2014-10-01 at 3.47.39 PM (2)
Screen Shot 2014-10-01 at 3.47.53 PM (2)
Screen Shot 2014-10-01 at 3.47.40 PM (2)

float[] noise= new float[333];
int[] x1= new int[333];
int[] y1= new int[333];
int[] x2= new int[333];
int[] y2= new int[333];
float xoff = 0.0;
float xoff2 = 1;

void setup(){
  size(1280,720);
  for(int i=0;i<333;i++){
      x1[i] = int(random(5,2275));
      y1[i] = int(random(5,1715));
      x2[i] = x1[i] + int(random(-100,100));
      y2[i] = y1[i] + int(random(-100,100));
  }  
}

void draw(){
  background(#ffffff);
  xoff = xoff + .02;
  xoff2 = xoff2+.02;
  for(int i=0; i<333; i++){
      float n = noise(xoff);
      float g = noise(cos(xoff2)+2);
     // int x1n = 
      int s1 = int(random(8,12)*random(0,1));
      int s2 = int(random(8,12)*random(0,1));
      line(x1[i]*g,y1[i]*n,x2[i]*n,y2[i]*g);
      fill(#ffffff); stroke(0); strokeWeight(2);
      ellipse(x1[i]*g,y1[i]*n,s1,s1);
      ellipse(x2[i]*n,y2[i]*g,s2,s2);
    }
    if(mousePressed){noLoop();}
  }

Clock

Screen Shot 2014-10-01 at 3.34.23 PM

I was trying to make a 12hour clock that would take a flower shape and for each hour the petal of the flower would be added to the middle part of the flower. For each minutes the orange dots would be randomly placed in the circle and for the seconds smaller brown dots would be placed in it.

I had hard time trying to make the circles be in a circular shape and trying to make the code work since it wouldn’t refresh itself every second and increase in the number of dots in the middle even though I wrote the function in the draw function.(I still couldn’t fix it) However, the shape came out as I wanted it to come out except that it isn’t working perfectly right now. I need to go back and see what the problem is.

 

void setup() {
size(400, 400);
}
void draw(){
  smooth();
  background(255);
  noStroke();
  float cx = width/2;
  float cy = height/2;
  float diameter = width*.6;
  float nbr_circles = 12;
  float lg_diam =  width * .55;                 // large circle's diameter
  float lg_rad  = lg_diam/2;                    // large circle's radius
  float lg_circ =  PI * lg_diam;                // large circumference
  float sm_diam = (lg_circ / nbr_circles);      // small circle's diameter
  float hourCount = hour();
  hourCount = hourCount%12;
  for (int i = 1; i < = nbr_circles; ++i) {
    if (hourCount > 0){
      fill(240,186,239);
      float angle = i * TWO_PI / nbr_circles;
      float x = cx + cos(angle) * lg_rad;
      float y = cy + sin(angle) * lg_rad;
      ellipse(x, y, sm_diam, sm_diam);
      println(hourCount);
      hourCount = hourCount - 1;
    }else{
      noFill();
      float angle = i * TWO_PI / nbr_circles;
      float x = cx + cos(angle) * lg_rad;
      float y = cy + sin(angle) * lg_rad;
      ellipse(x, y, sm_diam, sm_diam);
      hourCount = hourCount -1;
    }
  }

  fill(250,244,192);
  ellipse(cx, cy, lg_diam, lg_diam);

  float minuteCount = minute();
  for (int i = 1; i < = minuteCount; ++i){
    fill(245,144,77);
    ellipse(random(140,260),random(140,260),10,10);
  } noLoop();


  float secondCount = second();
  for (int i = 1; i <= secondCount; ++i){
    fill(108,81,68);
    ellipse(random(130,270),random(130,270),6,6);
  } noLoop();
}

IMG_20141001_145621 (1)

Ten Lines (Evade the Lines)

Sorta broke the color rule (whoops!) but its sorta needed. Here’s a game that only has 10 active lines on the screen, one player line and the rest are white lines meant to dodge. Use left/right arrow keys to dodge the incoming randomly generated lines.
tenline

int speed = 4;//speed
int[] h = new int[10];
int width = 75; //width changes length of lines (lines = width/2)
int height = speed*150; //height (depends on speed for ease on eyes)
int x = 0; //start locatoin for red player line
int switcher = 1;
int start = 0;
int score=0;

void setup(){
  size(width,height);
     background(255);
     for(int i=0;i<10;i++){
  h[i]= -height/9*i+int(random(-20,20));}
}
void draw(){
  noStroke();
  fill(0,0,0);
  rect(0, 0, width, height);
  strokeWeight(5);
 stroke(255,0,0);
 line(x,height-2,x+width/2,height-2);
 stroke(#ffffff);

 for(int k=0;k<10;k++){
 if(switcher>0){start = width/2;}
 else{start =0;}
 line(start,h[k],start+width/2,h[k]);
   //fill(255,0,0);
   //text(k, start, h[k]);
   //fill(#ffffff);
 h[k] = h[k]+speed;//int(float(speed)*random(0,1));
 
 switcher=switcher*-1;
 if(h[k]>height && x==start){println(score);
 fill(#ffffff);
 text("Score: "+score, width/2-23, height/2);
 noLoop();

 }
 if(mousePressed){noLoop();}
 if(h[k]>height){
 h[k] = reset(k);
  // cleanup(k);
 }


 }
}

void keyPressed() {
  if (key == CODED) {
    if (keyCode == LEFT && x>0) {x=x-width/2;}
    else if (keyCode == RIGHT && x0 && h[m]<50) && h[k]< =0){
   for(int j=k; j<10; j++){
     if(h[j]<0){
     h[j]=h[j]-50;}}
   }
}
}

Ten Lines

Yeah I know this one’s kind of lame too, I tried to do something else and it didn’t do what I wanted but I ran out of a) time and b) patience.

tenlines

I was attempting to get the lines to all rotate independently depending on the movement of the mouse but it didn’t work and ended up rotating them all as a massive chunk together. So I goofed around a little and made it so that all the lines move according to the X position of the mouse, but only the bottom five also react to the Y position. It’s a little pointless and not very elegant or interesting sorry.

void setup(){
  size(300,300);
  background(0);
  stroke(255);
  strokeWeight(2);
}

void draw(){
  background(0,0,0);
  rotate(PI/mouseX);
    line(30,30, 50,30);
    line(50,50, 70,50);
    line(70,70, 90,70);
    line(90,90, 110,90);
    line(110,110, 130,110);
    
  rotate(PI/mouseY+100);
    line(130,130, 150,130);
    line(150,150, 170,150);
    line(170,170, 190,170);
    line(190,190, 210,190);
    line(210,210, 230,210);  
  
}

One Line Game (Keep it up!)

This is a game I thought of using only one line and your mouse. The point of the game is to keep the line from touching the bottom by keeping the mouse under each of the ends of the line. Changing one variable will make it harder or easier to keep it up by limiting the “grace” space the mouse is in, the bubble of effectiveness, down to one pixel.
oneline

// RULES: keep mouse under each end to bounce back up
//        keep mouse over each end to freeze the end
//        keep from hitting the bottom

int points =0;

float x = 80;   // x location of square
float x2 = 120;
float y = 0;     // y location of square
float y2 = 0;

float speed = 0;   // speed of square
float speed2 = 0.5;

float gravity = .05;

int hardness = 7;

void setup() {
  size(200, 900);
  background(255);
}

void draw() {
  fill(#ffffff, 90);
  rect(0, 0, width, height);
  // Display the square
  fill(175);
  stroke(0);
  line(x, y, x2, y2);

  // Add speed to location.
  y = y + speed;
  y2 =y2+speed2;

  // Add gravity to speed.
  speed = speed + gravity;
  speed2 = speed2 + gravity;

  // If square reaches the bottom
  // Reverse speed

  int floor1 = mouseY;
  int floor2 = mouseY;

  if (mouseX >80-hardness && mouseX < 80+hardness && y > floor1 && y < floor1+10) {
    floor1 = mouseY;
    points++;
    speed = speed * -.98;
  } else {
    floor1 = height;
  }
  if (mouseX>120-hardness && mouseX<120+hardness && y2 > floor2 && y2 < floor2+10) {
    points++;
    speed2 = speed2 * -.97;
    floor2 = mouseY;
  } else {
    floor2 = height;
  }


  if (y >= height || y2 >= height) {
    noLoop();
    textSize(30);
    text("Game Over", 20, height/2);
    textSize(15);
    int finalPoints = points;
    text("Points: "+finalPoints, 65, height/2+30);
    speed = 0;
    speed2 = 0;
  }
}

Thousand Lines

Thousand_Line

My idea of thousand lines came from my friends homework where it was some sort of magnetic field/graph. So I thought of it as a way to make the one thousand line assignment since the lines could react to the mouse by staying still but just moving the direction of the lines instead of following the whole thing like my first two line assignments.

 

float spaceBetween;
float columns;
float rows;
PVector mousePosition;
 
void setup() {
  size(480,480);
  spaceBetween = 15;
  columns = int(width/spaceBetween);
  rows = int(height/spaceBetween);
}
 
void draw() {
  background(201,240,242);
  mousePosition = new PVector(mouseX,mouseY);
  stroke(49,196,175);
  for(int i = 0; i <= columns; i++){
    for(int j = 0; j <= rows; j++){
      drawLines(i*spaceBetween, j*spaceBetween);
    }
  }
}
  
void drawLines(float x, float y) {
  PVector pos = new PVector(x,y);
  point(pos.x,pos.y);
  stroke(49,196,175);
  PVector lineTarget = new PVector(mouseX, mouseY);
  lineTarget.sub(pos);
  lineTarget.mult(-1);
   
  pushMatrix();
  translate(pos.x,pos.y);
  lineTarget.normalize();
  lineTarget.mult(10);
  line(0,0, lineTarget.x,lineTarget.y);
  popMatrix();
}

IMG_20141001_145640 copy

One Line

 

 

 

oneline angle

oneline Lenght

oneline

 

I’m aware these could be more interesting; I kind of lost track of time with the other parts of this assignment and this (and the 10 lines one) kind of got the short end of the stick in terms of my attention. But basically the line follows the cursor around, and gets longer and shorter depending where the cursor is located, as well as changes its angle to gravitate toward the top and left depending which one the cursor is closer to.

 

void setup(){
  size(300,300);
  background(0);
  stroke(255);
  strokeWeight(3);
  frameRate(15);
}

void draw(){
  float x1 = mouseX+mouseX/5;
  float y1 = mouseY+mouseY/5;
  float x2 = mouseX-mouseX/5;
  float y2 = mouseY-mouseY/5;
  line(x1,y1, x2,y2);
  fill(0,0,0, 10);
  rect(0,0, 300,300);
}