Example 1 - Formula classes

Tip: This example assumes that you are familiar with Ultra Fractal basics as explained in the tutorials.

As a first example of how classes work in practice, let's take a look at some of the standard classes that come with Ultra Fractal.

    First, use the browser to open the Default parameter set in Examples.upr.
 

Click the Browse button in the Formula tab of the Layer Properties tool window to select Generic Formula in Standard.ufm.

Generic Formula is a "skeleton" formula that lets a class implement the actual fractal formula behavior. It has just one class parameter called Fractal Formula which is set to the Mandelbrot class by default:

The Mandelbrot class has its own parameters like Starting point, which appear grouped with the class parameter. Let's select a different formula class.

 

Click the Browse button for the Fractal Formula class parameter to select a new class. This opens the browser in class mode, so it shows only those classes that are compatible with this class parameter.

Locate the Newton class in Standard.ulb and click OK.

Now, a Newton fractal appears instead of a Mandelbrot fractal. Anyone could write a formula class that works with Generic Formula to create a different fractal, without having to modify Generic Formula itself. Of course, this doesn't really do anything new, since you could also just write a new fractal formula. But it does make the formula behavior available in a generic form.

  Click the Browse button for the Fractal Formula class parameter again, and this time, select the Slope class.
 

Briefly go to the Outside tab of the Layer Properties and click the Browse button there to select the Lighting coloring algorithm. Then go back to the Formula tab again.

The combination of the Slope formula class and the Lighting coloring algorithm creates a 3D lighting effect. Previously, there were three different Slope formulas for Mandelbrot, Julia, and Newton fractals (these are still in Standard.ufm). Each of these formulas duplicates the code for the lighting effect; the only different code is the where the actual fractal formula calculation is done. Adding a new fractal type could only be done by creating yet another variation of this formula.

However, now the Slope formula class contains another class parameter that enables you to select the internal fractal formula. You can select any formula class, just like with Generic Formula.

 

Click the Browse button for the Fractal Formula class parameter inside the Slope class (which currently is set to Mandelbrot) and select Phoenix (Mandelbrot) instead.

Suddenly, we have a Slope formula that works with any fractal type. New fractal types can be added simply by writing them as a formula class, which makes them available for Generic Formula, Slope, or any other place where a fractal formula can be inserted.

Next: Example 2 - Orbit trap classes

See Also
About classes
Fractal formulas
Writing formulas