diff --git a/0. Randomness/10. Perlin elevated/index.html b/0. Randomness/10. Perlin elevated/index.html new file mode 100644 index 0000000..c390616 --- /dev/null +++ b/0. Randomness/10. Perlin elevated/index.html @@ -0,0 +1,15 @@ + + + + + + + +
+
+ + diff --git a/0. Randomness/10. Perlin elevated/sketch.js b/0. Randomness/10. Perlin elevated/sketch.js new file mode 100644 index 0000000..ba936ea --- /dev/null +++ b/0. Randomness/10. Perlin elevated/sketch.js @@ -0,0 +1,43 @@ +let t = 0 +let animationSpeed = 0.0008 + +function setup() { + createCanvas(640, 240, WEBGL) + pixelDensity(1) +} + +function draw() { + background(255); + + let pointsX = 20 + let pointsY = 40 + let pointGap = 10 + + let zs = [] + for (let y = 0; y < pointsY+1; y++) { + for (let x = 0; x < pointsX; x++) { + let increment = 0.1 + zs.push(noise(x*increment, y*increment, t*animationSpeed)) + } + } + + push() + rotateX(PI/3) + rotateZ(0.0001*t) + scale(pointGap) + translate(-pointsX/2, -pointsY/2, 0) + + for (let y = 0; y < pointsY; y++) { + beginShape(QUAD_STRIP) + for (let x = 0; x < pointsX; x++) { + fill(zs[x + y * pointsX] * 255, 255) + vertex(x, y, zs[x + y * pointsX] * 10) + vertex(x, y+1, zs[x + (y+1) * pointsX] * 10) + } + endShape() + } + + pop() + + t += deltaTime +}