| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff 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 | + | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments