Writing plug-ins

Plug-in parameters make it easy to create different formulas with common features. What's even better is that you can write new plug-ins that can be used with the plug-in parameters in existing formulas.

If you load the MandelbrotTest example in Ultra Fractal, a Browse button is visible next to the name of the default plug-in in the list of parameters. This button enables the user to select a different plug-in, as long as it descends from the Bailout class. (See Example 1 - Formula plug-ins for an example.)

Let's write a new plug-in descending from the Bailout class that implements more bailout options:

class ExtendedBailout(Test.ufm:Bailout) {
public:
  bool func hasBailedOut(const complex z)
    return (@test == "mod" && |z| > @bailout) ||      \
      (@test == "real" && sqr(real(z)) > @bailout) || \
      (@test == "imag" && sqr(imag(z)) > @bailout)
  endfunc
default:
  title = "Extended Bailout"
  int param test
    caption = "Bailout Test"
    default = 0
    enum = "mod" "real" "imag"
  endparam
}

If you put this code in a plug-in library file (say Test.ulb), you can select the new plug-in by clicking on the Browse button next to the Bailout plug-in parameter. The MandelbrotTest formula will now use the bailout code from the ExtendedBailout class. As you can see, this system enables you to add new features to a formula even after it has been published, without having to modify the formula itself!

Next: Parameter forwards

See Also
Classes
Plug-in parameters
Inheritance
Overriding