Created
March 14, 2012 17:39
-
-
Save yoamomonstruos/2038133 to your computer and use it in GitHub Desktop.
Drawing random numbers like robot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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