Skip to content
This repository was archived by the owner on Sep 22, 2024. It is now read-only.

Commit 0c5788a

Browse files
authored
Merge pull request #120 from 201flaviosilva-labs/master
Add Graphing 1D Perlin Noise
2 parents 1f4ef51 + 4e6e00e commit 0c5788a

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.1/p5.min.js"></script>
6+
<meta charset="utf-8" />
7+
</head>
8+
9+
<body>
10+
<script src="sketch.js"></script>
11+
</body>
12+
13+
</html>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// The Nature of Code
2+
// Daniel Shiffman
3+
// http://natureofcode.com
4+
5+
let startX = 0;
6+
7+
function setup() {
8+
createCanvas(800, 600);
9+
stroke(255);
10+
noFill();
11+
}
12+
13+
function draw() {
14+
background(150);
15+
16+
const addingX = map(mouseY, 0, height, 0.01, 0.1);
17+
const detail = map(mouseX, 0, width, 0, 32);
18+
let xOff = startX;
19+
20+
noiseDetail(detail);
21+
22+
beginShape();
23+
for (let i = 0; i < width; i++) {
24+
vertex(i, noise(xOff) * height);
25+
xOff += 0.01;
26+
}
27+
endShape();
28+
29+
startX += addingX;
30+
}

0 commit comments

Comments
 (0)