Animator

About Animator

Animator is a program that allows you to draw simple animated 2D vector graphics without having to know the intricate APIs of more sophisticated vector libs. You don't have to link with anything: animator reads drawing commands from its STDIN.

Optionally, Animator can describe mouse and keyboard events on its STDOUT, so interactive graphics may be made.

Animator is written in C and depends only on SDL. It can also draw using OpenGL, but GL support is optional both at compile and run time.

Animator might be useful together with software like Plumb.

Rotating rectangle demo Metaball demo Lander demo

Download

Source code is available from Subversion:

$ svn co svn://repo.hu/animator/trunk animator

i386 and amd64 Debian packages are available from the repo.hu Debian repository.

There is now a package for Arch Linux, thanks to AndreasBWagner.

Command Line

Animator takes no file arguments, input is always read from STDIN.

The following command line arguments are accepted:

Input Syntax

Input is freeform, tokens are separated by whitespace.

Text starting with the ! character is ignored until EOL.

String constants can be given without quotes if they don't collide with keywords (and they're a single word); otherwise, they should be surrounded with double quotes ". Double quotes and backslashes can be escaped with backslash. Special characters \n \t \r \b \f are supported.

General Commands

Frame Management

Transformations

Initial coordinate system is left edge to right edge -1 .. 1, bottom edge to top edge -1 .. 1. Transformation matrices are kept on a stack; the top matrix of the stack is the active one.

Drawing

Colors

Colors can be specified in multiple ways:

Areas

Areas are used for event reporting. These are named polygon boundaries, the names of which are printed when events occur within their bounds.

Having many Areas doesn't cause a slowdown when processing mouse events. However, defining and redefining Areas carries a performance penalty (comparable to rendering the corresponding polygon). Additionally, the definition penalty is repeated for all Areas when the screen is resized.

In short, moving/redefining lots of Areas often won't be particularly efficient.

Macros

Not all commands are allowed inside macro bodies; basically only drawing and matrix commands are allowed. This is the full list:

color alpha thick dash dot line arrow rect fillrect text lines poly circle fillcircle push pop mult rotate scale shift ident invoke area delarea

Empty macro bodies are not allowed.

Executing a macro is equivalent to executing the instructions in it. Recording a macro doesn't execute the instructions in it right away; the macro has to be invoked for that.

Macros can be redefined by recording a new macro of the same name. Macros are looked up each time they're invoked, so if a macro is redefined, its meaning will change in any other macro that invokes it.

Recursive macros will do exactly what you expect - crash animator, that is.

Event Output

When event reporting is turned on, a description of each event is written to STDOUT, one per line. Coordinates in events are written in the current coordinate system seen at the time of the last events on command.

Reported Event Types

For PRESS, RELEASE, and MOTION, the names of the Areas that contain the mouse pointer are printed, separated by spaces.

mod_mask is a bitmask integer, describing which modifier keys are currently pressed. Here's the value table:

NONE  = 0x0000,
LSHIFT= 0x0001,
RSHIFT= 0x0002,
LCTRL = 0x0040,
RCTRL = 0x0080,
LALT  = 0x0100,
RALT  = 0x0200,
LMETA = 0x0400,
RMETA = 0x0800,
NUM   = 0x1000,
CAPS  = 0x2000,
MODE  = 0x4000

unicode is an integer: the unicode character the current keypress represents (might be 0 if no character can be associated)

keyname is the name of the pressed key, as reported by SDL_GetKeyName. A list may be seen here (the Common name column). Note that the names may contain spaces.

Author

Copyright (C) 2009-2010 Máté Nagy <mnagy AT port70.net>

Animator is licensed under the GNU General Public License Version 2 (available in the file COPYING) or any later version.

Home page: http://repo.hu/projects/animator