twice two . com

Optipusitcs applet

This browser does not have a Java Plug-in.
Get the latest Java Plug-in here.

(Click and drag with the mouse to draw, hit space to toggle the control panel.)

"Optipustics" is a clever hack invented by Dan Ritchie in his "PD Pro" paint program (and now in the standalone PD Particles). Basically, you "draw" particles with the mouse. After being created, particles move on their own, each having its own velocity. You can setup particles to respond to gravity or wind, split into child particles occasionally, follow the mouse, etc. Each particle traces a trail as it moves, so the result is a pretty feathery effect.

I wanted to experiment with different ways of moving the particles, so I put this applet together in Processing. Drag with the left mouse button to draw particles; the right mouse button clears the drawing area. The space bar toggles the "control panel" where you can edit the parameters, 'c' clears the canvas to the "starting color", 'x' is the panic button that kills all active particles, and the number keys 0-9 load different particle behavior presets.

Notes on the parameters:

  • "Wind" is a constant linear acceleration, added to every particle, every frame.
  • Every particle has a velocity, which implies that every particle has a heading (also a speed, but we don't use that, yet). Every particle also has an angular velocity, which is added to the heading every frame. (Heading is called "angle" in the parameters.)
  • Any one of these attributes (velocity x, velocity y, current heading, angular velocity) and a few others can be "jitter" randomly. Jittering adds a random value (on the range [-jitter, +jitter]) to the attribute. However, jittering need not be performed every frame. How often jittering is performed is determined by two parameters, the frequency and the probability.
    • The frequency determines how often, in frames, the probability test is performed. E.g., if the frequency is 10 then the probability test is performed every ten frames.
    • The probability determines the chance of jittering happening, from 0 (never) to 1 (always).
  • Branch probability and frequency determine how often branching occurs. Min/max branches determine how many branches are created. Branch spread determines the 1/2 the spread of the created branches, in radians. Branch position spread determines how far individual branches will randomly deviate from their original, perfectly-spaced, positions.
  • "Follow mouse" adds a vector (scaled by this parameter), pointing to the mouse cursor, on every frame.
  • Mouse inertia determines how much the starting directions of the particles are influenced by the mouse motion at that point.
  • Starting/ending color should be obvious. Note that pressing 'c' will clear the canvas to the starting color.
  • Min/max particles determines how many particles are randomly created at each point along the mouse trail.
  • Min/max life determines how long each particle will live, with each particle's lifespan being randomly selected from this range.

Problems and notes:

  • It is easy (particularly by messing with branching) to create too many particles and overload the system. If this happens, you can press 'x' to kill all the particles. However, it may take a while for your keypress to get through, so you might be better off closing your browser.
  • The branching code is wacky; it works, but I'm not sure why.
  • The anti-aliased pixel drawing code is borrowed from one of Glen Murphy's pieces over at Bodytag.org.

Download Processing source