xxxxxxxxxx
42
// Based on The Nature of Code Gaussian example by Daniel Shiffman
// http://natureofcode.com
const canvasWidth = 640;
const canvasHeight = 240;
function setup() {
createCanvas(canvasWidth, canvasHeight);
background(255);
}
function draw() {
drawPerlinNoise();
drawRandom();
drawGaussian();
}
function drawPerlinNoise() {
const x = noise(0.05 * frameCount) * canvasWidth;
drawLabelAndCircle('Perlin Noise', x, 60);
}
function drawRandom() {
const x = random(0, canvasWidth);
drawLabelAndCircle('Random', x, 130);
}
function drawGaussian() {
const x = randomGaussian(canvasWidth / 2, canvasWidth / 8);
drawLabelAndCircle('Gaussian', x, 200);
}
// Helper function to draw text and a circle
function drawLabelAndCircle(label, x, y) {
noStroke();
fill(0, 10);
circle(x, y, 16);
fill(0);
noStroke();
textSize(20)
text(label, 20, y - 20);
}