Particle Trails

Movement with time could create a trail. In comform, trails of particles can be created with a surprisingly simple method - just not clean the canvas on each frame. Continue from day 13’s sketch, just remove the cleaning code in the draw() method, we can have these:

Cool, but it may look a bit artificial. We can apply some rules to the particles, for example, following Anders Hoff’s article Shepherding Random Numbers. Making the initial distribution of the particles on the circumference of a circle we can have this:

Here is the code in p5.js.

The Task

  • Add the trail effect to your day 13 or day 14’s sketches.
  • Try different methods to generate and move the particles.
  • Here’s a few directions that come to my mind you can try with:
    • Use Perlin Noise we introduced on day 5 to replace the random function.
    • Implement Anders’ random shepherding method
    • Different initial distribution and velocities.
    • Apply forces or gravity to the particles.
    • Add a semitransparent layer on each frame to create the “fading trails” effect.

When you are all done, post your work on Twitter with the hashtag #codecember and #day15. Remember to include a link to the source code, so others can learn from your creation. We look forward to seeing your sketch!

Anthony & Pine