### 5.6 Interactive Variables ¶

The GUI for the first version of the Eukleides language, named `xeukleides`, allowed to interactively modify the value of numeric variables using the keyboard. The planned GUI for the second version will have similar features.

#### Mobile points ¶

A mobile point is a point-valued variable which is bound to a state (A to Z) and to the keyboard arrows. To switch to a given state, the user has to hit the corresponding key.

Syntax for a mobile point declaration is:

`mobile var { (state) } = point`
`mobile var ( { state, } z) = point`
`mobile var ( { state, } x, y, x', y' { , z } ) = point`

unless var already contains a point, in which case the initialisation part has to be omitted.

A state identifier consists in the number sign (`#`) followed by the corresponding uppercase letter. When omitted, the variable is bound to the state corresponding to the first letter of its name. Number z is the amount by which the appropriate coordinate is incremented or decremented for each stroke on the arrow keys (default: 0.1). Numbers x and x' are the minimal and maximal abscissa, numbers y and y' are the minimal and maximal ordinate. By default there are no boundaries.

Example: `mobile P_0(`#`A, 0.2)`

#### Interactive numeric variables ¶

An interactive numeric variable is bound to a state (A to Z) and to either the horizontal or the vertical keyboard arrows.

Syntax for interactive variable declaration is:

`horizontal variable (state { , x, y } { , z }) = t`
`vertical variable (state { , x, y } { , z }) = t`

Numbers x and y are the lower and upper bound. By default there are no boundaries. Number z is the amount by which the variable is incremented or decremented (default: 0.1).

Example: `horizontal x(`#`A, -1, 1)`

#### Initialisation directives ¶

An initialisation directive is equivalent to keystrokes prior to execution. It consists in a single line starting with a number sign followed by a space separated list of pairs of letters and integers. Lowercase letters correspond to horizontal arrows, uppercase to vertical. Negative integers correspond to left or down directions, positive to right or up.

Example: ``#` a 5 A 10 b -4`

This initialisation directive is equivalent to 5 strokes on the right arrow key and 10 strokes on the up arrow key in A state and 4 strokes on the left arrow key in B state.

An initialisation directive may also be given as a command-line parameter (using the `--interactive` option. If several initialisation directives are present, only the last one is taken into account.

#### Animation ¶

With `eukleides`, the `--animate` option allows one to generate PostScript files containing several pages which may be converted into animated GIFs (using ImageMagik’s `convert` for instance). The parameter for this option consists in a single letter followed by an integer number (without space), with the same meaning as for initialisation directives.

Example: `eukleides --animate=A20 figure.euk`

The former command yields a 20 pages PostScript file, each step corresponding to a stroke on the up arrow key.