From 7601e5f8f847a3dcb76ac0fea4b31ca92a163441 Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Mon, 5 Feb 2024 22:52:02 +0200 Subject: [PATCH] complete exercise 0.9 --- 0. Randomness/9. Perlin animated/index.html | 15 +++++++++++ 0. Randomness/9. Perlin animated/sketch.js | 30 +++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 0. Randomness/9. Perlin animated/index.html create mode 100644 0. Randomness/9. Perlin animated/sketch.js diff --git a/0. Randomness/9. Perlin animated/index.html b/0. Randomness/9. Perlin animated/index.html new file mode 100644 index 0000000..c390616 --- /dev/null +++ b/0. Randomness/9. Perlin animated/index.html @@ -0,0 +1,15 @@ + + + + + + + +
+
+ + diff --git a/0. Randomness/9. Perlin animated/sketch.js b/0. Randomness/9. Perlin animated/sketch.js new file mode 100644 index 0000000..be137b4 --- /dev/null +++ b/0. Randomness/9. Perlin animated/sketch.js @@ -0,0 +1,30 @@ +let increment = 0.01 +let octaves = 8 +let falloff = 0.4 + +let t = 0 +let animationSpeed = 0.0005 + +function setup() { + createCanvas(640, 240) + pixelDensity(1) + noiseDetail(octaves, falloff) +} + +function draw() { + loadPixels() + for (let x = 0; x < width; x++) { + for (let y = 0; y < height; y++) { + let index = (x + y * width) * 4 + + let noiseValue = noise(x*increment, y*increment, t*animationSpeed) + let bright = map(noiseValue, 0, 1, 0, 255) + pixels[index+0] = bright + pixels[index+1] = bright + pixels[index+2] = bright + pixels[index+3] = 255 + } + } + updatePixels() + t += deltaTime +}