This page contains an introduction to the EisenScript language.

For more information about various Structure Synth topics, the following blog posts may be useful:

The Anatomy of EisenScript

Below is an EisenScript sample. Hover the mouse over the various parts for more information.

/*
  Sample Torus.
*/

set maxdepth 100
r1
36  * { x -2 ry 10   } r1

rule r1 maxdepth 10 {
   2 * { y -1 } 3 * { rz 15 x 1 b 0.9 h -20  } r2
   { y 1 h 12 a 0.9  rx 36 }  r1
}

rule r2 {
   { s 0.9 0.1 1.1 hue 10 } box // a comment
}

rule r2 w 2 {
   { hue 113 sat 19 a 23 s 0.1 0.9 1.1 } box
}


Actions

Termination criteria

set maxdepth [integer]
Breaks after [integer] iterations (generations). This will also serve as a upper recursion limit for all rules.
set maxobjects [integer]
After [integer] objects have been created, the construction is terminated.
set minsize [float]
Allows you to specify how large or small a given object can be before terminating. The 'size' parameter refers to the length of the diagonal of a unit cube in the current local state. The initial coordinate frame goes from (0,0,0) to (1,1,1) and hence has a diagonal length of sqrt(3)~1.7). It is possible to specify both a mix and a min size. The termination criteria only stops the current branch - if other branches are still within a valid range, the will be continued. More info...
set maxsize [float]
See above.

Other

set seed [integer]
Allows you to set the random seed. This makes it possible to reproduce creations.
set seed initial
This allows you to set the seed to its initial value (the value specified in the seed box). Notice that each rule call branch maintains its own sequence of random numbers. This makes it possible to generate the same set of random numbers as used earlier, making it possible to combine randomness with self-similarity. More info.
set background [color]
Allows you to set the background color. Colors are specified as text-strings parsed using Qt's color parsing, allowing for standard HTML RGB specifications (e.g. #F00 or #FF0000), but also SVG keyword names (e.g. red or even lightgoldenrodyellow).

Rule modifiers

md / maxdepth [integer]
Rule Retirement.Sets the maximum recursive for the rule. The rule would not execute any actions after this limit has been reached.
md / maxdepth [integer] > [rulename]
Rule Retirement with substitution.Sets the maximum recursive for the rule. After this limit has been reached [rulename] will be executed instead this rule.
w / weight [float]
Ambiguous rules.If several rules are defined with the same name, a random definition is chosen according to the weight specified here. If no weight is specified, the default weight of 1 is used.

Transformations

Geometrical transformations

x [float]
X axis translation. The float argument is the offset measured in units of the local coordinate system.
y [float]
Y axis translation. As above.
z [float]
Z axis translation. As above.
rx [float]
Rotation about the x axis. The 'float' argument is the angle specified in degrees. The rotation axis is centered at the unit cube in the local coordinate system: that is the rotation axis contains the line segment from (0, 0.5, 0.5) -> (1, 0.5, 0.5).
ry [float]
Rotation about the y axis. As above.
rz [float]
Rotation about the z axis. As above.
s [float]
Resizes the local coordinate system. Notice that the center for the resize is located at the center of the unit cube in the local system (at (0.5,0.5,0.5)
s [f1] [f2] [f3]
Resizes the local coordinate system. As above but with separate scale for each dimension.
m [f1] ... [f9]
Applies the specified 3x3 rotation matrix to the transformation matrix for the current state. About the argument order: [f1],[f2],[f3] defines the first row of the matrix.
fx
Mirrors the local coordinate system about the x-axis. As above the mirroring planes is centered at the cube.
fy
Mirrors the local coordinate system about the y-axis.
fz
Mirrors the local coordinate system about the z-axis.

Color space transformations

h / hue [float]
Adds the 'float' value to the hue color parameter for the current state. Hues are measured from 0 to 360 and wraps cyclicly - i.e. a hue of 400 is equal to a hue of 40.
sat [float]
Multiplies the 'float' value with the saturation color parameter for the current state. Saturation is measured from 0 to 1 and is clamped to this interval (i.e. values larger then 1 are set to 1).
b / brightness [float]
Multiples the 'float' value with the brightness color parameter for the current state. Brightness is measured from 0 to 1 and is clamped to this interval. Notice that parameter is sometimes called 'V' or 'Value' (and the color space is often refered to as HSV).
a / alpha [float]
Multiplies the 'float' value with the alpha color parameter for the current state. Alpha is measured from 0 to 1 and is clamped to this interval. An alpha value of zero is completely transparant, and an alpha value of one is completely opaque.
color [color]
This commands sets the color to an absolut color (most other transformations are relative modifications on the current state). Colors are specified as text-strings parsed using Qt's color parsing, allowing for standard HTML RGB specifications (e.g. #F00 or #FF0000), but also SVG keyword names (e.g. red or even lightgoldenrodyellow)
blend [color] [strength]
Blends the current color with the specified color. A strength of 1.0 will weight the current and new color evenly. Colors are mixed in HSV color space. Hue's will wrap around. Saturation and Value are clamped to [0,1]. Notice that since the mixing is performed in HSV space, the result may seems counterintuitive. For instance blending a red color into a blue color, may have intermediate green steps (since you are change the hue - so you will move around on the HSV color circle). More info...
set color random
Chooses a random color (using the current colorpool - see below).
set colorpool [scheme]
Determines how random colors are drawn. The possible schemes are:
randomhue - chooses a random hue, with full brighness and saturation.
randomrgb - three independent random r,g, and b values.
greyscale - random r=g=b.
image:filename.png - color sampling. Chooses a random pixel from the specified image.
list:orange,white,grey - chooses from the specified list of colors. A color may appear multiple times to increase its weight. More info...

Drawing Primitives

box
solid box
grid
wireframe box
sphere
the round thingy (as of now this primitive has some issues - e.g. ellipsoids are not working.)
line
along x axis, centered in y,z plane.
point
centered in coordinate system.
triangle
creates a custom polygon. Specify the coordinates as follows: Triangle[0,0,0;1,0,0;0.5,0.5,0.5]
mesh
prototype mesh
cylinder
the symmetry axis will be the current x axis. [Not implemented]
tube
polygonal cylinder (will be drawn smoothly as the coordinate system transforms). [Not implemented]

Preprocessor commands

#define varname value

substitutes every occurrence of 'varname' with 'value'. Value may contain spaces.
#define varname value (float:0-40)

As above, but creates a pane with sliders for each of the variables defined. The values in the float-statement determines the lower and upper slider bounds. Example: '#define angle 14 (float:0-90)' will create a GUI slider for adjusting the angle parameter between 0 and 90.

For Context Free / CFDG users

The EisenScript syntax in Structure Synth has a lot in common with CFDG.

There are however a few important differences:

Context sensitivity: A CFDG script can be viewed as a grammar, where the production rules are independent of their context - or put differently - when choosing between rules CFDG does not have any knowledge of the history of system. This 'Context Free' property of CFDG was deliberately omitted in EisenScript, simply for pragmatic reasons: some structures would be difficult to create without having some way to change the rules after a certain number of recursions.

The 'startrule' statement: in CFDG startrules are explicitly specified. In EisenScript, a more generic approach is used: statements which can be used in a rule definition, can also be used at the top-level scope, so in order to specify a start-rule, just write the name of the rule.

Termination criteria: in CFDG recursion automatically terminates when the objects produced are too small to be visible. This is a very elegant solution, but it is not easy to do in a dynamic 3D world, where the user can move and zoom with the camera. Several options exist in Structure Synth for terminating the rendering.

Transformation order: in CFDG transformations (which CFDG refers to as adjustments) in curly brackets are not applied in the order of appearence, and if multiple transformations of the same type are applied, only the last one is actually carried out. For transformations in square brackets in CFDG the order on the other hand is significant. In Structure Synth the transformation order is always significant: transformations are applied starting from the right-most one.