complete exercise 0.10
This commit is contained in:
parent
7601e5f8f8
commit
97c2a74712
15
0. Randomness/10. Perlin elevated/index.html
Normal file
15
0. Randomness/10. Perlin elevated/index.html
Normal file
@ -0,0 +1,15 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="https://cdn.jsdelivr.net/npm/p5@1.9.0/lib/p5.js"></script>
|
||||
<script src="sketch.js"></script>
|
||||
<style>
|
||||
body {
|
||||
background: #212121;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
43
0. Randomness/10. Perlin elevated/sketch.js
Normal file
43
0. Randomness/10. Perlin elevated/sketch.js
Normal file
@ -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
|
||||
}
|
Loading…
Reference in New Issue
Block a user