论坛 分形艺术软件 Apophysis (超强的IFS算法渲染技术)
|
本版斑竹:shor luoyx2008 |
| 帖子列表 | 原创作品 | 共享资源 |
Writing Scripts Part #1Load the script editor and press the New button at the top of the toolbar. Running a blank script
will force the main flame to recalculate, but nothing will change. Before you go any further load
the transform editor and position it so that you can watch it as you run scripts. Type "Rotate(45);"
(without the quotes, but take note of the semi-colon at the end) into the script editor and press
the Run button. You'll see the triangle that's selected in the transform editor rotate by 45 degrees.
If you keep hitting the Run button the triangle will continue to rotate until it gets back its starting
point.
By default scripts are set up to operate on the selected transform, and there are a number of
functions that you can use to change it.
Here the documentation is going to get fuzzy because the functions mentioned so far use matrix
multiplication, and I'm not up to explaining that at the moment (if I ever will be!). One thing that
it means is that the order of operations is important. Translate(1, 1) will move a triangle of the
same size and position as the reference triangle one unit to the right and one unit upward, but if
you've already scaled the transform by 0.5 then it would only move the transform half a unit to the
right, and half a unit upward. Transforms with triangles that are off to the side, rotated and scaled
arbitrarily, will move in an unpredictable manner. There is a way to move transforms predictably,
but I'll get to that later.
These functions can operate on any transform in the flame, not just the one selected in transform
editor, but you have to tell the script which one you want to be the "active transform". You do this
with the SetActiveTransform method. The format is...
SetActiveTransform(i);
...where i is the index of the transform that you intend to alter. Indexing starts from zero, so to
work on the transform that is labeled 1 in the transform editor you would type
"SetActiveTransform(0);". Once you've done that all further operations will affect only that
transform, until you call SetActiveTransform again with a different index.
Usually you wouldn't use SetActiveTransform with a fixed number (a "constant"), but with a
variable that changes as the script progresses. You see this in most of the example scripts I
supplied. Here's how you would perform the same operation on all of the transforms in a flame
(in this case scaling):
for i := 0 to Transforms - 1 do
begin
SetActiveTransform(i);
Scale(1.1);
end;
You can copy that and paste it into the script editor to see what is does, if you like (there's a
pop-up menu in the script editor with a paste function--Ctrl+V won't work, but Shift+Insert
will). You could also try changing Scale to one of the other functions I've mentioned, or put a
few of them in there (make sure they come after the SetActiveTransform statement, and before the
"end", and don't forget to put the semi-colon at the end of the line).
From http://www.apophysis.org/tutorials/scripts1.html
| <<上一页 1 下一页>> | |||
![]() 注册: 2009-11-10 积分: 452 分 等级: ![]() 向你致敬 |
2009-11-11 00:30:15 #1
黑夜里的乌鸦! |
||
| <<上一页 1 下一页>> | |||