Processing Makes Its First Appearance

I’m going to meet with my own class today, FA3800 Generative Art with Processing. (I wore one of my Processing shirts for the occasion.) But I also thought it would be nice to include a little bit of Processing right here. I just ran this code and looked for a pretty frame (as it changes constantly):

// Create variables for the attributes I want to randomize.
float r;                           // For the red component of the line color.
float g;                           // For the green component of the line color.
float b;                           // For the blue component of the line color.
float a;                           // For the alpha (transparency) component of the line color.
float topX;                        // For the X dimension of the top of the line.
float bottomX;                     // For the X dimension of the bottom of the line.

void setup() {
  size(300, 150);                  // Create a screen 960 pixels wide and 320 pixels tall.
  background(0, 64, 32);           // Puts in a dark green background.
}

void draw() {
  r = random(0, 64);               // Randomizes the red component with low values.
  g = random(64, 255);             // Randomizes the green component with mid to high values.
  b = random(32, 128);             // Randomizes the red component with mid values.
  a = random(0, 200);              // Randomizes the alpha component with low to highish values.
  strokeWeight(20);                // Make the lines 20 pixels wide.
  stroke(r, g, b, a);              // Inserts the variables in the color definition.
  topX = random(0, width);         // Gets a random X coordinate for the top of each line.
  bottomX = random(0, width);      // Gets a random X coordinate for the bottom of each line.
  line(topX, 0, bottomX, height);  // Draws each line from top to bottom with the random Xs.
}

Then I just ran it and waited for an opportune moment to take a screenshot. Here’s the result:

Fun!

Advertisements
Tagged , , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: