/* CSC480RandomVsPerlinNoise, D. Parson, April 2020 */ // See http://faculty.kutztown.edu/parson/fall2013/distributions.pdf size(1000,700,P2D); background(0); ellipseMode(CENTER); rectMode(CENTER); strokeWeight(2); //randomSeed(12345); //noiseSeed(42); stroke(0,0,255); // blue for random() fill(0,0,255); int lastx = -1, lasty = -1 ; // https://processing.org/reference/random_.html // https://processing.org/reference/randomSeed_.html // for (int x = 0 ; x < width ; x++) { float y = random(height/4.0, 3*height/4.0); // ellipse(x, y, 2, 2); if (lastx > -1 && lasty > -1) { line(lastx, lasty, x, y); } lastx = x ; lasty = int(y) ; } // https://processing.org/reference/randomGaussian_.html // " Returns a float from a random series of numbers // having a mean of 0 and standard deviation of 1." stroke(172,0,0); // red for randomGaussian() fill(172,0,0); lastx = lasty = -1 ; for (int x = 0 ; x < width ; x++) { float y = (randomGaussian()*height*0.078125+height*0.5); // height*0.25,height*0.75); // rect(x, y, 2, 2); if (lastx > -1 && lasty > -1) { line(lastx, lasty, x, y); } lastx = x ; lasty = int(y) ; } stroke(0,255,255); // cyan for noise() fill(0,255,255); lastx = lasty = -1 ; // https://processing.org/reference/noise_.html // "The resulting value will always be between 0.0 and 1.0." // https://processing.org/reference/noiseSeed_.html // https://processing.org/reference/noiseDetail_.html for (int x = 0 ; x < width ; x++) { float y = noise(x/40.0)*height*0.5+height*0.25; // rect(x, y, 2, 2); if (lastx > -1 && lasty > -1) { line(lastx, lasty, x, y); } lastx = x ; lasty = int(y) ; }