Thursday 24 January 2008

Tip: Functions.asc

Is there a script or fragment thereof that's re-usable elsewhere? If you have such a thing, then it's possible to call it from other scripts by naming and storing in your Functions.asc script file that comes with the program and resides in you scripts folder. Open Functions.asc: you should see:

{**********************************}
{ Functions and procedures for use }
{ by other scripts. }
{**********************************}
procedure CalculateColors;
{ Spreads the color parameters evenly }
begin
for i := 0 to Transforms - 1 do
begin
SetActiveTransform(i);
Transform.Color := i / (Transforms - 1);
end
end;

As an example, copy the following into the file and save.

procedure FineGradient;
For i := 0 to 255 do
Begin
For j := 0 to 2 do
Begin
Flame.Gradient[i][j] := trunc(31+random*191) ;
End
End;

To prove that it works, open the script editor (Ctrl-D) and click on the 'New' icon (top of right-hand panel). Type, or copy and paste, FineGradient and click on the 'Run' icon (green triangle) - your current gradient will be replaced by a 256-band brightly-coloured one.

Troubleshooting: if it doesn't work, check that Functions.asc is selected in Options, Paths, Function library

No comments: