Please disable AdBlock. CAN is an ad-supported site that takes hundreds of hours and thousands of dollars to sustain.

Flocking.js [Javascript]

We have a new feature javascript running on CAN:  Flocking.js by Lucas Dupin. Click top right corner button for demo.

Flocking experiment done in canvas. Each particle has it’s own set of attributes and also interacts with the group, depending on environmental variables. The flocking algorithm is based on Craig Reynolds research and is based on 3 simple rules: Separation Cohesion Attraction Uses toxiclibs for vector math and all code is commented at: http://lucasdup.in/js/bg.js The idea is a bunch of individuals which try to stay together when they feel far from a ‘safe point’ (the mouse). After finding the safe spot, they spread. This is a common behaviour that can be observed in fish and birds.

Many thanks Lucas!

http://lucasdup.in

If you’d like to submit your own, see this page for more info.

Posted on: 14/09/2011

Posted in: Javascript

Post tags:

  • http://www.tomauger.com Tom Auger

    Brilliant, but doesn’t track right (in Chrome at any rate) once you start to scroll the page. (probably reads the mouse XY coords wrong…)

  • http://www.creativeapplications.net Filip

    I’ve attached it to body tag rather than content. Kind of need another div just for these “fullscreeners”.