From ba0dec0bb482115beaaaa0e00c3d51e3820f977e Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Wed, 7 Feb 2024 00:09:18 +0200 Subject: [PATCH] complete exercise 1.2 --- 1. Vectors/2. Perlin Walker/index.html | 15 ++++++++++++ 1. Vectors/2. Perlin Walker/sketch.js | 32 ++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 1. Vectors/2. Perlin Walker/index.html create mode 100644 1. Vectors/2. Perlin Walker/sketch.js diff --git a/1. Vectors/2. Perlin Walker/index.html b/1. Vectors/2. Perlin Walker/index.html new file mode 100644 index 0000000..c390616 --- /dev/null +++ b/1. Vectors/2. Perlin Walker/index.html @@ -0,0 +1,15 @@ + + + + + + + +
+
+ + diff --git a/1. Vectors/2. Perlin Walker/sketch.js b/1. Vectors/2. Perlin Walker/sketch.js new file mode 100644 index 0000000..b4a70bc --- /dev/null +++ b/1. Vectors/2. Perlin Walker/sketch.js @@ -0,0 +1,32 @@ +class Walker { + constructor(x = 0, y = 0) { + this.t = createVector(0, 10000) + this.pos = createVector(x, y) + } + + step() { + let dx = map(noise(this.t.x), 0, 1, -1, 1) + let dy = map(noise(this.t.y), 0, 1, -1, 1) + + this.pos.add(createVector(dx, dy)) + this.t.add(createVector(0.01, 0.01)) + } + + draw() { + stroke(0) + point(this.pos) + } +} + +let walker + +function setup() { + createCanvas(640, 240) + background(255) + walker = new Walker(320, 120) +} + +function draw() { + walker.step(); + walker.draw(); +}