diff --git a/0. Randomness/7. Perlin Walker/index.html b/0. Randomness/7. Perlin Walker/index.html new file mode 100644 index 0000000..c390616 --- /dev/null +++ b/0. Randomness/7. Perlin Walker/index.html @@ -0,0 +1,15 @@ + + + + + + + +
+
+ + diff --git a/0. Randomness/7. Perlin Walker/sketch.js b/0. Randomness/7. Perlin Walker/sketch.js new file mode 100644 index 0000000..d73c9b4 --- /dev/null +++ b/0. Randomness/7. Perlin Walker/sketch.js @@ -0,0 +1,37 @@ +class Walker { + constructor(x = 0, y = 0) { + this.tx = 0 + this.ty = 10000 + this.x = x + this.y = y + } + + step() { + let dx = map(noise(this.tx), 0, 1, -1, 1) + let dy = map(noise(this.ty), 0, 1, -1, 1) + + this.x += dx + this.y += dy + + this.tx += 0.01 + this.ty += 0.01 + } + + draw() { + stroke(0) + point(this.x, this.y) + } +} + +let walker + +function setup() { + createCanvas(640, 240) + background(255) + walker = new Walker(320, 120) +} + +function draw() { + walker.step(); + walker.draw(); +}