nick /224 /boxsquiggles

import processing.opengl.*;

squiggle[] s = new squiggle[100];
float a;
void setup(){
  size(800,600, OPENGL);
  smooth();
  for(int i = 0; i < s.length; i++){
    s[i] = new squiggle();
  }
  //fill(0,20);
  stroke(255,100);
}


void draw(){
  background(0);
  //translate(mouseX,mouseY);
  translate(width/2,height/2,-500);
  //rotateX(a);
  //rotateY(a);
  for(int i = 0; i < s.length; i++){
    s[i].draw();
  }
  a+=.01;
}

class squiggle{
  float rad;
  float x,y;
  float rand_turn;
  boolean turn = false;
  float speed;
  squiggle(){
    x = 0;
    y = 0;
    rad = random(0,2*PI);
    speed = random(.5,2);
  }
  void draw(){
    //line(x,y,cos(rad) * speed + x, sin(rad) * speed + y);
    //ellipse(x,y,rad,rad);
    pushMatrix();
    translate(x,y,0);
    rotate(rad);
    box(10);
    popMatrix();
    x = cos(rad) * speed + x;
    y = sin(rad) * speed + y;
    if(sqrt(sq(x - (0)) + sq(y - (0))) < 300){
      rad += random(-.25,.25);
      turn = false;
    }
    else {
      if(turn == false){
        rand_turn = random(.1,.3);
        turn = true;
      }
      rad += rand_turn;
    }
  }
}

Page Details
Contact DANM  |  Digital Arts and New Media  |  Arts Division  |  Grad Division
login