Writing Scripts Part #2

In the first part I described a few functions, and how they work on one transform at a time. They
affect the selected transform by default, but you can make them affect a different transform by
using the SetActiveTransform method. I finished by showing you a "for loop" that steps through
all of the transforms used by a flame and changed them in some way.

As well as using the functions that I described you can set the parameters of the active transform
directly using what I'll call the "Transform interface". The transform interface has 10 parameters
(or "properties") that you can read or write to: a, b, c, d, e, f, Weight, Color and Variation. The
a to f properties give you access to the corresponding parameters that you see on the Transform
tab of the Transform editor. Weight corresponds to the "p" parameter. Color corresponds to the
Color parameter on the Color tab. You can write to the properties one at a time by using the
format...

Transform.a := 1.5;

If you pasted that line into an otherwise empty script editor and run it you'd see the "a" parameter
of the selected transform take on the value of 1.5. You can also use a "with block" to write to a
number of the Transform properties, like this...

with Transform do
begin
a := 1.5;
b := 0;
c := -1;
end;

The Color property only accepts values from 0 to 1 inclusive, and if you try to give it a value
outside that range no change will occur. The Weight property accepts values larger than 0 and
smaller than 1.

The Variation property is a bit different because it gives you access to the values of all of the
variations. It's an "array property" and uses an index...

Transform.Variation[x] := n;

...where x is the index of the variation that you want to change and n is the value that you want to
give it. The index goes from zero (for Linear) to 13 (for Folded). The variations values have to be
normalized (made so that altogether they add up to 1) so setting a single variation won't necessarily
give it the value you expect if other variations are non-zero. You can get around this by setting all
the variations to zero before setting re-setting the value...

for i := 0 to NVARS -1 do
Transform.Variation[i] := 0;
Transform.Variation[0] := 1;

...and now the Linear variation will be set to one. NVARS is a constant that gives the number of
variations in the current version of Apophysis. I use "NVARS - 1" rather than "13", so the script
will still work in future versions that have more variations (I'm not sure there will ever be any
more, but it's nice to be safe).

In the last part I mentioned that there was a way of moving the active transform around
predictably, and you do it by changing the transform's e and f properties.
Transform.e := Transform.e + 1; will always move the active transform one unit to the right.

So now I think I've shown you everything that works on existing transforms (more methods might
appear in the future), but you can add transforms to the flame by using the AddTransform and
CopyTransform methods.

AddTransform creates a new "identity" transform (the corresponding triangle will be the same
size and shape as the reference triangle) that uses only the Linear variation.. It will automatically
become the active transform, so any of the methods described so far will immediately apply to it.
Try this...