Skip to content

Instantly share code, notes, and snippets.

@mattdesl
Created July 5, 2021 17:30
Embed
What would you like to do?
// 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