a question to jump to its answer.
Who made this?
I'm Jim Garretson.
I built this as MHCI coursework
under the direction of the artist formerly known
as Golan Levin. Feel
free to contact me with questions or concerns.
Why do I need this?
Well, you don't need it. The Animation object doesn't
do anything Processing couldn't already do. It simply encapsulates
all of the timestamp-tracking, counter-setting tedium required
when making simple animations, hopefully making the programmer's
life a bit easier.
My ulterior motive (I'm from here,
after all) is that this object hopefully makes it a five-minute
job to add better feedback to custom widgets. (See the examples
page for .. examples.)
How do I use this?
You'll need to download the Animation.java file and put
it in the code folder of your sketch (or source folder if you're
using Eclipse or another IDE). Detailed instructions can be found
How do I make a different motion?
There are a number of motions predefined; to get at them (or to
make your own) use the setStep() method.
Why does my Animation go outside the
rectangle on the right and bottom sides?
Because the Animation object internally calls the Processing
method, which means that the specifics of image placement are
actually being controlled by Processing's imageMode()
The most flexible way to control placement of your graphic is
Why does currentPercentage() always return
a float, which means it will always
return a decimal value between 0 and 1. (25%, for example, comes
out as 0.25). If you're storing the result of the call in an int,
Java will round to 0. Use a float instead.
Why does my custom step method throw
a null pointer exception?
If you're calling image() inside
your method, and the Animation doesn't have an image defined (if,
for example, another Animation is nested inside of it), then image()
will return null. You'll need to handle the case that image()
returns null in order for your custom step method to work as a
step method for a nested animation.
I don't want to use a BImage. How do
I set a custom draw method?
Excellent question. You can't actually pass another method to
the Animation constructor, but you can define a custom
step method. What I'd suggest you do is this:
// pass null as a BImage, so nothing is drawn.
a = new Animation(this, (BImage)null, 100,20, 200, 40);
// custom step method also does the drawing.
float myDraw(float percent)
// you can call a predefined step method, or calculate
the new position yourself.
float new_position = a.BOX(percent);
ellipse(new_position, new_position, 50, 30);
It's not the most elegant solution, but it does
keep all of the drawing encapsulated within the Animation object
and supporting functions. Most importantly, it stays out of loop().
Why has my Processing window
It may be because you've accidentally called an Animation's
methods (for example, draw() ) before the constructor has been
called. If that's not it, please drop
me a line.