Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Square Party

Name: Anonymous 2010-01-22 18:53

// It's time to get high /prog/. Load this into processing 1.0.9 and light yourself a fatty, preferably in that order.

RandSquare[] square;

float factor = 1.5;

int   squares = 300;
int   size_scale = int(400 * factor);
float len_max = 60 * factor;
float len_min = 20 * factor;
float pos = len_max/2 * factor;
float speed = 2 * factor;
float r, b, g, t = 0;
float freq = .001;
float amp_shift = 0;
float amplitude = 255/4;
float r_phase = random(2*3.1415);
float g_phase = random(2*3.1415);
float b_phase = random(2*3.1415);

void setup() {
  size(size_scale, size_scale);
  square = new RandSquare[squares];
  for(int i = 0; i < squares; i++) {
    square[i] = new RandSquare(color(random(255), random(255), random(255), random(255)), random(width), random(height), random(-speed, speed), random(-speed, speed), random(len_min, len_max));
  }
}

void draw() {
  bgshift();
  background(r, b, g);
  for(int i = 0; i < squares; i++) {
    square[i].move();
    square[i].display();
  }
}

void bgshift() {
  t += freq;
  if(t % (2 * 3.141) == 0) {
    t = 0;
  }
  r = amplitude * sin(t*r_phase) + amp_shift;
  b = amplitude * sin(t*b_phase) + amp_shift;
  g = amplitude * sin(t*g_phase) + amp_shift;
}

class RandSquare {
  color c;
  float xpos;
  float ypos;
  float xspeed;
  float yspeed;
  float len;
 
  RandSquare(color c_, float xpos_, float ypos_, float xspeed_, float yspeed_, float len_) {
    c = c_;
    xpos = xpos_;
    ypos = ypos_;
    xspeed = xspeed_;
    yspeed = yspeed_;
    len = len_;
  }
 
  void display() {
    noStroke();
    fill(c);
    rectMode(CENTER);
    rect(xpos, ypos, len, len);
  }
 
  void move() {
    xpos = xpos + xspeed;
    ypos = ypos + yspeed;
    if((xpos > width + pos + 1) || (xpos < -pos - 1) || (ypos > height + pos + 1) || (ypos < -pos - 1)) {
      reset();
    }
  }
 
  void reset() {
    int coin = int(random(4));
      c = color(random(255), random(255), random(255), random(127,245));
      len = random(len_min, len_max);
      if (coin == 0) {
        xpos = width + pos;
        ypos = random(-pos, height + pos);
        xspeed = random(-speed,0);
        yspeed = random(-speed,speed);
      }
      else if (coin == 1) {
        xpos = -pos;
        ypos = random(-pos, height + pos);
        xspeed = random(0,speed);
        yspeed = random(-speed,speed);
      }
      else if (coin == 2) {
        xpos = random(-pos, width + pos);
        ypos = height + pos;
        xspeed = random(-speed,speed);
        yspeed = random(-speed,0);
      }
      else {
        xpos = random(-pos, width + pos);
        ypos = -pos;
        xspeed = random(-speed,speed);
        yspeed = random(0,speed);
      }
  }
}

Name: Anonymous 2010-01-22 22:08

rm -rf

no thanks

Name: Anonymous 2010-01-23 9:56

>>2

Just delete everything that is below your level? HIGH AND MIGHTY /prog/ doesn't understand that which is love, and thus does not know when it receives it.

shred -f your_anus

Name: Anonymous 2010-01-23 10:00

>>1
use damn [code] next time.

Name: Anonymous 2010-01-23 10:02

Hey OP, you should use code tags as well as provide a screenshot next time. I can imagine most /prog/rammers don't use processing and you would have to persuade them to get it.

Name: Anonymous 2010-01-23 14:36

>>5
Let me fix this for you:
>I can imagine most /prog/rammers don't use processing and you would have to persuade them to get it.
I can imagine most /prog/rammers don't use processing and you would have to point at them with an AK 47 to get it.

Name: Anonymous 2010-01-23 15:11

>>5-6
What?  Processing is sweet, you guys are missing out.

Name: Anonymous 2010-01-23 15:15

>>7
processing is a slow piece of shit collection of Java wrapper functions

that's right, a JAVA WRAPPER.

the thought is enough to piss me off, but i have to be fair.  it is very nice for the prototyping of interactive multimedia, which is after all its main purpose for being.

Name: 5 2010-01-23 15:21

>>7
I just said "don't use processing", not that it's bad. I've yet to experiment with it myself, but might just do that someday.

Name: Anonymous 2010-01-23 15:27

Look at how I write /prog/
Haha!

Name: Anonymous 2010-01-23 15:45

>>10
faggot

Don't change these.
Name: Email:
Entire Thread Thread List