Alex One Liner

Screen Shot 2014-10-01 at 4.54.23 PM

For this assignment, I wanted to have a line that would bend with the movement of the mouse. I succeeded by using vectors. However, that was too easy and boring. So, i decided to add more lines that moved with the mouse but were fixed at different angles. I really enjoy the forms and shades created by a gem. I originally had all of the lines move with the mouse however, I re read the prompt and decided to only move one of the lines. I then thought it would be interesting to add a transparency so that the viewer can observe the tonal changes.

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

void draw(){
 background(200);
 
  fill(220);
 beginShape();
   vertex (200,0);
   vertex(height/2+150, height/1.5);
   vertex(200,400);
 endShape(); 
 
 fill(10);
 beginShape();
   vertex (200,0);
   vertex(height/2+70, height/1.5);
   vertex(200,400);
 endShape();   
 
  fill(215);
 beginShape();
   vertex (200,0);
   vertex(height/2+20, height/1.5);
   vertex(200,400);
 endShape();  
 
 fill(255);
  beginShape();
   vertex (200,0);
   vertex(height/2-150, height/1.5);
   vertex(200,400);
 endShape();
 
 fill(150);
 beginShape();
   vertex (200,0);
   vertex(height/2-100, height/1.5);
   vertex(200,400);
 endShape();  
 
  fill(50);
 beginShape();
   vertex (200,0);
   vertex(height/2-50, height/1.5);
   vertex(200,400);
 endShape(); 
  
 fill(100,100,100, 100);
 beginShape();
   vertex (200,0);
   vertex(mouseX, height/1.5);
   vertex(200,400);
 endShape(); 
} 

One Line Project

One line concept sketch One line concept sketch

For my one line project I made a code in which a line is attempting to cross the board but every time your mouse gets in front of it stops it. When your mouse is on greater than it by ten paces/pixel it is pushed back one pixel. I had a lot of problems with this piece, most of which dealt with my initial code which had a numerous amount of ‘if’ statements that seemed to contradict each other at one point. I made many versions of this piece but I feel that I’m happiest with the last one which incorporates some of the skills we’ve learned.

Finished Product Finished Product
int x=0;
int x2=0;
int y1=150;
int y2=300;
void setup(){
size(450,450);


}


void draw(){
background(0);

stroke(255);
if(x<width){
line(x,150,x,300);
x=x+1;

}
if ((mouseX>=x+10)&&(x>11)){//if the mouse is ten pixels in from it

x=x-1;

}
if (mouseX==x){
x=x-10;
}
if (x>=width){//if line crosses the border reset it to 0
x=0;

}

}

10 kinked lines

bloggif_542c6974451ce

Moving the mouse right, the line kinks and folds downward.


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

void draw () {
  
  background (100);
  strokeWeight (3);
  stroke (255);
  
  for (int i= 140; i <400; i+=25) {
    
    float mx = map (mouseX, 0, height, 150, 300);
    line (i, mx, i+40, 300);
    
    if (mouseY>150){
      for (int j=140; j<400; j+=25)
      
      line (j, mx, j+40, 150);
    }
    }
   
    }

One Thousand Lines

Concept Concept

For my 1 thousand lines I created a series of lines that ran along the borders of the page. I mapped them to the position of the mouse and made it so stroke weight and the amount of lines would change depending on the position of the lines. I also changed the increment in which the lines were draw, switching between predetermined numbers to random ones. Like my other two line projects I seemed to have a incredibly hard time bringing what I had envisioned on paper into fruition. I had some issues with making if statements that weren’t complete contradictions of one another as well as call values. Unlike my other two line programs by this attempt I had become more familiar with mapping and didn’t have a big issue with it. Overall I was really pleased with my final outcome.

ten thousand lines

 

 

float x1=150;
float y1= 400;
float lines;
float botlines;
float leftlines;
float rightlines;
float mapDheight;
  float maplW;
  float addby=2;
void setup(){
  size(500,500);
}

void draw(){
  background(255);
  strokeWeight(1);
  //toplines
  smooth();
  
  
  float mapH= map(mouseY,0,height,400,500);
  //the top lines on the screen
   if (mouseX<=0){
    strokeWeight(5);
    
    
        }
        
  if (mouseY<=200){mapH=mouseX; }  if (mouseY>=400){
    mapDheight=mouseY;
    
 }
 
 if (mouseX>400){
   leftlines= mouseX;
   
   
 }
    
 
  //bottom lines on screen 
  for( lines = 0; lines<=width; lines= lines+addby){
  
  line(lines,mapH,lines,500);
  if(mouseY<250){
    addby=24;
  }else{
    addby=2;
  }
  
  
  
  }
 
  
  
  
  //the toplines on the screen 
mapDheight= map(mouseY,0,height,0,100);
   for(botlines=0; botlines<=width; botlines= botlines+addby){ line(botlines,mapDheight,botlines,0);if (mouseY>400){
      addby=.5;
    }
  
  }
  
  

  
  float maplW= map(mouseX,0,width,0,100);
  //the left lines on the screen 
 for(leftlines=0; leftlines<=height; leftlines= leftlines+addby){     if (mouseX>300){
      addby=random(10,30);
    }
   
   line(0,leftlines,maplW,leftlines);
  
 }
 
 
  float mapRW= map(mouseX,0,width,400,500);
  //the left lines on the screen 
 for(rightlines=0; rightlines<=height; rightlines= rightlines+addby){
  if(mouseX<100){
    addby=random(50,100);
    
  }
   
   line(500,rightlines,mapRW,rightlines);
 }
 println("MouseX", mouseX, "mouseY:", mouseY);
 

 
}

Ten Lines

Concept Concept

Again, for this piece I had envisioned something that played with the idea of the mouse pushing a line forward and back. For my ten lines project I had similar problems as seen in my first one. Mainly these problems dealt with if statements and making sure they weren’t contradicting one another. I created a series of ten lines that when up horizontally that reacted to whether or not the mouse was in a certain range. The lines would then move away the mouse if it was in that range. Overall I didn’t really like this piece, mostly because of the fact that it wasn’t what I envisioned in addition to my long hours spent attempting to tackle it.

 

Complete Complete
float x1=100;
float x2=345;

int y2=300;
void setup(){
  size(450,450);
  
  
}


void draw(){
  background(0);
  
  stroke(255);
  

 
 for (int i = 0; i < =10; i = i+1) {
   
   float imov= map(i,0,10,0,height);
  line(x1, imov, x2, imov);

 if( (mouseX>=200)&&(mouseX< =300)){
   x1= imov-15;
  
 }else{
   
   x1=100;
 }
 if (mouseY<200){
   x1= random(100);
 }
 }
  
}

 

10 lines

10 lines to make an infinite hallway. Moving the mouse to the right when you’re at a window will turn the lights on or off. This a very basic version of what I originally wanted to. I was hoping to have the colors fade, not switch.

 

 

float winSpeed;
float winX;
float lineCol, backgroundCol;
float startPoint;


void setup() {
  size(700, 700, P3D);
  winX= width/7;
  lineCol=0;
  backgroundCol=255;
  startPoint=-2500;
}

void draw() {
  noStroke();
   background(backgroundCol);
  // winX= winX-1;
       if (winSpeed > 5300){
          winSpeed=startPoint;
//          if (backgroundCol == 0)backgroundCol=255;
//          if (backgroundCol == 255)backgroundCol=0;
//          if (lineCol == 0)lineCol=255;
//          if (lineCol == 255)lineCol=0;
       }
   winSpeed=winSpeed+20;
   
  moveZ(winX, height/2, startPoint, winSpeed); 
  if (pmouseX < mouseX && winSpeed > 3000 && winSpeed < 3400 ){
     if( backgroundCol == 255 ){
         while (backgroundCol > 0 )
         {backgroundCol= backgroundCol-10;
         }}
     if( backgroundCol == 0 ){
         while (backgroundCol < 255 )
         {backgroundCol= backgroundCol+10;
         }
       }
      if( lineCol == 255 ){
         while (lineCol > 0 )
         {lineCol= lineCol-10;
         }}
     if( lineCol == 0 ){
         while (lineCol < 255 )
         {lineCol= lineCol+10;
         }}
  }
  
  
 
}

void moveZ(float x, float y, float z, float speed) {

  z = z + speed;

  drawDoors(x*2, y, z);//left door
  drawDoors(x*5, y, z+50);//rightdoor
}

void drawDoors(float x, float y, float z) {
  float speed=10;
  float side = 103;
  stroke(lineCol);

//strokeWeight(winSpeed); //uncomment for something different
 //strokeWeight(sqrt(speed/100));
strokeWeight(pow(1.5,winSpeed*.001)-.2);  // the -1 gives the flicker at the beggining
  //REMEBER TO UNCOMMENT ^^^^^^^

  //z = z + speed;
  
  line(x, y+100, z+50, x, y+100, z-50);//top
  line(x, y+side, z-50, x, y-side, z-50);//right
  line(x, y-100, z-50, x, y-100, z+50);//bot
  line(x, y-side, z+50, x, y+side, z+50);//left
 
  //  line(x, y+100, z+50, x, y+100, z-50);//top
  //  line(x, y+side, z-50, x, y-side, z-50);//right
  //  line(x, y-100, z-50, x, y-100, z+50);//bot
  //  line(x, y-side, z+50, x, y+side, z+50);//left
  //     }



  //  beginCamera();
  //  camera(x,y,z+speed,x,y,z+speed, 0, 1, 0);
  //  endCamera();
}

Abbey Road

Concept Concept

For my time project I wanted to make a visual clock that showed people crossing the street during the duration of the day. I was inspired by the Beatles album cover Abbey Road and my design was based off that iconic image. I created four figures, each linked to a different time. The smallest, child like figure is milliseconds, the next taller one is seconds which is second fastest across the screen, the fourth fastest figure is minutes. The tallest figure is of course hours. The fastest blue figure was linked to milliseconds, the second fastest figure was linked to seconds, the third, minutes and the last, hours. Each figure would move real-time according to minutes and hours. I also changed the color of the outfits of the minutes, hours and seconds as they crossed the threshold. The traffic light is also a sort of clock as well. From 1 to 4 it is red, from 5 to 8 green and from 9 to 12 it is yellow.

My main goal was to both create a recognizable scene through processing and link that scene to the passage of time.  I was especially focusing on visuals  for this project seeing as I hadn’t been happy with the overall appearance of some of my other programs. Overall, I like my results, especially considering the amount of time I spent creating the actual image. If possible I would like to add more aspects to the scene including passing vehicles and the like.

Completed Final version Completed Final version

 

 


 float skinc=227;
float x=1;
float s= second();
float h= hour();
float m= minute();
float grelight=250;
float grealpha=0;
float relight=0;
float realpha=255;
float yelllight=0;
float yelllightalpha=255;
color milclothesc=color(255,255,255);
float secclothes= 170;
 //changing the color of the persons outfit
  float change;

float moving3old=0;
void setup(){
  
  size(450,450);
  noStroke();
  
}


void draw(){
  
 smooth();
  background(29,208,242);
  
  //street
  fill(113,112,111);
  beginShape();
  vertex(-58,450);
  vertex(165,160);
  vertex(291,160);
  vertex(490,450);
  endShape();
  //left sidewalk
  fill(155,153,151);
    beginShape();
  vertex(148,160);
  vertex(-434,553);
  vertex(-63,478);
  vertex(175,160);
  endShape();
  //right sidewalk
fill(155,153,151);
  beginShape();
  vertex(289,160);
  vertex(476,442);
  vertex(545,357);
  vertex(313,161);
  endShape();
  
  fill(255);
  //left buildings
beginShape();
vertex(0,0);
vertex(169,114);
vertex(166,160);
vertex(-26,300);
endShape();

//right buildings
beginShape();
vertex(451,-1);
vertex(304,114);
vertex(305,160);
vertex(461,300);
endShape();
  
 fill(0);//gaps between buildings
  beginShape();
  vertex(112,75);
  vertex(123,83);
  vertex(123,193);
  vertex(116,197);
  endShape();
  
   beginShape();//right gaps
  vertex(413,29);
  vertex(402,37);
  vertex(404,249);
  vertex(412,258);
  endShape();

float time= hour()+minute()+millis();
if(time< =4){//from  0 to 4
  grelight=0;
  grealpha=255;
  relight=250;
  realpha=0;
   yelllight=0;
   yelllightalpha=255;

}
if((time>4)&&(time< =8)){//from 5 to 8 color will be green 
  grelight=250;
  grealpha=0;
  relight=0;
  realpha=255;
   yelllight=0;
   yelllightalpha=255;

}
if((time>8)&&(time< =12)){//from 9 to 12it is   yellow
  grelight=0;
  grealpha=255;
  relight=0;
  realpha=255;
   yelllight=250;
   yelllightalpha=0;

}


//traffic light
fill(68);
rect(385,105,36,94);
rect(399,188,8,116);

fill(255,0,0,relight);//red light
ellipse(403,123,25,25);
fill(0,0,0,realpha);//not on
ellipse(403,123,25,25);

fill(249,250,91,yelllight);//yellow
ellipse(403,153,25,25);
fill(0,0,0,yelllightalpha);//not on
ellipse(403,153,25,25);

fill(0,255,0,grelight);//green
ellipse(403,182,25,25);
fill(0,0,0,grealpha);//not on
ellipse(403,182,25,25);
  noStroke();
  for (float i=160; i<320; i=i+32){//creating the peach lines going don the street
  
    
    fill(234,218,194);
    rect(228,i,3,19);
    
     }
     
     
        fill(234,218,194);//left square
     beginShape();
     vertex(85, 321);
     vertex(126,321);
     vertex(91+(-91),1101);
     vertex(11,450);
     endShape();
     
        fill(234,218,194);//right square 
     beginShape();
     vertex(335, 321);
     vertex(379,321);
     vertex(875+(-91),1101);
     vertex(383,450);
     endShape();
     
     for(float e=150; e<289; e=e+108){
          fill(234,218,194);//middle square s
     beginShape();
     vertex(e+10, 321);
     vertex(e+52,321);
     vertex(e+75,450);
     vertex(e+-4,450);
     endShape();
}
     

  //mapping the first person with hours
  //head4
  fill(562,220,187);
  
 float hoursmove= (map(hour(),0,23,0,width));
  if( hoursmove<=0){
    secclothes= random(0,255);
    
  }
//left leg
  triangle(hoursmove+-29,407,hoursmove+12,323,hoursmove+-6,311);
//right leg
  triangle(hoursmove+15,416,hoursmove-(-13),307,hoursmove-5,316);
   fill(secclothes,544,-2);//stomach color
   triangle(hoursmove+(-1),196,hoursmove+-30,341,hoursmove+17,327);//stomach
   fill(562,220,187);

 ellipse(hoursmove,200,28,50);//head
 triangle(hoursmove+-29,298,hoursmove+-3,219,hoursmove+-6,254);//arm top
 

 
 float minmove= (map(minute(),0,59,0,width));
  //head3
  if(minmove==0){
    secclothes= random(0,255);
    
  }
  fill(250,227,192);
  
    //left leg
  triangle(minmove+-35,419,minmove+-12,344,minmove+5,344);
//right leg
triangle(minmove+8,419,minmove+-7,344,minmove+8,344);

fill(350,secclothes,104);
triangle(minmove+-6,279,minmove+9,346,minmove+-25,361);//stomach

fill(250,218,192);
ellipse(minmove,259,31,50);//head
//top arm 
  triangle(minmove+15,344,minmove+-10,306,minmove+-5,288);
  

  
  //head2
float moving2= millis()%1000;
//actual number of seconds as an whole number

float moving3=round(float(millis()-500)/1000);


 float moving= map(moving2,0,1000,0,width);
 
  if(moving3!=moving3old){
   milclothesc= color(random(0,255),random(0,255),18);
 
    moving3old = moving3;
    
  }

  
  fill(milclothesc);//stomach color
  triangle(moving+0,341,moving-(1),387,moving+25,381);//stomach
 //left leg
 triangle(moving-6,412,moving-(1),385,moving+18,379);
 
//right leg
  triangle(moving+22,410,moving-(-11),383,moving+24,379);
  
  fill(250,218,192);
  //top arm
  ellipse(moving,329,29,28);
  triangle(moving-31,377,moving-0,342,moving-(-4),351);
  
  //mapping the most left girl in purple with the amount of seconds
  float mappingtime= (map(second(), 0,59,0,width));
  
  //changing the color of the persons outfit

 if (mappingtime==0){
   secclothes= random(0,255);
     
 }if (secclothes>255){
   secclothes=0;
   
 }
  
  //head1
  fill(160,110,2);
  
   fill(160,110,2);
 //back arm
triangle(mappingtime-(-31),358,mappingtime+5,311,mappingtime-3,321);
   //back leg
triangle(mappingtime+-16,413,mappingtime-4,346,mappingtime+14,346);
//right leg
triangle(mappingtime+21,417,mappingtime-3,346,mappingtime+13,360);
fill(secclothes,138,245);//stomach color
  triangle(mappingtime+2,297,mappingtime-18,386,mappingtime+21,378);//stomach
  fill(160,110,2);
  //top arm 
  ellipse(mappingtime,288,31,38);//head
  triangle(mappingtime-27,344,mappingtime+2,324,mappingtime-(-1),310);
   
 println("secclothes", secclothes, "moving", moving, "changingtime", mappingtime);
}

 

wheat waves (1000)

bloggif_542c676569efaScreen Shot 2014-10-01 at 16.42.14

Thank you Golan for the sinusoidal support!!

Each line is created from 30 segments, and there are approx. 33 independent waves to total 1000 lines. When the mouse is clicked, the waves react.
Would have liked to offset the reaction, so that one starts slightly after the other.

float maxAmplitude;

void setup() {
  size(800, 500);
  maxAmplitude = 0;
}



void draw() {
  background (148, 213, 214);


  maxAmplitude = maxAmplitude * 0.96;
  fill (0);


  int nSegments = 30; 
  float segmentLength = 10; 
  noFill() ;

  int numWaves = 33;
  float spacing = float(width)/float(numWaves);

  for (float j = 0; j < spacing*numWaves; j += spacing) {
    pushMatrix();
    println(j);
    translate(j, 0);
    
    
    float howFar = j / float(width);
    strokeWeight (1);
    stroke (247, 231, 213, 255*howFar); //gradient
    beginShape(); 
    for (int i=20; i<nSegments; i++) {
      float phase = 0.4; 
      float frequency = 120;
      float t0 = millis()/frequency + (i  )*phase;

      float amplitude0 = map(i, 0, nSegments, 0, maxAmplitude); 
      float sinusoidalDeflection0 = amplitude0 * sin(t0); 
      float x0 = 100 + sinusoidalDeflection0; 
      float y0 = i*segmentLength; 

      curveVertex (x0, y0);
      curveVertex (x0*1.5, y0*1.5);
      curveVertex (x0/2, y0/4);
      curveVertex (x0, y0);
      curveVertex (x0+5, y0+5);
    }
    endShape();
    popMatrix();
  }
}



void mousePressed() {
  maxAmplitude = 50;
}

1000 lines- spirograph

Ok so basically I wanted to make a spirograph so I went and did a bunch of research and I made a spirograph and it’s kinda psychedelic. The gifs are kinda large and won’t play so right-click and open them in another tab.
spirograph2

spirograph

spirograph3

 

I guess I don’t really know what to say to talk about these other than I went and looked at actual math and other peoples’ code to see how spirographs even worked, and then I tried to do a much more complicated color thing that decided to refuse to work for some reason so instead it does a color thing related to the position of the mouse instead.

oneliner

bloggif_542c62b4c4529

As you move the cursor across the screen, the line increases suddenly in size, flooding the screen.

float x; 

void setup () {
  size (400, 400);
  smooth ();
  x = width/2;
  noCursor ();
}

void  draw () {
 
  
  background (200);
  strokeWeight (1);
  stroke (255);
  if (mouseX > x) {
    x += 2 ; 
  }
  if (mouseX < x) {
    x -= 2;
   
  }
  
  line (x, 200, 20, 200);
  
  line (mouseX, mouseY, mouseX, mouseY );
  line (mouseX, mouseY, mouseX, mouseY );
  
 if (mouseX > width/2) {
   strokeWeight (650);
 
 }
 else {
   strokeWeight (1);
 }
 

 
 if (mouseX > width/2) {
   stroke (100);
   strokeWeight (650);
   
    if (mouseX > x) {
    x += 2 ; 
  }
  if (mouseX < x) {
    x -= 2;
   
   
   line (x, 200, 20, 200);
   line (mouseX, mouseY, mouseX, mouseY);
  }
   
 }
 else {
   stroke (255);
   strokeWeight (650);
 }
}