JTraffic Screensaver

[A: ]

[A: <AnimationRules>,<#><PictureName>,<TargetX>, <TargetY>,<FrameWidth>, <FrameHeight>, <SourceX>, <SourceY>, <Time>, <NumberOfFrames>, <StepX>, <StepY> ]

[A: <AnimationRules>, <PictureName>, <TargetX>, <TargetY> ]

[AT: <AnimationRules>,<#><PictureName>,<TargetX>, <TargetY>,<FrameWidth>, <FrameHeight>, <SourceX>, <SourceY>, <Time>, <NumberOfFrames>, <StepX>, <StepY> ]

[AT: <AnimationRules>, <PictureName>, <TargetX>, <TargetY> ]

Animation definition

Animations depict complex behaviors and have many various parameters associated with them.

An animation is a sequence of individual pictures that are usually placed into a single, larger picture with its own Stock List entry. The images are shown in sequence and the resulting sequential display of creates the illusion of motion.  Rules determine in what sequence the pictures are displayed and how fast the sequence is displayed.  They also determine where on a vehicle or foreground or background picture the animation is placed.  The parameter <AnimationRules> describe the direction, eventually the sequence these phase pictures will be copied on the vehicle or background/foreground element.

The individual pictures comprising each part of the motion in the animation which are customarily arranged in sequence inside a single picture.  This source picture consequently shows each position of the motion from start to finish.  Therefore, the source picture is usually have a width equal to <FrameWidth> * <NumberOfFrames> - each phase picture has it's own area, and the phase pictures are near each other.  In most cases the parameters <SourceX> and <SourceY> have the value 0, because the first portion of the animation is usually found in the leftmost corner.   <StepX> is equal to <FrameWidth> and <StepY> is customarily zero because the individual pictures usually stay near each other in the source picture.  There are, however, other possible ways to use the animation commands.  One can draw the phases of the animation in one picture appearing vertically rather than horizontally or one can even use specific portions of an animation picture as individual pictures.

Imagine if you will a sliding door which opens upward to reveal a homogeneous colour behind it (a dark colour perhaps, to represent the depths of a vehicle or building):  in this case it is sufficient to draw only the door and underneath it, a picture of the opening revealed when the door slides open.  The first stage (or "phase") of the animation depicts the door closed.  The next shows the same picture one pixel below the first: one can see the first row of bits of the "inside" and as the animation progresses the original picture is shifted up each phase by one pixel, creating the illusion that the door is moving.  In this case, one would use the following parameters:

<SourceX> = 0
<SourceY> = <NumberOfFrames> - 1
<StepX> = 0
<StepY> = -1

This part, the geometric parameters, describes the location of the phase pictures - they define a set of phase pictures numbered from 0 to <NumberOfFrames> - 1.  The following, the <AnimationRules>  determines how, in which sequence these individual component pictures are displayed during the animation.

Going back to the example we used at the beginning of this section, the short form of the animation [A: ] can be used when the remaining information required can be found in the macro attached to the picture <PictureName> in its Stock List entry.  If this is the case, the picture <PictureName> will have the following parameters defined in its Stock List entry modifier:

[ANIM: <AnimationRules>, <FrameWidth>, <FrameHeight>, <SourceX>, <SourceY>, <%Time%>, <NumberOfFrames>, <StepX>, <StepY> ]

In order to be implemented, the only thing that is then required is to specify the coordinate values of where the animation is to be placed and to specify the name of the animation being placed.  When <EventName> is a single name and not a complex definition, the macro for the individual pictures can be described even more succinctly:

[ <EventName>: <FrameWidth>, <FrameHeight>, <SourceX>, <SourceY>, <%Time%>, <NumberOfFrames>, <StepX>, <StepY> ]

Let's see the parameters individually:

<PictureName> Picture composed of the individual pictures that make up the animation,  A name without slashes or periods defines a picture from the Stock List.  If a picture is called which is outside of the Stock List, it cannot be referenced with the short form of the command [A: ] as this command requires that the picture have macros associated with it which can only be attached to pictures in the Stock List. If a # precedes the picture name, it means, that the picture will be mirrored before using it.
<TargetX>, <TargetY> The coordinates where the animation appears in the picture. The <TargetX> and <TargetY> parameter do not have any default value.
<FrameWidth>, <FrameHeight> The width and height measurements of the individual pictures comprising the animation (so called "frames") which is also the amount of space which will be covered with the animation if it is overlaid on another picture.  The individual frames of the animation must all be equally sized, regardless if the portion of the animation which depicts motion takes up the entire individual frame or not.  Therefore, the frame width and height for each individual frame must be as high as the highest portion of the motion and as wide as the widest portion of the motion.  For example, if you have an animation of a pantograph, the height of every frame in the animation must be as high as the highest position of the pantograph in its raised state and the width of the frame must be set to the widest width of the pantograph in its lowered state. The <FrameWidth>> parameters default value is the width of the animation picture, the default value for the <FrameHeight> parameter is the height of the animation picture - so, if the phase pictures are placed near each other, you can omit the <FrameHeight> parameter, if they are above/below each other, you can omit the <FrameWidth> parameter.
<SourceX>, <SourceY> The coordinates of the lower left corner of the first frame of the animation inside the animation picture <PictureName>, which contains all of the animation frames. The defeault value for both the <SourceX> and <SourceY> parameters are 0 - so, in the usual case having the phase pictures near each other, beginning from left, the you can omit both of this parameters.
<Time> Time between the depiction of the individual frames in 10ms intervals. You can override this interval time for specific steps, if you use the program format of the <AnimationRules> parameter - see it there. The default value for the <Time> Parameter is 15 (meaining 150 ms)
<NumberOfFrames> Number of individual frames comprising the animation. The default value for this parameter is a guess based on the size of the <PictureName> picture and the <FrameWidth>, <FrameHeight> parameters. If the phase pictures are placed near or above each other without overlapping, Traffic's guess is correct - you can omit this parameter.
<StepX>, <StepY> The distance in pixel of the frames from each other (to the right and up when positive values, to the left and down when negative values).  These two parameters enable one to use a particular part of an animation multiple times (see the door example above). The default values for these parameter are Traffic's guesses base on the size of the <PictureName> picture, the <FrameWidth>, <FrameHeight> and <NumberOfFrames> parameters. Once more, in the simple cases - no extra unused place in the animation picture - Traffic's guess is correct, you can omit this parameter.

The [AT: ] modifier behaves similarly as the [A: ] modifier. The only difference: the phase pictures of the [AT: ] modifier will be placed before the base picture the modifier acts, the [A: ] modifier places the phase pictures instead of the part of the base picture - so, you can look through the transparent pixels of the [AT: ] modifier's picture to the base picture, in contrary, the phase pictures of the [A: ] modifier should contain the pixels of the base picture too, if inside the target square there are parts viewable from the base picture.

Animations are not allowed to overlap each other. If they overlap, the result is unpredictable. Traffic usually draws the animated areas when they change, and one animation does not take into account the state of the other animation. This rule is valid also inside of a background or a foreground picture - even, if the modifier itself was attahed to a different element. The only case, when animations can be placed to the same coordinates, if they are on different layers of a $SCENE construct.

Animations can be triggered when a vehicle is at rest or when it passes predetermined waypoints.  They can also continue to run as the vehicle also begins moving or continues to move, respectively. Animations can be placed not only on vehicles, but on foreground or background elements too. For starting the animations, see the syntax element <WaitTime> and the chapter Actions.

The Configuration Window
Program Window
Stock List
Description Editor
Graphic Testpad
Timetable Editor
Timetable Syntax and Semanics
The timetable header
Sections, Groups, Lines, Scenes
Stock List File