Different every time!
Log in to post a comment.
Canvas.setpenopacity(.2)
particles = []
for (i = 0; i < 100; i++) {
particles.push(
{
turtle: new Turtle(),
speed:Math.random() * 2 - 1,
angle:Math.random() * 2 - 1
})
}
function walk(i) {
mean = [0, 0]
for (particle of particles) {
turtle = particle.turtle
lerpedPos = lerp2D(turtle.position(), mean, 0.2)
turtle.goto(lerpedPos)
turtle.forward(particle.speed)
turtle.right(particle.angle)
mean[0] = mean[0]+turtle.position()[0]
mean[1] = mean[1]+turtle.position()[1]
}
mean[0] /= particles.length
mean[1] /= particles.length
return i < 2000
}
function lerp2D(a, b, amount) {
newPos = []
newPos[0] = a[0] * (1 - amount) + b[0] * amount
newPos[1] = a[1] * (1 - amount) + b[1] * amount
return newPos
}