Created
July 5, 2021 17:30
-
-
Save mattdesl/516f4c1197e2db71a5a729b095b5fcd4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A 2D polyline of samples along a flow field | |
let path = [ penStart ]; | |
let [ x, y ] = penStart; | |
for (let i = 0; i < steps; i++) { | |
// Get new angle of rotation | |
const angle = noise(x, y) * angleAmplitude; | |
// Offset the point by this angle | |
x += Math.cos(angle) * stepSize; | |
y += Math.sin(angle) * stepSize; | |
// Add the new sample | |
path.push([ x, y ]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment