This page contains a reference of all predefined input/output variables, constants, operators, and functions you can use when writing a script to process your pen/mouse data with **Lazy Nezumi Pro**.

- Output Variables
- Input Variables
- Constants
- Operators
- Functions
- L-System Functions
- Scripting Engine Version History

Your script must assign a value to at least one of these output variables for it to have an effect.

Name | Description | Range/Units |
---|---|---|

ox | Pen x coordinate. | Screen pixels |

oy | Pen y coordinate. | Screen pixels |

op | Pen pressure. | Normalized [0..1] |

or | Pen rotation angle (or twist) around its major axis. | Degrees [0..360] |

ote | Pen tilt elevation angle with the xy plane. Negative when the pen is flipped. | Degrees [-90..90] |

ota | Pen tilt azimuth angle around the z axis. | Degrees [0..360] |

These variables are updated before your script is called. They give your script a way to use your pen/mouse data.

Name | Description | Range/Units |
---|---|---|

x | Pen x coordinate. | Screen pixels |

y | Pen y coordinate. | Screen pixels |

rx | Pen x coordinate before ruler stage. | Screen pixels |

ry | Pen y coordinate before ruler stage. | Screen pixels |

sx | Start of stroke x coordinate. | Screen pixels |

sy | Start of stroke y coordinate. | Screen pixels |

ex | End of previous stroke x coordinate. | Screen pixels |

ey | End of previous stroke y coordinate. | Screen pixels |

psx | Start of previous stroke x coordinate. | Screen pixels |

psy | Start of previous stroke y coordinate. | Screen pixels |

p | Pen pressure. | Normalized [0..1] |

d | Distance from start of current stroke. | Screen pixels |

do | Distance from start of output pos. | Screen pixels |

dn | For rulers with a center or connection point: normalized distance. | Radial/Perspective/Connected: 1.0 at start, 0.0 at center/VP/connection point. Ellipse: 0.0 at start, plus or minus 1.0 for each time around. |

ds | Rulers: Radial, Perspective, Connected Distance from start to center/VP/connection point. | Screen pixels |

s | Pen speed. | Screen pixels between updates |

ew | Ellipse ruler width (width >= height). | Screen pixels |

eh | Ellipse ruler height. | Screen pixels |

er | Ellipse ruler rotation. | Degrees |

eca | Ellipse ruler current angle of pen position. | Degrees |

nx | Line normal x coordinate. | [-1..1] |

ny | Line normal y coordinate. | [-1..1] |

dx | Change in x since last pen position. | Screen pixels |

dy | Change in y since last pen position. | Screen pixels |

dxo | Change in x (normalized) of output position vector (ox, oy) since last execution. | [-1..1] |

dyo | Change in y (normalized) of output position vector (ox, oy) since last execution. | [-1..1] |

rcx | Ruler center position x. | Screen pixels |

rcy | Ruler center position y. | Screen pixels |

r | Pen rotation angle (or twist) around its major axis. | Degrees [0..360] |

te | Pen tilt elevation angle with the xy plane. Negative when the pen is flipped. | Degrees [-90..90] |

ta | Pen tilt azimuth angle around the z axis. | Degrees [0..360] |

tx | Pen tilt angle along the x-axis. | Degrees [-90..90] |

ty | Pen tilt angle along the y-axis. | Degrees [-90..90] |

sr | Starting pen rotation angle (or twist) around its major axis. | Degrees [0..360] |

ste | Starting pen tilt elevation angle with the xy plane. Negative when the pen is flipped. | Degrees [-90..90] |

sta | Starting pen tilt azimuth angle around the z axis. | Degrees [0..360] |

stx | Starting pen tilt angle along the x-axis. | Degrees [-90..90] |

sty | Starting pen tilt angle along the y-axis. | Degrees [-90..90] |

res0 | Result 0 of special functions. | Function dependant |

res1 | Result 1 of special functions. | Function dependant |

These are useful mathematical constants you can use in your scripts instead of writing out their values.

Name | Description | Value |
---|---|---|

pi | Archimedes' constant π. | 3.1415926536 |

e | Euler's number e. | 2.7182818284 |

phi | The golden ratio φ. | 1.6180339887 |

inf | A very big value. | 3.402823466e+38F |

true | True. | 1 |

false | False. | 0 |

zoom | Current canvas zoom percentage value. | [0..1] |

These are the scripting language operators, and their priority in a statement when not using parentheses.

Operator | Description | Priority |
---|---|---|

= | Assign a value to a variable. | -1 |

condition ? a : b | Evaluates to a if condition is true, b otherwise. | 0 |

&& | Boolean AND. | 1 |

|| | Boolean OR. | 2 |

<= | Less or equal. | 4 |

>= | Greater or equal. | 4 |

!= | Not equal. | 4 |

== | Equal. | 4 |

< | Less than. | 4 |

> | Greater than. | 4 |

+ | Add. | 5 |

- | Subtract. | 5 |

* | Multiply. | 6 |

/ | Divide. | 6 |

^ | Exponentiate. | 7 |

These are all the functions your script can call. When available, click the links to see graph previews.

Wave Functions | Description |
---|---|

saw(x) | Saw wave. All wave functions output in range [-1..1], and have a period of 1. graph |

sine(x, thickness) | Sine wave. Thickness parameter [0..1] controls how thick the crests are. Set to 1 for regular sine wave. graph |

triangle(x) | Triangle wave. graph |

square(x, pulseWidth) | Square wave. PulseWidth parameter [-1..1] controls width of crest. Set to 0 for a symmetrical wave. graph |

sigmoid(x) | Sigmoid wave. graph |

noise(x) | Sine-like noise function (continuous). graph |

cellNoise(x) | Square-like noise function (non-continuous). graph |

voronoi(x) | Triangle-like noise function (non-continuous). graph |

Trigonometric Functions | Description |

sin(a), cos(a), tan(a) | Sine, Cosine, Tangent of angle a (in radians). graph |

asin(x), acos(x), atan(x) | Inverse Sine, Cosine, Tangent functions (returns radians). graph |

Hyperbolic Functions | Description |

sinh(x), cosh(x), tanh(x) | Hyperbolic Sine, Cosine, Tangent functions. graph |

asinh(x), acosh(x), atanh(x) | Inverse Hyperbolic Sine, Cosine, Tangent functions. graph |

Exponential Functions | Description |

log2(x) | Binary (base 2) logarithm of x. graph |

log10(x) | Decimal (base 10) logarithm of x. graph |

log(x), ln(x) | Natural (base e) logarithm of x. graph |

exp(x) | e raised to the x power. graph |

sqrt(x) | Square root of x. graph |

rsqrt(x) | Inverse square root of x. graph |

Misc Functions | Description |

abs(x) | Absolute value of x. |

sign(x) | -1 if x < 0, 1 if x > 0, 0 if x == 0. |

rint(x) | Round to closest integral value. graph |

ceil(x) | Round up to the closest integral value. graph |

floor(x) | Round down to the closest integral value. graph |

frac(x) | Fractional part of x. graph |

fmod(x, y) | Floating-point remainder of x/y. |

clamp(a, b, x) | Clamp x to range [a..b]. graph |

mix(a, b, w) | Returns a when w is 0, b when w is 1, linear interpolation in between. graph |

mixDeg(a, b, w) | Linear interpolation between the angles a and b (in degrees) along their shortest arc. |

mixRad(a, b, w) | Linear interpolation between the angles a and b (in radians) along their shortest arc. |

minArcDeg(a, b) | Shortest arc between the angles a and b (in degrees). |

minArcRad(a, b) | Shortest arc between the angles a and b (in radians). |

linearStep(a, b, x) | Returns 0 if x < a, 1 if x > b, linear interpolation in between. graph |

smoothStep(a, b, x) | Returns 0 if x < a, 1 if x > b, cubic interpolation in between. graph |

smootherStep(a, b, x) | Like smoothStep but with quintic polynomial interpolation. graph |

easeIn*(a, b, x) easeOut*(a, b, x) easeInOut*(a, b, x) | Like smoothStep, but with different easing functions: Sine, Circ, Quad, Cubic, Quart, Quint, Exp, Back, Elastic, Bounce. |

Random Value Functions | Description |

randSeed(int) | Set the starting seed value for the random functions. If this is zero, the seed does not get reset between lines. |

rand() | Random value in range [0..1]. |

srand() | Random value in range [-1..1]. |

randGauss(mean, stddev) | Random value using gaussian distribution using supplied mean and standard deviation. |

Vector Functions | Description |

atan2(y, x) | Angle of (x, y) vector, in radians. |

normalize(x, y) | Returns length of (x, y) vector and normalizes it into (res0, res1). |

length(x, y) | Length of (x, y) vector. |

rlength(x, y) | Inverse length of (x, y) vector. |

lengthSq(x, y) | Square length of (x, y) vector. |

rotDeg(x, y, a) | Rotate (x, y) vector a degrees into (res0, res1). |

rotRad(x, y, a) | Rotate (x, y) vector a radians into (res0, res1). |

getQuadraticTangent(x, y, a) | Returns a normalized vector (res0, res1) that is tangent to the quadratic curve y = a * x^2, that passes through point (x, y). |

Statistics Functions | Description |

sum(...) | Sum of all arguments. |

avg(...) | Average of all arguments. |

min(...) | Minimum value of all arguments. |

max(...) | Maximum value of all arguments. |

Debugging & Logging | Description |

debugOut1(string, value) | Send string in printf format (with one argument) to the log (use dbgview app to see output). Example: debugOut1("Var: %f", var); |

debugOut2(string, v1, v2) | Send string in printf format (with two arguments) to the log. Example: debugOut2("Var1: %f, Var2: %f", var1, var2); |

These are all the available **L-System** related functions that you can use in your scripts for generative art.

Function | Description |
---|---|

lsysAxiom(string) | Set the Axiom (starting state) of the system. |

lsysRules(string) | Set the Rules of the system, in the following format: [symbol]=[symbols],[symbol]=[symbols],... |

lsysDrawSymbols(string) | Set the symbols (one after the other, without spaces or commas) that will cause the pen to move when encountered in the final instruction string. Other symbols will only be used to control the evolution of the system as it is iterated. |

lsysIterations(number) | Set the number of times the system should be iterated before producing the final instruction string. |

lsysDir(x, y) | Set the pen's starting Direction vector. Default is (1, 0). |

lsysDirAngle(angle) | Set the pen's starting Direction angle. (Can be used instead of lsysDir.) |

lsysAngle(angle) | Set the starting Angle (in degrees) that will be used when processing a rotate instruction. Default is 90. Also resets angle range and increase amount to their default values. |

lsysAngleRandom(angle) | Set the maximum angle (in degrees) that can be randomly added to the current Angle when processing a rotate instruction. Default is 0. |

lsysAngleScale(factor) | Set the Angle Scale Factor. Default is 1.3. |

lsysAngleInc(amount) | Set the Angle Increase Amount. Default is 10% of starting angle. |

lsysAngleRange(min, max) | Set the Angle min and max values. Defaults are 0 and 180. |

lsysThickness(thick) | Set the starting line Thickness, between 0.0 and 1.0. Default is 1.0. |

lsysThicknessRandom(factor) | Set the percentage of current Thickness that can be randomly added when moving the pen position. Default is 0. |

lsysThicknessScale(factor) | Set the Thickness Scale Factor. Default is 1.3. |

lsysThicknessInc(amount) | Set the Thickness Increase Amount. Default is 10% of starting thickness. |

lsysThicknessRange(min, max) | Set the Thickness min and max values. Defaults are 0 and 1. |

lsysLength(len) | Set the starting line Length. Default is 1.0. |

lsysLengthRandom(factor) | Set the percentage of current Length that can be randomly added when moving the pen position. Default is 0. |

lsysLengthScale(factor) | Set the Length Scale Factor. Default is 1.3. |

lsysLengthInc(amount) | Set the Length Increase Amount. Default is 10% of starting length. |

lsysLengthRange(min, max) | Set the Length min and max values. Defaults are 0 and 20. |

lsysLoop(loop) | If loop is 1, then lsysAdvance will wrap around to the start of the system's instruction string upon reaching the end. Otherwise, the pen position will no longer be updated. Default is 0. |

lsysMaxLoops(int) | Sets the number of times the system will loop. Set to -1 to loop forever, which is the same as calling lsysLoop(1). |

lsysMaxDrawSteps(steps) | Set the maximum number of draw steps that will be used for a draw instruction. Will produce curved lines when using the '>' and '<' rotate instructions. Default is 1. |

lsysMinStepDist(dist) | Set the minimum step distance (in screen pixels) when drawing in multiple steps. Increasing this can speed up drawing when there are lots of short branches. Default is 8. |

lsysAdvance() | Step through the system's instruction string until finding a Draw Symbol, at which point the pen's position is moved by the current Length in the current Direction. If MaxDrawSteps > 1, this can happen over several calls. The new position is stored in the ox, oy variables, and the current thickness is stored in the op variable. The current distance traveled from the start position is stored in the d variable. The current normal vector is stored in the nx, ny variables. |

The following table describes the function of each **Symbol** you can use when defining your **L-System Axiom and Rules**.

Symbol | Instruction |
---|---|

Any Draw Symbol | Move the pen position by Length amount in the current Direction. |

0-9 | Sets the current Skip Number (used with the ? symbol). |

? | Random Skip: Selects a random number between 0 and 10. If it is higher than the current Skip Number, then skip the next instruction. |

: | Skip the next instruction. You can use this to write statements like 5?A:B, where either A or B will be executed. |

( ) | Open and close an Instruction Group. This lets you skip an entire group of instructions by writing something like 5?(AB):(CD). |

[ | Save the state to the stack and start a new Branch. |

] | End the current Branch and restore the state from the top of the stack. |

+ | Rotate the current Direction right by the set Angle amount, plus a random amount of which the maximum is set by lsysAngleRandom. |

- | Rotate the current Direction left by the set Angle amount, plus a random amount of which the maximum is set by lsysAngleRandom. |

> | Like '+', but rotate gradually if MaxDrawSteps > 1. |

< | Like '-', but rotate gradually if MaxDrawSteps > 1. |

| | Reverse direction (rotate 180 degrees). |

. | Exchange meaning of + and -. |

! | Divide Thickness by Thickness Scale Factor. |

@ | Multiply Thickness by Thickness Scale Factor. |

# | Decrease Thickness by Thickness Increase Amount. |

$ | Increase Thickness by Thickness Increase Amount. |

% | Divide Length by Length Scale Factor. |

^ | Multiply Length by Length Scale Factor. |

& | Decrease Length by Length Increase Amount. |

* | Increase Length by Length Increase Amount. |

{ | Divide Angle by Angle Scale Factor. |

} | Multiply Angle by Angle Scale Factor. |

_ | Decrease Angle by Angle Increase Amount. |

/ | Increase Angle by Angle Increase Amount. |

Depending on the version of **Lazy Nezumi Pro** you are using, you may not be able to use all the scripting functionalities shown on this page. This section shows the version history.

**23.05.09** New input variables: tx, ty, sr, ste, sta, stx, sty. New functions: minArcDeg, minArcRad, mixDeg, mixRad. New constant: zoom. The unit for pen tilt variables has been changed to degrees.

**22.07.20** New input variables: do, dxo, dyo.

**21.09.12** New functions: randSeed, voronoi, linearStep, easeIn*, easeOut*, easeInOut*. New L-System functions: lsysMaxDrawSteps, lsysMinStepDist, lsysMaxLoops, lsysAngleRange, lsysThicknessRange, lsysLengthRange, lsysDirAngle. New constants: true, false. Added number scale suffixes: G M k h d c m mu n.

**21.06.05** New functions: noise, cellNoise, sine, saw, triangle, square, sigmoid, debugOut2. New constant: phi. Added /* */ and // style comment support.

**18.02.01** New input variables: ew, er, eca.

**17.06.09** New input variable: ds.

**17.03.25** New input variables: rcx, rcy.

**17.01.25** New input variables: rx, ry.

**16.11.13** New input variables: dn, eh.

**15.05.05** New input variables: psx, psy.

**14.08.26** New function: getQuadraticTangent.

**14.08.09** New constant: inf.

**14.06.17** New input variables: ex, ey.

**14.05.06** New functions: normalize, length, rlength, lengthSq. New input variables: dx, dy.

**14.04.14** L-System functions.

**14.03.27** New functions: clamp, debugOut, rotDeg, rotRad.

**14.03.17** Scripting engine introduced.

Copyright © 2013-2024 Guillaume Stordeur. All rights reserved. Privacy Policy. EULA.

Lazy Nezumi is a trademark of Guillaume Stordeur. Developed in the USA.