Like formulas, classes can also have parameters and a title, which are declared in the default section. This matters only if the class is used by a plug-in parameter for a formula. Classes used by plug-in parameters are called plug-ins.
When used as a plug-in, 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 plug-ins 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 Writing plug-ins 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 be able to use this class as a plug-in and include its parameters in the parameter list for a formula, declare a plug-in parameter in the formula. A plug-in parameter is declared by a parameter block with a class as the parameter 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: Writing plug-ins
See Also
Classes
Parameter blocks
Function blocks
Headings