Parameters

Parameters are used to allow users to customize formulas without needing to rewrite them. Parameters are used just like variables, with two exceptions: you cannot write to them, and you must prefix them with the @ character (so the compiler can determine they are parameters instead of variables). Here is an example that uses a parameter:

Mandelbrot {
init:
  z = 0
loop:
  z = z^@power + #pixel
bailout:
  |z| < 4
}

The parameter used here is @power. In the Formula tab, the user can now enter a value for this parameter and view the Mandelbrot set of any power using just one formula.

By default, the type of a parameter is complex. You can change that by adding a param block to the default section of your formula and providing the necessary settings. Using the param block, you can also specify enumerated parameters. With enumerated parameters, the user does not have to enter a numerical value, but rather chooses an item from a drop-down list.

It is also possible to use user functions. These can be used just like normal functions, with the exception that the user can choose the actual function from a list of all available built-in functions. Here is an example with a user function:

Mandelbrot {
init:
  z = 0
loop:
  z = @myfunc(z) + #pixel
bailout:
  |z| < 4
}

Now, the user can use sqr, but also sin and cos and many other functions with this formula. You can customize the behavior of the user function using the func block in the default section.

Notes

Next: Arrays

See Also
Providing help and hints
Writing direct coloring algorithms