Andrew Trice
Real-World Rich Internet Applications
Monday April 02, 2007
(Flex && DisplacementMapFilter && WebCam) == (Tons O' Fun!)
I threw this experiment together out of pure boredom while traveling... and what a great idea that was. :) I have spent way too much time sitting here making funny pictures using my webcam and the DisplacementMapFilter object. You can make people look fat, look thin, look distorted... it is like a fun-house mirror through the web. Here is a preview video to start with, and then we'll get into how it works.
Or, you can interact with it here: (Requires a webcam)
Basically, There are 2 drawing modes for the application:
- Displacement Mode
- Drawing Mode
displacementBitmap = getBitmapData( paintCanvas );I also added some sliders to allow you to adjust the parameters used in the displacement. The blur parameters affect a blur filter that is on the paintCanvas. The displacement parameters allow you to adjust the amount of displacement in the X and Y directions. The color modifies the drawing color (FYI: different colors are affected more by the displacement. Read up on displacementMapFilters for a further understanding.) The thickness parameter adjusts the thickness of the line drawn on the PaintCanvas component.
var displacementMapFilter : DisplacementMapFilter =
new DisplacementMapFilter(
displacementBitmap, new Point(0,0),
2, 4, displacex.value, displacey.value,
DisplacementMapFilterMode.CLAMP );
videoContainer.filters = [ displacementMapFilter ]
There is some great information on DisplacementMapFilters here:
- DisplacementMapFilter API Refference
- Grant Skinner's WebCam Goo (with source)
- Psyark’s DisplacementMapFilter Tutorial
Enjoy!
Posted by andrewtrice | Apr 02 2007, 04:18:41 PM EDT
Permalink






