mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
removing old nature of code examples before adding new ones
This commit is contained in:
-39
@@ -1,39 +0,0 @@
|
||||
// Daniel Shiffman
|
||||
// The Nature of Code
|
||||
// ITP, Spring 2006
|
||||
// http://www.shiffman.net/
|
||||
|
||||
int x,y;
|
||||
|
||||
void setup() {
|
||||
size(200,200);
|
||||
background(0);
|
||||
smooth();
|
||||
}
|
||||
|
||||
void draw() {
|
||||
//create an alpha blended background
|
||||
fill(0,1);
|
||||
rect(0,0,width,height);
|
||||
|
||||
//probabilities for 3 different cases (these need to add up to 100% since something always occurs here!)
|
||||
float p1 = 0.05; // 5% chance of pure white occurring
|
||||
float p2 = 0.80 + p1; // 80% chance of gray occuring
|
||||
//float p3 = 1.0 - p2 ; // 15% chance of black (we don't actually need this line since it is
|
||||
// by definit n, the "in all other cases" part of our else
|
||||
float num = random(1); // pick a random number between 0 and 1
|
||||
if (num <p1) {
|
||||
fill(255);
|
||||
} else if (num < p2) {
|
||||
fill(150);
|
||||
} else {
|
||||
fill(0);
|
||||
}
|
||||
|
||||
stroke(200);
|
||||
rect(x,y,10,10);
|
||||
|
||||
// X and Y walk through a grid
|
||||
x = (x + 10) % width;
|
||||
if (x == 0) y = (y + 10) % width;
|
||||
}
|
||||
Reference in New Issue
Block a user