Skip to content

Instantly share code, notes, and snippets.

@yoamomonstruos
Created March 14, 2012 17:39
Show Gist options
  • Save yoamomonstruos/2038133 to your computer and use it in GitHub Desktop.
Save yoamomonstruos/2038133 to your computer and use it in GitHub Desktop.
Drawing random numbers like robot
void setup() {
size(600, 600);
background(255, 255, 255);
frameRate(10);
}
void draw() {
// Random Colour Generator
float r = random(0, 255);
float g = random(0, 255);
float b = random(0, 255);
// Random Stroke
stroke(r, g, b);
// Create a random number between 1-9
float n = random(1,2);
drawLetter(n);
}
void drawLetter(int n) {
switch(n)
{
case 1:
float x = random(290, 310);
line(x, 300, x, random(0, 300));
line(x, 300, x, random(300, 600));
break;
case 2:
float bY = random(570, 590);
float lX = random(10, 30);
float tX = random(570, 590);
float mY = random(290, 310);
line(590, bY, 10, bY);
line(lX, 300, lX, 590);
line(10, mY, 590, 300);
line(tX, 10, tX, 300);
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment