optionsfiltername(user values)

expression

end

optionscan be zero or more options for the filter. They are discussed in detail below.The

nameof the filter can be an arbitrary identifier (identifiers can contain letters, digits and the underscore and must not begin with a digit).The

user valuesmust be separated by commas. Any number of user values can be specified. See below for a detailed discussion of user values.

floatname:min-max(default)- A tuple of type
nil:1with the value of a floating point number chosen in the range frommintomax. The default value isdefault.intname:min-max(default)- A tuple of type
nil:1with the value of an integer chosen in the range frommintomax. The default value isdefault.boolname- A tuple of type
nil:1with the value0or1.colorname- A tuple of type
rgba:4, representing a color.curvename- A function taking a single argument between
0and1and returning the value of the corresponding point on the curve, also between0and1.gradientname- A function taking a single argument between
0and1and returning the color at that point as a tuple of typergba:4.optionsimagename- A function taking a single argument of type
xy:2orra:2and returning the color of the point with those coordinates in the image as a tuple of typergba:4.optionscan be left out or it can be theunitoption, discussed below.

unitFilters and image user values can be given the

unitoption to use a differently scaled coordinate system. Instead of pixel coordinates, which are the default, a filter or image with theunitoption will be scaled such that the value along its shorter axis goes from-1to1. The longer axis will be scaled to preserve the aspect ratio.If the

unitoption is given thestretchedsub-option in addition, the values along both axes will go from-1to1.

Every value in MathMap is a tagged tuple. This means it consists of one or more numbers and a symbolic tag. RGBA colors, for example are represented by tuples of length 4 with the tag

rgba(standing for "red, green, blue, alpha"). The valuergba:[1,0,0,1]for example, represents the fully opaque color red.Single numbers are represented by tuples of length 1 with the tag

nil(which is the default tag). For simplicity's sake, single numbers need not be written in tuple syntax, i.e.3.1415is equivalent tonil:[3.1415].There are several other tuple tags which are used by MathMap:

TagPurposenilDefault tag rgbaRGBA Color hsvaHSVA Color riComplex number xyCartesian coordinate raPolar coordinate v22d vector v33d vector m2x22x2 matrix m3x33x3 matrix quatnon-commutative quaternion cquatcommutative quaternion hyperhypercomplex number In order for the tag system to make sense, operators and functions are overloaded based on the types of their arguments. For this to work at compile time, types must be statically determined. That means that any expression must have only one possible type, e.g. the expression

if x then abc:[1,2,3] else xyz:[4,5] endis not valid. Furthermore, all assignments to the same variable must have the same type. Hence,v=[1,2];v=[1,2,3]is not valid.Tuple types are expressed in this manual in the form

T:LwhereTis the tag andLis the length, e.g.rgba:[1,0,0,1]has the typerbga:4.Elements of tuples can be extracted by the indexing operator

[]. The expressionp[0], for example, extracts the first element ofpand is of typenil:1.

A few variables are set for the position of the pixel to be calculated:To make it easier to write expressions which depend on the image size, a few additional variables are set:

xy(xy:2)- The cartesian coordinates of the pixel.
x(nil:1)- The first component of the cartesian coordinates of the pixel.
y(nil:1)- The second component of the cartesian coordinates of the pixel.
ra(ra:2)- The polar coordinates of the pixel.
r(nil:1)- The first component of the polar coordinates of the pixel (
0 <= r < 2*pi).a(nil:1)- The second component of the polar coordinates of the pixel (the distance from the center).
For the purpose of animations two additional variable are set:

WH(xy:2)- The size of the image.
W(nil:1)- The width of the image.
H(nil:1)- The height of the image.
R(nil:1)- The biggest possible value for
rin the image, which it has at the four corners.XY(xy:2)- The biggest possible value (in both components) for
xy.X(nil:1)- The biggest possible value for
xfor the image.Y(nil:1)- The biggest possible value for
yfor the image.

t(nil:1)- The time which is
0 <= t < 1. If animation is disabled, the value oftcan be chosen in the Settings tab. If you want to make animations loop, set the 'Periodic' check-box in the Settings tab and make sure that the images att == 0andt == 1are the same.frame(nil:1)- The number of the current frame, beginning with
0for the first frame.

MathMap defines a few mathematical constants to make your life easier:

pi(nil:1)- 3.1415926535...
e(nil:1)- Euler's constant 2.7182818284...
I(ri:2)- The imaginary unit
ri:[0,1]

Conditions and invariants are always expected to evaluate to tuples of length 1.

ifconditionthen

consequence

end- Returns the value of
consequenceif the value ofconditionis not0,0otherwise.

ifconditionthen

consequence

else

alternative

end- Returns the value of
consequenceif the value ofconditionis not0, otherwise the value ofalternative.

whileinvariantdo

body

end- While
invariantis not0, executesbody, then returns0.

do

body

whileinvariantend- Executes
bodyuntilinvariantis not equal0, then returns0.

forcounter=start..enddo

body

end- Executes
bodywith the variablecountergoing fromstarttoend, then returns 0. Semantically equivalent to

counter=start;

__tmp=end;

whilecounter<=__tmpdo

body;

counter=counter+1;

end

Operators and functions in MathMap are overloaded based on the number and tuple types of their arguments. The reference enumerates all the ways in which operators and functions are overloaded by giving the argument and return types like this:

(v3:3, m3x3:9) -> v3:3. This particular example describes a function taking two arguments, the first of length 3 with the tagv3and the second of length 9 with the tagm3x3, and returning a tuple of length 3 with the tagv3.Most overloading specifications are parametric, though, in that the length and/or tag of the tuples is not fixed, like here:

(?t:1, ?t:1) -> ?t:1. The question mark indicates a parametric variable (in this case?t, whose value is arbitrary, but which must have the same value wherever it occurs. Here the function takes two arguments, both of length 1 and both having the same, but arbitrary, tag. It returns a tuple of length 1 with that very same tag. Parametric variables denoted just by a question mark, without any symbolic name, are arbitrary and independent of all other parametric variables, i.e. two sole question marks can have different values.

a + bAddition. Works on real numbers, complex numbers and tuples. Tuples can be added element-wise or the same real number can be added to each element of a tuples.(ri:2, ri:2) -> ri:2

(ri:2, ?:1) -> ri:2

(?:1, ri:2) -> ri:2

(?t:1, ?t:1) -> ?t:1

(?t:?l, ?:1) -> ?t:?l

(?t:?l, ?t:?l) -> ?t:?l

a && bThe logical conjunction of the two arguments.(?t:1, ?t:1) -> ?t:1

__applyCurve(c, p)(curve:1, ?:1) -> nil:1

__applyGradient(g, p)(gradient:1, ?:1) -> rgba:4

a / bDivision. Works on real numbers, complex numbers, tuples, vectors and matrices. A tuple can be divided by another element-wise or by the same number for each element. Vectors can be divided by matrices.(ri:2, ri:2) -> ri:2

(?t:1, ri:2) -> ri:2

(?:2, m2x2:4) -> v2:2

(?:3, m3x3:9) -> v3:3

(?t:1, ?t:1) -> ?t:1

(?t:?l, ?:1) -> ?t:?l

(?t:?l, ?t:?l) -> ?t:?l

a == bReturns 1 if the arguments are equal, otherwise 0.(ri:2, ri:2) -> nil:1

(ri:2, ?:1) -> nil:1

(?:1, ri:2) -> nil:1

(?t:1, ?t:1) -> nil:1

a > bReturns 1 if(?t:1, ?t:1) -> nil:1

ais greater thanb, otherwise 0.

a >= bReturns 1 if(?t:1, ?t:1) -> nil:1

ais greater or equal thanb, otherwise 0.

a < bReturns 1 if(?t:1, ?t:1) -> nil:1

ais less thanb, otherwise 0.

a <= bReturns 1 if(?t:1, ?t:1) -> nil:1

ais less or equal thanb, otherwise 0.

a % bRemainder. Calculates the remainder of a division. Works on real numbers and tuples. The remainder can be calculated for two tuples element-wise or for one tuple and the same number for each element of the tuple.(?t:1, ?t:1) -> ?t:1

(?t:?l, ?:1) -> ?t:?l

(?t:?l, ?t:?l) -> ?t:?l

a * bMultiplication. Works on real numbers, complex numbers, quaternions, hypercomplex numbers, tuples, vectors and matrices. Two tuples can be multiplied element-wise or a tuple can be multipled by a single number for each element. Vectors and matrices can be multipled in both directions and two matrices can be multipled as well.(ri:2, ri:2) -> ri:2

(?:1, ri:2) -> ri:2

(m2x2:4, m2x2:4) -> m2x2:4

(m3x3:9, m3x3:9) -> m3x3:9

(v2:2, m2x2:4) -> v2:2

(v3:3, m3x3:9) -> v3:3

(m2x2:4, v2:2) -> v2:2

(m3x3:9, v3:3) -> v3:3

(quat:4, quat:4) -> quat:4

(cquat:4, cquat:4) -> cquat:4

(hyper:4, hyper:4) -> hyper:4

(?t:1, ?t:1) -> ?t:1

(?t:?l, ?:1) -> ?t:?l

(?t:?l, ?t:?l) -> ?t:?l

-xNegation.(?t:?l) -> ?t:?l

!aThe logical negation of the argument.(?t:1) -> ?t:1

a != bReturns 1 if the arguments are not equal, otherwise 0.(?t:1, ?t:1) -> nil:1

a || bThe logical disjunction of the two arguments.(?t:1, ?t:1) -> ?t:1

__origVal(p, frame, drawable)(xy:2, nil:1, image:1) -> rgba:4

a ^ bExponentiation of real and complex numbers and tuples. A tuple can be exponentiated for each element by a single number.(ri:2, ?t:1) -> ri:2

(ri:2, ri:2) -> ri:2

(?t:1, ri:2) -> ri:2

(?t:1, ?t:1) -> ?t:1

(?t:?l, ?:1) -> ?t:?l

a - bSubtraction. Works on real numbers, complex numbers and tuples. One tuple can be subtracted from another element-wise or the same real number can be subtracted from each element of a tuple.(ri:2, ri:2) -> ri:2

(ri:2, ?:1) -> ri:2

(?:1, ri:2) -> ri:2

(?t:1, ?t:1) -> ?t:1

(?t:?l, ?:1) -> ?t:?l

(?t:?l, ?t:?l) -> ?t:?l

a xor bThe logical exclusive disjunction of the two arguments.(?t:1, ?t:1) -> ?t:1

abs(a)Absolute value of real numbers, complex numbers (magnitude), quaternions, hypercomplex numbers and vectors (Euclidian norm).(ri:2) -> nil:1

(quat:4) -> nil:1

(cquat:4) -> nil:1

(hyper:4) -> nil:1

(v2:2) -> nil:1

(v3:3) -> nil:1

(?t:1) -> ?t:1

(?t:?l) -> ?t:?l

acos(a)Arccosine of real and complex numbers.(ri:2) -> ri:2

(?t:1) -> ?t:1

acosh(a)Hyperbolic arccosine of real and complex numbers.(ri:2) -> ri:2

(?t:1) -> ?t:1

alpha(c)The alpha (opacity) component of the color(rgba:4) -> nil:1

c.

arg(a)The argument of a complex number.(ri:2) -> nil:1

asin(a)Arcsine of real and complex numbers.(ri:2) -> ri:2

(?t:1) -> ?t:1

asinh(a)Hyperbolic arcsine of real and complex numbers.(ri:2) -> ri:2

(?t:1) -> ?t:1

atan(y, x)Arctangent of(?t:1, ?t:1) -> ?t:1

y/x, with the signs of the arguments taken into account to determine the correct quadrant of the result.

atan(a)Arctangent of real and complex numbers.(ri:2) -> ri:2

(?t:1) -> ?t:1

atanh(a)Hyperbolic arctangent of real and complex numbers.(ri:2) -> ri:2

(?t:1) -> ?t:1

beta(a, b)The complete beta function for positive real arguments.(?t:1, ?t:1) -> ?t:1

blue(c)The blue component of the color(rgba:4) -> nil:1

c.

ceil(a)The ceiling of a number, defined as the smallest integer not smaller than that number.(?t:1) -> ?t:1

clamp(a, l, u)Clamp each element of tuple(?t:?l, ?t:?l, ?t:?l) -> ?t:?l

ato be not less than the corresponding element inland not greater than the corresponding element inu.

conj(a)The complex conjugate.(ri:2) -> ri:2

cos(a)Cosine of real and complex numbers.(ri:2) -> ri:2

(?t:1) -> ?t:1

cosh(a)Hyperbolic cosine of real and complex numbers.(ri:2) -> ri:2

(?t:1) -> ?t:1

crossp(a, b)Cross product of two tuples/vectors with three elements.(?t:3, ?t:3) -> ?t:3

deg2rad(a)Convert degrees to radians.(?:1) -> nil:1

det(a)Determinant of a matrix.(m2x2:4) -> nil:1

(m3x3:9) -> nil:1

dotp(a, b)Dot product of two tuples/vectors.(?t:?l, ?t:?l) -> nil:1

ell_int_D(phi, k, n)Incomplete elliptic integral D in Legendre form.(?t:1, ?t:1, ?t:1) -> ?t:1

ell_int_E(phi, k)Incomplete elliptic integral E in Legendre form.(?t:1, ?t:1) -> ?t:1

ell_int_Ecomp(k)Complete elliptic integral E in Legendre form.(?t:1) -> ?t:1

ell_int_F(phi, k)Incomplete elliptic integral F in Legendre form.(?t:1, ?t:1) -> ?t:1

ell_int_Kcomp(k)Complete elliptic integral K in Legendre form.(?t:1) -> ?t:1

ell_int_P(phi, k, n)Incomplete elliptic integral P in Legendre form.(?t:1, ?t:1, ?t:1) -> ?t:1

ell_int_RC(x, y)Incomplete elliptic integral RC in Carlson form.(?t:1, ?t:1) -> ?t:1

ell_int_RD(x, y, z)Incomplete elliptic integral RD in Carlson form.(?t:1, ?t:1, ?t:1) -> ?t:1

ell_int_RF(x, y, z)Incomplete elliptic integral RF in Carlson form.(?t:1, ?t:1, ?t:1) -> ?t:1

ell_int_RJ(x, y, z, p)Incomplete elliptic integral RJ in Carlson form.(?t:1, ?t:1, ?t:1, ?t:1) -> ?t:1

ell_jac_cn(u, m)Jacobian elliptic function cn for real and complex arguments.(?t:1, ?t:1) -> ?t:1

(ri:2, ?:1) -> ri:2

ell_jac_dn(u, m)Jacobian elliptic function dn for real and complex arguments.(?t:1, ?t:1) -> ?t:1

(ri:2, ?:1) -> ri:2

ell_jac_sn(u, m)Jacobian elliptic function sn for real and complex arguments.(?t:1, ?t:1) -> ?t:1

(ri:2, ?:1) -> ri:2

exp(a)The natural exponential function(ri:2) -> ri:2

(?t:1) -> ?t:1

e^xfor real and complex numbers.

floor(a)The floor of a number, defined as the largest integer not greater than that number.(?t:1) -> ?t:1

gamma(a)The (logarithm of the) gamma function for real and complex numbers.(ri:2) -> ri:2

(?t:1) -> ?t:1

gray(c)The luminance value of the color(rgba:4) -> nil:1

c.

grayColor(g)Returns a fully opaque gray RGBA color with luminance(?t:1) -> rgba:4

g, i.e.rgba:[g,g,g,1].

grayaColor(g, a)Returns a gray RGBA color with luminance(?t:1, ?t:1) -> rgba:4

gand alpha componenta, i.e.rgba:[g,g,g,a].

green(c)The green component of the color(rgba:4) -> nil:1

c.

inintv(a, l, u)Returns 1 if(?t:1, ?t:1, ?t:1) -> nil:1

alies in the interval defined by the lower boundland the upper boundu, otherwise 0.

lerp(p, a, b)Linear interpolation between(?:1, ?t:?l, ?t:?l) -> ?t:?l

(?t:?l, ?t:?l, ?t:?l) -> ?t:?l

aandb, done element-wise. The result isaifpis 0,bifpis 1, and linearly interpolated in between. More formally, the result isa*(1-t)+b*t.

log(a)The natural logarithm for real and complex numbers.(ri:2) -> ri:2

(?t:1) -> ?t:1

max(a, b)The larger of two numbers. For tuples, the larger number for each pair of elements is determined.(?t:?l, ?t:?l) -> ?t:?l

min(a, b)The smaller of two numbers. For tuples, the smaller number for each pair of elements is determined.(?t:?l, ?t:?l) -> ?t:?l

noise(octaves, persistence, lacunarity, a)(?:1, ?:1, ?:1, ?:3) -> nil:1

noise(a)The Perlin noise function, defined in three-dimensional space. Its values lie between -1 and 1 if(?:3) -> nil:1

octavesis 1.octavesis the number of octaves (by default 1).persistenceis the factor by which the amplitude dimishes from one octave to the next.lacunarityis the factor by which the frequency increases from one octave to the next.

noiseBillow(octaves, persistence, lacunarity, a)A "billowy" noise function, similar to Perlin noise. Its values lie between -1 and 1 if(?:1, ?:1, ?:1, ?:3) -> nil:1

octavesis 1.octavesis the number of octaves (by default 1).persistenceis the factor by which the amplitude dimishes from one octave to the next.lacunarityis the factor by which the frequency increases from one octave to the next.

noiseRidgedMulti(octaves, lacunarity, a)A "ridgy" noise function, similar to Perlin noise. Its values lie between -1 and 1 if(?:1, ?:1, ?:3) -> nil:1

octavesis 1.octavesis the number of octaves (by default 1).persistenceis the factor by which the amplitude dimishes from one octave to the next.lacunarityis the factor by which the frequency increases from one octave to the next.

normalize(a)Normalize a vector to Euclidian length 1.(?t:?l) -> ?t:?l

pixelSize(drawable)Returns a tuple giving the width and height of one pixel in the image(image:1) -> xy:2

drawable.

pmod(a, b)The remainder of a division, made positive if the dividend is negative by adding the divisor.(?t:1, ?t:1) -> ?t:1

print(val)Print a tuple to standard output. Useful for debugging a script.(?:?) -> nil:1

rad2deg(a)Convert radians to degrees.(?:1) -> deg:1

rand(a, b)A random number between(?t:1, ?t:1) -> ?t:1

aandb.

red(c)The red component of the color(rgba:4) -> nil:1

c.

render(drawable)Renders the image(image:1) -> image:1

drawable, giving another drawable, which is a bitmap image.

rgbColor(r, g, b)Returns a fully opaque RGBA color with red component(?t:1, ?t:1, ?t:1) -> rgba:4

r, green componentgand blue componentb, i.e.rgba:[r,g,b,1].

rgbaColor(r, g, b, a)Returns an RGBA color with red component(?t:1, ?t:1, ?t:1, ?t:1) -> rgba:4

r, green componentg, blue componentband alpha componenta, i.e.rgba:[r,g,b,a].

scale(a, fl, fu, tl, tu)Scale each element of(?t:?l, ?t:?l, ?t:?l, ?t:?l, ?t:?l) -> ?t:?l

awhich is supposed to lie between the corresponding elements offlandfuto lie at the same point betweentlandtu, proportionately. More formally, computes((a-fl)/(fu-fl))*(tu-tl)+tl.

sign(a)The sign of a number or tuple. The sign of a number is -1 if the number is negative, 1 if the number is positive and 0 if the number is 0. For a tuple, calculates the sign element-wise.(?t:?l) -> ?t:?l

sin(a)Sine of real and complex numbers.(ri:2) -> ri:2

(?t:1) -> ?t:1

sinh(a)Hyperbolic sine of real and complex numbers.(ri:2) -> ri:2

(?t:1) -> ?t:1

sqrt(a)The square root of a complex or real number. A real argument must be positive, otherwise the result will not be definied.(ri:2) -> ri:2

(?t:1) -> ?t:1

sum(a)The sum of all elements of a tuple.(?t:?l) -> nil:1

tan(a)Tangent of real and complex numbers.(ri:2) -> ri:2

(?t:1) -> ?t:1

tanh(a)Hyperbolic tangent of real and complex numbers.(ri:2) -> ri:2

(?t:1) -> ?t:1

toHSVA(a)Conversion of an RGBA color value to HSVA.(rgba:4) -> hsva:4

toRA(arg)Conversion of rectangular coordinates to polar coordinates.(xy:2) -> ra:2

(ra:2) -> ra:2

toRGBA(a)Conversion of an HSVA color value to RGBA.(hsva:4) -> rgba:4

toXY(a)Conversion of polar coordinates to rectangular coordinates.(ra:2) -> xy:2

(xy:2) -> xy:2

voronoiCells(a)The Voronoi cell function, defined in three-dimensional space. Its values lie between -1 and 1.(?:3) -> nil:1