Process statements
Process statement defines processing of L-system with process configuration.
Basic process statement
Basic syntax of process statement is process LsystemName with ConfigurationName;
where LsystemName
is name of processed L-system and ConfigurationName
is name of used process configuration. There are predefined process configurations that can be used right away. One of them is SymbolPrinter
which will print all symbols of L-system.
Input
1 2 3 4 5 | // process statements example 01 lsystem LsystemA { set symbols axiom = LsystemA; } process LsystemA with SymbolPrinter; |
Output
LsystemA
Processing all defined L-systems
If there are more L-systems and we want to render them all we can write one process statement for each L-system or we can just use all
to process all defined (non-abstract) L-systems.
Input
1 2 3 4 5 6 7 8 9 10 11 | // process statements example 02 abstract lsystem LsystemA { set symbols axiom = LsystemA; } lsystem LsystemB { set symbols axiom = LsystemB; } lsystem LsystemC { set symbols axiom = LsystemC; } process all with SymbolPrinter; |
Output
LsystemB
LsystemC
Passing arguments to processed L-systems
If L-system has some parameters it is possible to pass arguments to them with process statement.
Input
1 2 3 4 5 6 7 8 9 10 | // process statements example 03 lsystem ParameterizedLsystem(x = 0, i = 1) { set symbols axiom = A; set iterations = i; rewrite A to X(x) A; } process ParameterizedLsystem(5, 5) with SymbolPrinter; process ParameterizedLsystem(4) with SymbolPrinter; process all(2, 2) with SymbolPrinter; process ParameterizedLsystem with SymbolPrinter; |
Output
X(5) X(5) X(5) X(5) X(5) A
X(4) A
X(2) X(2) A
X(0) A
Adding additional L-system statements to process statement
If you need to process L-system with minor changes you can write L-system statements after process statement. You can only write following statements: component property assign, rewrite rule and interpretation definition. Behavior is the same as if you will derive processed L-system and written statements to child L-system.
This can be used in L-system gallery in thumbnail source. you can just invoke original L-system with for example lower iteration number.
Input
1 2 3 4 5 6 7 8 9 10 11 | // process statements example 04 lsystem Lsystem { set symbols axiom = A; set iterations = 2; rewrite A to X A; } process Lsystem with SymbolPrinter set iterations = 10; process Lsystem with SymbolPrinter set symbols axiom = B B rewrite B to X B; |
Output
X X X X X X X X X X A
X X B X X B
Specifying components for containers
In process statement components in containers in process configurations can be specified. By default each container have specified default component but definition will override it. To be able to assign component to container component type must be compatible with container's type.
Input
1 2 3 4 5 6 7 8 9 | // process statements example 05 lsystem Lsystem { set symbols axiom = F; set iterations = 2; interpret F as DrawForward(10); rewrite F to F + F; } process Lsystem with SvgRenderer use DebugRenderer2D as Renderer; |
Output
InitializeState|0,0|2|0,0,0,0 DrawTo|10,0|2|0,0,0,0 DrawTo|20,0|2|0,0,0,0 DrawTo|30,0|2|0,0,0,0 DrawTo|40,0|2|0,0,0,0
You can use DebugRenderer3D
instead of ThreeJsSceneRenderer3D
or InterpreterCallerDebugger
instead of InterpreterCaller
.
Formal grammar
1 2 3 4 5 6 7 | process_statement = 'process' name params? 'with' ID use_components* ';' name = 'all' | ID params = '(' ( expression (',' expression)+ )? ')' use_components = 'use' ID 'as' ID |