Skip to content

Processing Pixel Swarm

by Colin on June 1st, 2009



This version of pixel swarm attracts pixels based off the distance (Pythagorean Theorem) between the points and the mouse.  I've added gravity and dampening to it so that the pixels bounce around the mouse movement.

pixelSwarm2_2pixelSwarm2_3
In this version of Pixel Swarm I reversed the velocity of the pixels so that instead of adding it's current position to where the mouse was, I subtracted it, giving it this magnifying feeling.  I also removed the gravity field so that it's more bouncey and animated.  Both versions of the Pixel Swarm in processing display 2,500 movable pixels.  The first displaying in a grid and the second using the Logarithmic Sprial.  I also changed how the pixels were written.  The first was displayed through drawing a rectangle:

noStroke ();
fill (#FFFFFF);
rect (sx, sy, 1, 1);

The second written:

point (sx, sy);

Processing handles drawing points a lot faster than drawing rectangles. The downside to this is that you can't (as far as I know) change the color of the points in processing.
Last, but not least, I added a rectangle under each iteration of the draw function. This gave me control so that the previous point coordinates would echo and visually fade the other pixels out.

From → Processing

No comments yet

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS