Monthly Archives: September 2014

Field Masking in Action

Sept23c2014Here’s an animation I made using the new AUMultiField masking call. This is an animated gif that I drew and saved one frame at a time.

I first drew a big white circle on a black background, and saved that in an AUField. That was my mask.

To draw each frame, I first drew the checkerboard full-screen and saved it in an AUField (I could have also drawn it into an offscreen PGraphics buffer). Then I cleared the screen to white, drew the outer circle, then the checkerboard with the mask, so it didn’t clobber my existing background and circle, and then finally drew the red dot on top.

New in AU Library: Field masking

maskedAUMultiFieldIn the AU Library (currently in beta – see earlier posts for download links) you can store an RGB image in an object called an AUMultiField, where you can do lots of things to do it, including drawing it on the screen.

Now you can also draw it using a mask. Create any AUField with shades of gray, and tell the library to use this as a mask when you draw your picture. Values of the mask from 0 to 1 control the opacity of the corresponding pixels, from fully transparent to fully opaque. In other words, the mask is an alpha layer, but it’s better than Processing’s built-in alpha because the values are stored in floats, giving them much more range and precision. The layer is also separate from the pixels, making it easier and faster to modify.
Continue reading

The Joy of Easy Motion Blur

A frame with and without motion blur

Motion blur on the left, no motion blur on the right

Any time I make an animation where things are moving quickly on the screen, I think about adding motion blur to my sketch. We’re used to seeing a trail behind fast-moving objects when watching film or video, and when we don’t see it the animation can feel jerky or just vaguely “wrong” (for more discussion, with examples, see Imaginary Institute Technical Note #7, “Fields and Cameras,” available here). Sometimes I’ve bothered to invest the time to write motion blur code yet again, sometimes I haven’t.

In my AU Library (now available in beta through this post), I’ve implemented a high-quality camera model that is super-easy to use (though it has lots of options for advanced users). One of its built-in features is motion blur. I wrote a little animation yesterday, and thought I’d add motion blur. I included the library and added three trivial lines, and it was done! Less than a minute of work and I had fully motion-blurred results that look great. After the break you can watch the animation with and without motion blur. Continue reading

AU Library for Processing: The Beta Release!

AUBeta-logo-226-225Huzzah! After a seemingly endless gestation period, my Processing library is ready for its beta release!

You can download the file here. Install it into your Processing setup in the usual way (that is, unzip the file and place the results into the libraries folder of your Processing installation. You can find lots of walkthroughs for this procedure online; a nice one can be found here.

The AU library (AU stands for “Andrew’s Utilities”) contains 12 distinct sections, each intended to help you write shorter, cleaner, and more bug-free programs. The sections range from very simple (a single routine to flip a coin) to very powerful (generating equally-spaced points on multi-segment curves). The library is thoroughly documented with motivation, explanations, lots of pictures, and lots of complete examples with source code.

This beta release is meant to be a shakedown cruise. I’d love to have lots of people use this and help me make it even better before I formally release it.

Follow the break for a summary of the library’s contents. Continue reading

Efficiently Finding Points on Catmull-Rom and Bezier Curves

In my AU library, I offer some utilities related to curves. Although Processing offers functions for finding points on curves, I needed to write my own implementation that was fast and efficient. Here’s an easy, elegant way to compute points on Catmull-Rom and Bezier curves, along with a discussion of an idea for making it faster. Continue reading