Skip to content

Instantly share code, notes, and snippets.

@mattdesl
Created July 5, 2021 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattdesl/516f4c1197e2db71a5a729b095b5fcd4 to your computer and use it in GitHub Desktop.
Save mattdesl/516f4c1197e2db71a5a729b095b5fcd4 to your computer and use it in GitHub Desktop.
// 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