Random.

Random.

Random numbers create the basis of this image. Each time the program is loaded the result is different.


void setup() {
  size(640, 360);
  background(0);
  strokeWeight(20);
  frameRate(2);
}

void draw() {
  for (int i = 0; i < width; i++) {
    float r = random(255);
    stroke(r);
    line(i, 0, i, height);
  }
}

Functions Used

stroke()

Sets the color used to draw lines and borders around shapes

Learn More
size()

Defines the dimension of the display window width and height in units of pixels

Learn More
setup()

The setup() function is run once, when the program starts

Learn More
strokeWeight()

Sets the width of the stroke used for lines, points, and the border around shapes

Learn More
frameRate

The system variable frameRate contains the approximate frame rate of a running sketch

Learn More
random()

Generates random numbers

Learn More
draw()

Called directly after setup(), the draw() function continuously executes the lines of code contained inside its block until the program is stopped or noLoop() is called

Learn More
line()

Draws a line (a direct path between two points) to the screen

Learn More
background()

The background() function sets the color used for the background of the Processing window

Learn More