NAME

FigAnim - A XFig file animator class

SYNOPSIS

Here is a simple example where we first parse a file "file.fig". This file is supposed to contain an object named "Square" (in XFig the name of an object is it's commentary). Then this object translates according to vector (50px, 25px), the animation starts at t=0 second and it's duration is 1 second. In the end we generate an animated GIF file named "anim.gif", and a SVG+SMIL file named "anim.svg".

use FigAnim;

$fig_anim = new FigAnim;
$fig_anim->parseFile("file.fig");

$fig_anim->{objects}->{Square}->translate(0, 1, 50, 25, 'px');

$fig_anim->generateGif("anim.gif", 12, 0);
$fig_anim->generateSMIL("anim.svg");

ABSTRACT

FigAnim is a package which takes an existing FIG file (made by the XFig vector drawing program for example) and generates animations in animated GIF format and/or in SVG+SMIL format.

DESCRIPTION

Here are all the methods you can use in the package FigAnim :

new(), parseFile(), writeFile(), setAttributevalue(), setPenColor(), setFillColor(), hide(), show(), changeThickness(), changeFillIntensity(), scale(), translate(), rotate(), generateGIF(), writeSVGfile(), generateSMIL(), selectByType(), selectByPenColor(), selectByFillColor(), selectByAttributeValue()

The time unit used for every animation is in seconds.

BASIC COMMANDS

new()

Creates a new instance of the class FigAnim. Every animation must begin with these two lines:

use FigAnim;
$fig_anim = new FigAnim;
parseFile()

Parses the file given in parameter, for example:

$fig_anim->parseFile("file.fig");

where "file.fig" is a correct FIG file.

writeFile()

Writes a new FIG file from another parsed FIG file. This method is only used for testing purpose (to test the identity). Example:

$fig_anim->writeFile("another_file.fig");

SET

setAttributeValue()

This method sets an attribute value of an object at a given time, without any interpolation. For example, if we have in our FIG file an object named "Square":

$fig_anim->{objects}->{Square}->setAttributeValue(3, 'thickness', 2);

sets the attribute "thickness" of object "Square" to 2 at instant t=3 seconds.

setPenColor()

Example:

$fig_anim->{objects}->{Square}->setPenColor(4, 'Green4');

this command modifies the object's pen color to a color called Green4 (in XFig) at instant t=4s, without any interpolation.

setFillColor()

Example:

$fig_anim->{objects}->{Square}->setFillColor(5, 'Green4');

similar to previous method, but modifies fill color instead of pen color at t=5s.

HIDE/SHOW

hide()

Example:

$fig_anim->{objects}->{Square}->hide(3);

this command hides an object named "Square" at instant t=3s.

show()

Example:

$fig_anim->{objects}->{Square}->hide(4);

this command makes an object named "Square" appear at instant t=4s.

CHANGE

changeThickness()

Example:

$fig_anim->{objects}->{Square}->changeThickness(0, 1, 7);

animates (with linear interpolation) the thickness of an object named "Square" from time t=0s for a duration of 1s. The thickness will have a value of 7 at the end of the animation.

changeFillIntensity()

Example:

$fig_anim->{objects}->{Square}->changeFillIntensity(2, 1, 0);

animates (with linear interpolation) the fill intensity of an object named "Square" from time t=2s for a duration of 1s. The intensity will have a value of 0 at the end of the animation. The intensity must be a number between 0 (black) and 20 (full saturation of the color). In the example the object becomes darker and darker until it becomes black.

scale()

Example:

$fig_anim->{objects}->{Arc}->scale(0, 1, 1.2);

scales the object named "Arc" from time t=0s for a duration of 1s according to scale factor 1.2. The center of the scale is the center of the object.

MOVEMENTS

translate()

Example:

$fig_anim->{objects}->{Square}->translate(0, 1, 2, 3, 'in');

translates the object named "Square" from time t=0s for a duration of 1s according to vector (2in, 3in). Possible values for units (last parameter) are 'in', 'cm' or 'px'. Units are Fig units if none specified.

rotate()

Example:

$fig_anim->{objects}->{Arc}->rotate(0, 1, -330);

rotates the object named "Arc" from time t=0s for a duration of 1s according to rotation angle -330 degrees. In this case the center of the rotation is the center of the object.

$fig_anim->{objects}->{Ellipse}->rotate(0, 1, -330, 2, 3,'in');

rotates the object named "Arc" from time t=0s for a duration of 1s according to rotation angle -330 degrees. In this case the center of the rotation is point (2in, 3in). Possible values for units (last parameter) are 'in', 'cm' or 'px'. Units are Fig units if none specified.

FILE GENERATION

generateGif()

Example:

$fig_anim->generateGif("anim.gif", 10, 1);

generates an animated GIF file named "anim.gif" with 10 frames per second, with only one loop (1). If you put a higher number of frames, the animation will be smoother but will take more time to be generated and the file size will be bigger. If you put a lower number of frames, the file will be generated faster and it's size will be smaller but the animation will be less smooth.

Another example:

$fig_anim->generateGif("anim.gif", 10, 0, 1);

generates a GIF file named "anim.gif" with 10 frames per second, with infinite loop (0), and waits for 1s at the end of each loop. The last parameter is optional, if ommited its value is 0 (no waiting).

writeSVGfile()

Example: $fig_anim->writeSVGFile("file.svg");

generates a SVG file named "file.svg" from a FIG file. This is a graphic filter with no animations.

generateSMIL()

Example:

$fig_anim->generateSMIL("file.svg");

generates a SVG+SMIL file named "file.svg", it is an animated SVG file with SMIL tags. For now only the Adobe SVG plugin can display animated SVG+SMIL files.

SELECT OBJECTS

You can select objects by there type, pen color, fill color or attribute value and apply an animation to the selected object(s). Also, you can put as many parameters as you want in each select method (as you can see in Example2). You can also apply a selector on a compound object. Many selectors can be applied successively.

selectByType()

Example1:

$fig_anim->selectByType("polylines")->hide(1);

hides all objects of type polylines (as defined in XFig) at t=1s.

selectByPenColor()

Example2:

$fig_anim->selectByPenColor("Red", "Blue")->hide(1);

hides all objects with "Red" or "Blue" line (as defined in XFig) at t=1s.

selectByFillColor()

Example3:

$fig_anim->selectByFillColor("White")->hide(1);

hides all objects filled with "White" color (as defined in XFig) at t=1s.

selectByAttributeValue()

Example4:

$fig_anim->selectByAttributeValue("thickness", 1)->hide(1);

hides all objects with thickness value 1 (as defined in XFig) at t=1s.

Example5: multiple selections:

$fig_anim
->selectByPenColor("Red","Blue")
->selectByType("polylines")
->hide(1);

hides all polylines with "Red" or "Blue" line (as defined in XFig) at t=1s. =back

AVAILABLE COLORS

Background, None, Default, Black, Blue, Green, Cyan, Red, Magenta, Yellow, White, Blue4, Blue3,Blue2, LtBlue, Green4, Green3, Green2, Cyan4, Cyan3, Cyan2, Red4, Red3, Red2, Magenta4, Magenta3, Magenta2, Brown4, Brown3, Brown2, Pink4, Pink3, Pink2, Pink, Gold

SEE ALSO

FigAnim::Arc, FigAnim::Color, FigAnim::Compound, FigAnim::Ellipse, FigAnim::Polyline, FigAnim::Spline, FigAnim::Text.

AUTHOR

K. Imakita, <kzu@wanadoo.fr>; Q. Lamerand, <bret.zel@wanadoo.fr>; F. Perrin, <fred.per1@free.fr>

COPYRIGHT AND LICENSE

Copyright 2004 by K. Imakita, Q. Lamerand, F. Perrin

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 1888:

You forgot a '=back' before '=head2'