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:

OperatorMeaningPriority
= 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 modulus0
*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 ArgumentsExplanation
sin 1sine function
cos 1cosine function
tan 1tangens function
asin 1arcus sine function
acos 1arcus cosine function
atan 1arcus tangens function
sinh 1hyperbolic sine function
cosh 1hyperbolic cosine
tanh 1hyperbolic tangens function
asinh 1hyperbolic arcus sine function
acosh 1hyperbolic arcus tangens function
atanh 1hyperbolic arcur tangens function
log2 1logarithm to the base 2
log10 1logarithm to the base 10
log 1logarithm to the base 10
ln 1logarithm to base e (2.71828...)
exp 1e raised to the power of x
sqrt 1square root of a value
sign 1sign function -1 if x<0; 1 if x>0
rint 1round to nearest integer
abs 1absolute value
if 3if ... then ... else ...
min variablemin of all arguments
max variablemax of all arguments
sum variablesum of all arguments
avg variablemean 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.







The formula parser that is included is the open source "muparser" created by Ingo Berg which can be found at http://muparser.beltoforion.de/

Related topics

Paint Mode Settings