Documentation

Formula Editor

This editor is used to define certain mathematical formulas for the formula paint mode in the
menu Mode.
Calculations than are to be used as paint mode transformation can be made based on combining
color indexes or by doing calculations in RGB or HSB spaces. You may define settings for any of these calculation types. The
current selected one (tab) is then actually used.
When applying the formula paint mode Pro Motion passes pixel data of the underlying image and
the used brush shape to the corresponding formula.

The formula engine that is used provides the following set of mathematical operators:

Operator

Meaning

Priority

=

assignement*

-1

and

logical and

1

or

logical or

1

xor

logical xor

1

<=

less or equal

2

>=

greater or equal

2

!=

not equal

2

==

equal

2

>

greater than

2

<

less than

2

+

addition

3

-

subtraction

3

*

multiplication

4

/

division

4

^

raise x to the power of y

5

mod

modulus

0

*The assignment operator is special since it changes one of its arguments and can only by applied to variables.

The smaller the priority the later the operator is applied to it's operands. For example x * 3 - 2 will calculate "x * 3" before
substracting 2. To have other priorities you must use braces, like x * (3-2).

Additionaly the follwing functions are supported:

Name

# of Arguments

Explanation

sin

1

sine function

cos

1

cosine function

tan

1

tangens function

asin

1

arcus sine function

acos

1

arcus cosine function

atan

1

arcus tangens function

sinh

1

hyperbolic sine function

cosh

1

hyperbolic cosine

tanh

1

hyperbolic tangens function

asinh

1

hyperbolic arcus sine function

acosh

1

hyperbolic arcus tangens function

atanh

1

hyperbolic arcur tangens function

log2

1

logarithm to the base 2

log10

1

logarithm to the base 10

log

1

logarithm to the base 10

ln

1

logarithm to base e (2.71828...)

exp

1

e raised to the power of x

sqrt

1

square root of a value

sign

1

sign function -1 if x0

rint

1

round to nearest integer

abs

1

absolute value

if

3

if ... then ... else ...

min

variable

min of all arguments

max

variable

max of all arguments

sum

variable

sum of all arguments

avg

variable

mean value of all arguments

The arguments must be passed in braces, e.g. sin(x) or if( x > 2, 7, 6 ). The number of arguments may be variable, for example
when using the sum function.

Predefined variables to create calculations with are always listed at the respective color space section.

Indexed

Calculations working on color indexes will get color indexes as input data. You can not access
any RGB values of the colors. That means you formula must have knowledge about color orders
in your palette.

RGB

Calculations working on RGB color space get RGB values as input data. For the RGB result the best matching color in
the color table is used. The result can be very poor, if the colors in palette differ too much from the results. To improve this
you can Limit the Color Matching to current Gradient or use a Dither Mode. Dithering works best if you use an uniform palette,
like the one that is saved as "uniform.pal" in the palettes folder.

HSB

Calculations working on HB color space get HSB values as input data. For the HSB result the best matching color in
the color table is used. The definitions for color matching are the same as with RGB mode.