FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

adding a new example for randomGaussian · ranlevinstein/processing@025b353 · GitHub

Repository navigation

Commit 025b353

Browse files
committed
adding a new example for randomGaussian
1 parent 917eb9d commit 025b353

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* Random Gaussian.
3+
*
4+
* This sketch draws ellipses with x and y locations tied to a gaussian distribution of random numbers.
5+
*/
6+
7+
void setup() {
8+
size(640, 360);
9+
background(0);
10+
}
11+
12+
void draw() {
13+
14+
// Get a gaussian random number w/ mean of 0 and standard deviation of 1.0
15+
float val = randomGaussian();
16+
17+
float sd = 60; // Define a standard deviation
18+
float mean = width/2; // Define a mean value (middle of the screen along the x-axis)
19+
float x = ( val * sd ) + mean; // Scale the gaussian random number by standard deviation and mean
20+
21+
noStroke();
22+
fill(255, 10);
23+
noStroke();
24+
ellipse(x, height/2, 32, 32); // Draw an ellipse at our "normal" random location
25+
}
26+
27+
28+

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL