Like formulas, classes can also have parameters and a title, which are declared in the default section. This matters only if the class is in turn declared as a class parameter for a formula. In this case, the class appears in the list of parameters in the Layer Properties tool window, with the parameters for the class grouped with the title of the class. (See Example 1 - Formula classes for a screen shot.)
Here is a simple example of a class that implements a simple bailout condition for a Mandelbrot-like fractal formula. The bailout value is exposed as a parameter.
class Bailout {
public:
func Bailout()
; Empty constructor, see Extending class parameters
endfunc
bool func hasBailedOut(const complex z)
return |z| > @bailout
endfunc
default:
title = "Simple Bailout"
float param bailout
caption = "Bailout value"
default = 4
min = 1
endparam
}
To use this class and include its parameters in the parameter list for a formula, declare a class parameter in the formula. A class parameter is declared by a parameter block with the name of the class as its type.
MandelbrotTest {
init:
z = (0, 0)
Bailout bo = new @bailoutParam
loop:
z = sqr(z) + #pixel
bailout:
!bo.hasBailedOut(z)
default:
Bailout param bailoutParam
caption = "Bailout Test"
endparam
}
Notes
Next: Extending class parameters
See Also
Classes
Parameter blocks
Function blocks
Headings