Scripts

To put a diagram on auto-pilot so it will pass through a fixed set of positions, use the .script command. It takes the following form:

[F] = .script([FLOAT], [FLOAT], [FLOAT]);
Each [FLOAT] represents a literal floating point number (in other words, you can't put in variable [F] types). In the command they are interpreted as the minimum value for flt, its maximum value, and the step size. If a line like this appears in your file, it means that when you press the Run Script button, the number on the left side of the "=" sign will start at minimum and will take steps of the size indicated by the other parameter until it reaches the maximum value. Thus, f = .script(0, 1, .01); will take 100 steps to proceed through the script. You can then use the value of f as you would any other number. In radian mode, if you want an angle to run from 0 to 2π in steps of .02 radians, do this: f = .script(0, 6.2831853, .02);

As an example, here's a simple script that drives a point in a circle of radius 1 about the origin in 100 steps:

.geometry "version 0.2";
f = .script(0, 360, 3.6);
vx = .f.rpn(f, .cos);
vy = .f.rpn(f, .sin);
v = .v.ff(vx, vy);
f is the angle in degrees and runs from 0 to 360 (to go completely around the circle). We then take the cosine and sine of the resulting number to generate the x and y coordinates of the point v. Run the script, and v moves smoothly around in a circle.

Normally, the Run Script button in Geometer is deactivated, but as soon as a .script command is read from the file, the button is activated. Only one script command is allowed per Geometer file.

That's all there is to the .script command, but it can be a very powerful tool.

Recording Animations

It is possible to save an EPS file for each stage of a running script. If you use the Print Script command in the File pull-down menu before running the script. This activates the saving of Encapsulated PostScript files for one execution of the script. The files are written in the same directory as the Ggeometer file and are given names related to that file. For example, if the file name is Frog.T and there are 20 steps in the script, PostScript files named Frog000.eps, Frog001.eps, ..., Frog019.eps will be generated.

It is up to you to figure out what to do with those files, but various programs can be used to combine them into animated GIFs that could be used on web pages, for example. For a detailed example, see the teacher's tutorial chapter.