### Aside

If your books haven’t arrived yet, try this:

# Using “Random” with Processing

Below is my very rough code to create messy, random dots. It’s bloated, and you could do a lot to “bum” this code.

``````// The statements in the setup() function
// execute once when the program begins void setup() { size(600, 600);
// Size should be the first statement stroke(255);
// Set stroke color to white noLoop(); }

float y = 300; // this is the midpoint of the 600px tall sketch

// The statements in draw() are run until the
// program is stopped. Each statement is run in
// sequence and after the last line is read, the first
// line is run again.

void draw() {
// background(125); // Set the background to black (I commented this out - Steve)
float rando = random(-10,10); // choose a random number from -10 to 10
float randColorR = random(255); // Pick a value for RED from 0-255
float randColorG = random(255); // Pick a value for GREEN from 0-255
float randColorB = random(255); // Pick a value for BLUE from 0-255

noStroke();
fill(randColorR,randColorG,randColorB,5);

// fill in the RGB, and the last value is for opacity! Which I set to 5.

ellipse(width/2+rando*4,y+30+rando*60,y-rando,y-rando);
//This is just some crazy math to make the ellipse all jittery and weird. Could be much more efficient.
// and now it repeats

fill(randColorR+randColorR-50,randColorG+randColorR-125,randColorB*randColorR,5);
ellipse(width/4+rando*4,y+30+rando*60,y-rando,y-rando);

// and now it repeats - again, this could MUCH more efficient.
fill(randColorR+randColorR-50,randColorG+randColorR-125,randColorB-200,5);
ellipse(width/1.25+rando*4,y+30+rando*60,y-rando,y-rando);
// stroke(y,y/2,y/3);
// background(y-100,y*2,Y*3);
// line(10, y, width/3, y);```

y = y - 1;
if (y < 0) {
y = height;
}
}

void mousePressed()
{
loop();
}```