Category: Assignment-05-One-Line

Lights Out (one liner)

Have you ever had the feeling that someone is following you? Well in this situation, you’d be correct. In the distance, you see a curtain that appears to be floating in midair flying towards you! Don’t let it catch you, or you won’t be able to see where you’re going. The curtain is relentless. Don’t look away, or you might find yourself in darkness!

 

//Lights out
// If the circle catches your cursor, it will turn out the lights

float buttonX = width/2;
float buttonY = height/2;

void setup(){
size(400,400);
background(255);
frameRate(140);
smooth();

}

void draw(){
float vChase = 1;
float rad = 10;
background(255,10);

stroke(0);
ellipse(buttonX, buttonY, rad, rad);

if(buttonX == mouseX && buttonY == mouseY){

background(0);
println("done");
}

if (buttonX > mouseX){
buttonX -= vChase;
println("minus X");
}

if (buttonX < mouseX){
buttonX += vChase;
println("plus X");

}

if (buttonY > mouseY){
buttonY -= vChase;
println("minus Y");
}

if (buttonY < mouseY){
buttonY += vChase;
println("plus Y");

}

}

SkyLine One Line

A skyline set to Chopin, accompanied with ambient city sounds.
code:

//skyline one line 
//cc Charlotte Stiles 2014

float lineLength = 400.0;
int [] x = new int[400];
float [] y = new float[400];
float lineX,lineY;
float times = .9;
float grab=200;

void setup() {
  background(255);
  size(500, 500);
}
void draw() {
  fill(255,10);
  noStroke();
  rect(0, 0, width, height);

  beginShape();
  for (int i = 50; i < lineLength; i++) {
    
    x[i] = i; //draws line from left to right
    
    lineX= x[i];
    lineY= y[i];
    println(x[i]);

    if (dist (lineX, lineY, mouseX, mouseY) > 400)   {
      lineX = mouseX; //this makes it have more curved lines
      for(float g = 0 ; g < 10; g++){
        if(x[i] <= grab + 200 && x[i] >= grab - 200){ //grab is the center point of the curve
        y [i] = mouseY * (g*.15);//g is made to increase little by little
        lineY = y[i];
       }
      }
    }
    
    strokeWeight(random(.1,1));
    stroke(random(0,100));
    curveVertex(lineX, lineY);//behold, one line
  }
  endShape(); 
}

Catch me you won’t 1 line

 

 

clair chin one line

catchmegif

 

PFont f;
int oneHidingSpotX = 58;
int oneHidingSpotY = 93;
int twoHidingSpotX = 339;
int twoHidingSpotY=142;
int threeHidingSpotX=500;
int threeHidingSpotY=276;
int fourHidingSpotX=190;
int fourHidingSpotY=269;
int fiveHidingSpotX=121;
int fiveHidingSpotY=464;
int lineX=360;
int lineY=360;
int currentTree;
float hidingSpotX=0;
float hidingSpotY=0;
float speed=3;

void setup (){
size(550,550);
smooth();
background(255);
f= createFont(“Helvetica”,20,true);
}

void draw(){
background(255);
///i like trees
///trees from left to right top to bottom
int treeRadius=70;
fill(0);
///tree 1
triangle(58, 20, 30, 75, 86, 75);
triangle(58,50,20,120,98,120);
strokeWeight(15);
strokeCap(SQUARE);
line(58,120,58,160);
///tree 2
strokeWeight(25);
triangle(340,70,320,100,360,100);
triangle(340,100,300,170,380,170);
line(340,160,340,195);
///tree 3
strokeWeight(15);
triangle(500,210,480,310,520,310);
triangle(500,300,480,400,520,400);
line(500,400,500,440);
///tree 4
triangle(190,230,170,250,210,250);
triangle(190,240,160,280,220,280);
strokeWeight(20);
line(190,270,190,310);
///tree 5
triangle(120,430,100,450,140,450);
triangle(120,450,90,480,150,480);
line(120,480,120,510);

//line
strokeWeight(3);
textFont(f);
fill(0);
text(“Catch me- you won’t.”,270,310);
line(lineX,lineY,lineX,lineY+20);
if (distance(mouseX,mouseY,lineX,lineY)<15 && currentTree==0)
{
int tree = (int)random(1,6);
while (currentTree == tree)
{
tree = (int)random(1,6);
}
currentTree = tree;
if (tree==1)
{
hidingSpotX=oneHidingSpotX;
hidingSpotY=oneHidingSpotY;
}
else if (tree==2)
{
hidingSpotX=twoHidingSpotX;
hidingSpotY=twoHidingSpotY;
}
else if (tree==3)
{
hidingSpotX=threeHidingSpotX;
hidingSpotY=threeHidingSpotY;
}
else if (tree==4)
{
hidingSpotX=fourHidingSpotX;
hidingSpotY=fourHidingSpotY;
}
else
{
hidingSpotX=fiveHidingSpotX;
hidingSpotY=fiveHidingSpotY;
}
}
else if (currentTree>0)
{
if (lineX<hidingSpotX)
{
lineX+=speed;
}
else if (lineX>hidingSpotX)
{
lineX-=speed;
}
if (lineY<hidingSpotY)
{
lineY+=speed;
}
else if (lineY>hidingSpotY)
{
lineY-=speed;
}
if (distance(hidingSpotX,hidingSpotY,lineX,lineY)<(1.5*speed))
{
currentTree=0;
}
}
}

float distance (float x,float y,float x1, float y1)
{
float xs=pow(x1-x,2);
float ys=pow(y1-y,2);
float d = pow(xs+ys,0.5);
return d;
}

One Liner

I did not want to create lines, I wanted to create beings. I wanted to be God. And so I was. I examined my creatures and the results surprised me. (Not really, I built them this way.)

In the beginning there was one. Created in my visage, but left to his own thoughts and devices. A free will of sorts. In his plane, he roams unaware of the outside world. When encroached upon, he is shy, timid, and afraid. Alone, he runs, hiding from intruders until he may return safely to his plane.

import java.awt.MouseInfo;
import java.awt.Point;

LineMan guy;
boolean mouseInFrame;
int lastMouseX;
int lastMouseY;

void setup() {
  size(800,600);
  lastMouseX = 0;
  lastMouseY = 0;
  mouseInFrame = false;
  guy = new LineMan(width/2, height/2);
}

void draw() {
  background(255);
  checkForMouse();
  guy.update();
  guy.drawMe();
}

void checkForMouse() {
  Point mousePos = (MouseInfo.getPointerInfo().getLocation());
  int mWinX = mousePos.x;
  int mWinY = mousePos.y;
  int fX = frame.getLocation().x;
  int fY = frame.getLocation().y;
  if ((mWinX > fX && mWinX < fX + width) &&
     (mWinY > fY && mWinY < fY + height)) {
   mouseInFrame = true;
  } else {
   mouseInFrame = false;
  } 
  if (lastMouseX != mouseX){
    lastMouseX = mouseX;
  }
  if (lastMouseY != mouseY) {
    lastMouseY = mouseY;
  }
}

class LineMan {
  float x;
  float y;
  float lineLength;
  float thickness;
  float headX;
  float headY;
  float bottomX;
  float bottomY;
  float hoverValue;
  float shakeValue;
  float speed;
  boolean inPlace;
  float shakeChange;
  boolean noRelocate;
  Position target;
  int lastSeenX; 
  int lastSeenY;
  float scared;
  float originalSpeed;
  
  LineMan(float x, float y) {
   this.lastSeenX = 0;
   this.lastSeenY = 0;
   
   this.x = x;
   this.y = y;
   
   this.lineLength = random(height*.05, height*.1);
   this.thickness = random(width*.005, width*.01);
   
   this.originalSpeed = (max(width * .2 , height * .2) / (this.lineLength * this.thickness));
   this.speed = this.originalSpeed;
   
   this.headX = x;
   this.headY = y - this.lineLength / 2;
   
   this.bottomX = x;
   this.bottomY = y + this.lineLength /2;
   
   this.hoverValue = random(0, 6.28);
   this.shakeValue = random(0, 6.28);
   
   this.shakeChange = .1;
   this.inPlace = false;
   
   this.scared = 1;
   
   target = new Position(width * .1, width * .9, height * .1, height *.9);
  }
  
  void move() {
      float distance = dist(this.x, this.y, this.target.x, this.target.y);
      if (distance < (max(width,height) * .05)) {
        this.inPlace = true;
      } else {
        this.inPlace = false;
      }
      if (!this.inPlace) {
          this.x += this.speed *  -((this.x - this.target.x)/distance);
          this.y += this.speed *  -((this.y - this.target.y)/distance);
      } 
    this.headX = this.x; 
    this.headY = this.y - lineLength/2;
    this.bottomX = this.x;
    this.bottomY = this.y + lineLength/2;
  }
  
  void hover() {
    float xChange = cos(this.shakeValue) * (width * .02);
    float yChange = sin(this.hoverValue) * (height * .02);
    this.headX += xChange;
    this.bottomX += xChange;
    this.headY += yChange;
    this.bottomY += yChange;
    this.hoverValue = (this.hoverValue + this.shakeChange) % 6.28;

  }
  
  void drawMe() {
    strokeWeight(this.thickness);
    line(headX,headY, bottomX, bottomY);
  }
  
  void relocate() {
    float distance;
    float erratic = .1; // bigger value means more erratic behavior. 
    if (mouseInFrame) { // Relocate on screen to a new position if the mouse is on screen
    //These Changes will be erratic and make the line look scared.
      if ((random(10) < erratic) || (lastMouseX != this.lastSeenX || lastMouseY != this.lastSeenY)) {
        this.lastSeenX = lastMouseX;
        this.lastSeenY = lastMouseY;
          if (mouseY < height / 2) { // Top half
            if (mouseX < width/2) { //left
              this.target = new Position(width/2, width, height/2, height); //bottom right
            } else { // right
              this.target = new Position(0, width/2, height/2, height); // bottom left
            }
          } else { //Bottom Half
            if (mouseX < width/2) { //left
              this.target = new Position(width/2, width, 0, height/2); // top Right
            } else { //right
              this.target = new Position(0, width/2, 0, height/2); // top left
            }
          }
      }
    } else { 
      float chance = .1; // Bigger values means more relocation when mouse off screen.
      if (random(10) < chance) { // Relocate in the window sometimes 
        this.target = new Position(width * .1, width * .9, height * .1, height * .9);
      }
    }
  } 

  void worry() {
   if (mouseInFrame) {
      this.shakeValue = (this.shakeValue + (this.shakeChange * this.scared)) % 6.28;
      if (!(this.speed >= this.originalSpeed * 2)) {
        this.speed *= 1.01;
      }
      if (!(this.scared >= 3)) {
        this.scared *= 1.01;
      }
    } else {
        if (!(this.scared <= 1)) {
          this.scared *= .999;
        }
        if (!(this.shakeValue <= .1)) {
          this.shakeValue -= .005;
        }
        if (!(this.speed <= this.originalSpeed)) {
          this.speed *= .999;
        }
      }
  }  
  
  void update() {
    this.worry();
    this.move();
    this.hover();
    this.relocate();
  }
    
}

class Position {
    float x;
    float y;
    
    Position(float startX, float endX, float startY, float endY) {
      this.x = random(startX, endX);
      this.y = random(startY, endY);
    }
}

One Line : draw one line

There’s not much to say about this. Draw one line, if you try to draw more, pointless operations heat up your processor to punish you for breaking the rules. I came up with this idea while sitting in Concept studio.

20141001_175237

Recently, I’ve realized that I haven’t done a true cop out for an assignment in a long time.

oneline

1 Line: Blowout

Screen Shot 2014-10-01 at 12.14.59 PMScreen Shot 2014-10-01 at 12.15.11 PM

 

 

Two shots of a starting generation.

This is a simple test piece involving the reaction of a single line to the mouse. The line in randomly generated, and the points used to construct the curve will move away from the mouse to warp the shape they create.

code:

//Blowout. When you're swirly and you're curly, then you're kitsch

int[] points;
int[] mpoints;

//generates the points used to make the base curve, as well as define
//the static edge cases for the rendered lines
void setup(){
  size(600,600);
  points = new int[24];
  points[0] = 0;
  points[1] = 0;
  points[22] = width;
  points[23] = height;
  for(int i = 0; i < 10;i++){
    points[2*(i+1)] = int(width * noise((2*i)/1.0));
    points[(2*(i+1)+1)] = int(height * noise((2*i + 20)/1.0));
  }
  for(int i = 0;i<12;i++){
    println("point "+i+": "+points[2*i]+", "+points[(2*i)+1]);
  }
  mpoints = new int[24];  
  mpoints[0] = 0;
  mpoints[1] = 0;
  mpoints[22] = width;
  mpoints[23] = height;
}

//adjusts the rendered point based on the position of the mouse.
int[] adjust( int x, int y, int px, int py){
  int[] result = new int[2];
  float dist = sqrt(sq(px-x) + sq(py-y))/60.0;
  if(dist == 0.0){ dist = 0.1;} 
  result[0] = int(px + (px - x)/dist);
  result[1] = int(py + (py - y)/dist);
  return result;
}

int[] pair;

//creates an updated version of each point based on the original
//generation and the position of the mouse, then draws the line
void draw(){
  background(255);
  int x = mouseX;
  int y = mouseY;
  for(int i = 0; i < 10 ; i++){
    pair = adjust(x, y, points[2*(i+1)], points[(2*(i+1))+1]);
    mpoints[2*(i+1)] = pair[0];
    mpoints[(2*(i+1))+1] = pair[1];
  }
  strokeWeight(3);
  noFill();
  stroke(0,0,0);
  curve(mpoints[0],mpoints[1], mpoints[0],mpoints[1],
        mpoints[2],mpoints[3], mpoints[4],mpoints[5]);
  for(int i = 0;i<9;i++){
    curve(mpoints[2*i],mpoints[2*i+1], mpoints[2*i+2],mpoints[2*i+3],
          mpoints[2*i+4],mpoints[2*i+5],mpoints[2*i+6],mpoints[2*i+7]); 
  }
  curve(mpoints[18],mpoints[19], mpoints[20],mpoints[21], 
        mpoints[22],mpoints[23], mpoints[22],mpoints[23]);
}

 

 

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(); 
}