# Enigma Studio Documentation

Here you will find documentation about some of the most mysterious features of this marvellous software. The goal is not to have a full documentation of each and every feature, but to remind the users of the details that even we as developers never seem to be able to remember, when we need them ;)

## 1 Working with Views

### 1.1 Using the Mouse

LMB+drag | Scrolls a view
RMB+drag | Selects items in a view using a selection rectangle
LMB+ALT+drag | Zooms a view
MMB+drag | Moves the time marker of a view (if such exists)

### 1.2 Using the Keyboard

#### 1.2.1 Viewport

W A S D | Move around in the viewport
Shift | Accellerates viewport movements
Tab | Toggles viewport between full screen and windowed
R | Resets the viewport
T | Shows bitmap tiled
A | Visualizes bitmap's alpha channel
+ | Zooms in bitmap
- | Zooms out bitmap
G | Toggles grid
N | Toggles mesh normals
B | Toggles bounding boxes
Y | Activates scale widget
X | Activates rotate widget
C | Activates translate widget
T | Enables fixed camera for effect operators
Z | Enables free camera for effect operators
U | Enables linked camera for effect operators

#### 1.2.2 Operator page view

A | Adds a new operator
Del | Removes the selected operators
S | Shows the selected operator in viewport
G | Jumps to the operator loaded by the selected load operator
Ctrl+A | Selects all operators
F | Opens a dialog to search for operators
+ | Zooms in the operator page
- | Zooms out the operator page
C | Copies the selected operators to clipboard
X | Cuts the selected operators to clipboard
V | Pastes operators from clipboard
P | Opens the selected path operator in the path-editor
Q | Opens the the selected demo operator in the sequencer

#### 1.2.3 Sequencer

A demo operator can be loaded into the sequencer using the context menu in the operator page view or the hotkey Q.

G | Toggles displaying gaps
Q | Finishes editing demo and goes pack to operator page view

#### 1.2.4 Path-editor

A path operator can be loaded into the path-editor using the context menu in the operator page view or the hotkey P.

A | Adds a new key to the active sub-path at the current time
W | Adds a new key to each sub-path at the current time
Del | Removes the selected keys
F | Adjusts the zoom so that the full path is visible
C | Copies the selected keys to clipboard
X | Cuts the selected keys to clipboard
V | Pastes keys from the clipboard
Ctrl+A | Selects all keys of all sub-paths
1 2 3 4 | Toggles visibility of X, Y, Z and W sub-paths
P | Finishes editing path and goes back to operator page view
Q | Sets the interpolation mode of the selected keys to cubic
L | Sets the interpolation mode of the selected keys to linear
S | Sets the interpolation mode of the selected keys to step

## 2 Script System

### 2.1 Variables

In the script scalar and 4D vector variables are available. They can be declared as shown in the following. Declaration and initialization cannot be performed at the same time. Individual elements of vector variables can be accessed by appending `.x`, `.y`, `.z`, `.w` to the variable. Swizzling is currently not supported.

`scalar s; s = 5.1;` | Declares a scalar variable `s` initializes it
`vector v; v = [1,2,3,4];` | Declares a vector variable `v` initializes it

### 2.2 Globals

`time` | Contains the scene time in seconds
`time_rel` | Contains the relative scene time since the last rendered frame in seconds
`audio_peak` | Contains the absolute amplitude peak of audio in the range [0,1]

### 2.3 Functions

`sin(x)` | Calculates sine for input x
`cos(x)` | Calculates cosine for input x
`sqrt(x)` | Calculates square root for input x
`min(x, y)` | Returns the lower of the two inputs
`max(x, y)` | Returns the higher of the two inputs
`abs(x)` | Returns the absolute number for x
`mod(x, y)` | Returns x modulo y
`path("path", time)` | Evaluates the given path for a given time value
`random(min, max)` | Returns a random number in the given range

### 2.4 Popular examples

                // Animating perlin bitmap op
                #Persistence = sin(time*0.5) + 2.0;
                #Amplify = sin(time*1.5) + 3.0;

                // Animating mesh multiply rotation
                #Rotate.x = sin(time) * 0.005;
                #Rotate.y = -0.1 + cos(time) * 0.005;

                // defining and using vectors
                vector v;
                v = [1, 2, 3, 4];
                #Rotate = v;

                // defining and using scalars
                scalar s;
                s = 5;
                #Rotate.x = s;