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

Commit 7f133e7

Browse files
committed
Noise 2D added(initially absent)
1 parent 1c52b17 commit 7f133e7

File tree

5 files changed

+46
-2
lines changed

5 files changed

+46
-2
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<head>
2+
<script language="javascript" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.7/p5.js"></script>
3+
<script language="javascript" type="text/javascript" src="sketch.js"></script>
4+
<title>Noise 2D</title>
5+
</head>
6+
7+
<body>
8+
</body>
58.7 KB
Loading

chp00_introduction/Noise 2D/sketch.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
// The Nature of Code
3+
// Daniel Shiffman
4+
// http://natureofcode.com
5+
6+
7+
function setup() {
8+
9+
createCanvas(640,360);
10+
background(150);
11+
12+
}
13+
14+
function draw() {
15+
16+
loadPixels(); //tell p5 we will work with pixels
17+
var xoff = 0.0;
18+
19+
//getting individual pixels on canvas and updating them with perlins noise
20+
for(var x = 0; x < width; x++){
21+
22+
var yoff = 0.0;
23+
24+
for(var y = 0; y < height; y++){
25+
26+
var bright = map(noise(xoff,yoff),0,1,0,255);
27+
set(x, y ,floor(bright)); //setting pixel color to bright
28+
yoff += 0.01; //incrementing y-offset perlins noise
29+
30+
}
31+
xoff += 0.01; //incrementing x-offset perlins noise
32+
33+
}
34+
35+
updatePixels();//update pixels on canvas
36+
37+
}

chp00_introduction/Noise1D/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<head>
22
<script language="javascript" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.7/p5.js"></script>
3-
<script language="javascript" type="text/javascript" src="noise.js"></script>
43
<script language="javascript" type="text/javascript" src="sketch.js"></script>
54
<title>Noise 1D</title>
65
</head>

chp00_introduction/Noise1D/sketch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ function draw() {
3131
fill(200);
3232
ellipse(x,height/2, 64, 64);
3333

34-
print(n);
34+
3535
}

0 commit comments

Comments
 (0)