防抖辅助绘画神器 —— Lazy Nezumi Pro 入门(十一)【L-sytem】

276 阅读3分钟

本文已参与掘金创作者训练营第三期「高产更文」赛道,详情查看:掘力计划|创作者训练营第三期正在进行,「写」出个人影响力

7、L 系统(L-System)

14.04.14 版本开始,Lazy Nezumi Pro 可以帮助你使用脚本引擎的 L-System 函数绘制复杂的形状和分形。之后会专门写一篇教程将逐步教你如何使用这些函数。所有函数和指令符号的参考表都可以在以下脚本参考表内找到。

如果你在 L-System 类别下查找脚本模式,你会发现程序可以自己绘制。它们使用了这里描述的特殊函数

  • 下表给出了所有可在脚本中使用的 L-System 函数
函数描述
lsysAxiom(string)Set the Axiom (starting state) of the system.
lsysRules(string)Set the Rules of the system, in the following format:[symbol]=[symbols],[symbol]=[symbols],...
lsysIterations(number)Set the number of times the system should be iterated before producing the final instruction string.
lsysDrawSymbols(string)Set the symbols (one after the other, without spaces or commas) that will cause the pen to move when encountered in the final instruction string. Other symbols will only be used to control the evolution of the system as it is iterated.
lsysDir(x, y)Set the pen's starting Direction vector. Default is (1, 0).
lsysAngle(angle)Set the starting Angle (in degrees) that will be used when processing a rotate (+ or -) instruction. Default is 90.
lsysAngleRandom(angle)Set the maximum angle (in degrees) that can be randomly added to the current Angle when processing a rotate instruction. Default is 0.
lsysAngleScale(factor)Set the Angle Scale Factor. Default is 1.2.
lsysAngleInc(inc)Set the Angle Increase Factor. Default is 5.
lsysThickness(thick)Set the starting line Thickness, between 0.0 and 1.0. Default is 1.0.
lsysThicknessRandom(factor)Set the percentage of current Thickness that can be randomly added when moving the pen position. Default is 0.
lsysThicknessScale(factor)Set the Thickness Scale Factor. Default is 2.0.
lsysThicknessInc(inc)Set the Thickness Increase Factor. Default is 0.1.
lsysLength(len)Set the starting line Length. Default is 1.0.
lsysLengthRandom(factor)Set the percentage of current Length that can be randomly added when moving the pen position. Default is 0.
lsysLengthScale(factor)Set the Length Scale Factor. Default is 1.3.
lsysLengthInc(inc)Set the Length Increase Factor. Default is 0.1.
lsysLoop(loop)If loop is 1, then lsysAdvance will wrap around to the start of the system's instruction string upon reaching the end. Otherwise, the pen position will no longer be updated. Default is 0.
lsysAdvance()Step through the system's instruction string until finding a Draw Symbol, at which point the pen's position is moved by the current Length in the current Direction. The new position is stored in the ox, oy variables, and the current thickness is stored in the op variable.
  • 下表描述了定义 L-system 公理和规则时可以使用的每个符号的功能。
符号指令
Any Draw SymbolMove the pen position by Length amount in the current Direction.
0-9Sets the current Skip Number (used with the  ?  symbol).
?Random Skip: Draw a random number between 0 and 10. If it is higher than the current Skip Number, then skip the next instruction.
:Skip the next instruction. You can use this to write statements like 5?A:B, where either A or B will be executed.
( )Open and close an Instruction Group. This lets you skip an entire group of instructions by writing something like 5?(AB):(CD) .
+Rotate the current Direction left by the set Angle amount, plus a random amount of which the maximum is set by lsysAngleRandom.
-Rotate the current Direction right by the set Angle amount, plus a random amount of which the maximum is set by lsysAngleRandom.
Reverse direction (rotate 180 degrees).
.Exchange meaning of  +  and -.
!Divide Thickness by Thickness Scale Factor.
@Multiply Thickness by Thickness Scale Factor.
#Decrease Thickness by Thickness Increase Factor.
$Increase Thickness by Thickness Increase Factor.
%Divide Length by Length Scale Factor.
Multiply Length by Length Scale Factor.
&Decrease Length by Length Increase Factor times Start Length.
*Increase Length by Length Increase Factor times Start Length.
{Divide Angle by Angle Scale Factor.
}Multiply Angle by Angle Scale Factor.
<Decrease Angle by Angle Increase Factor.
Increase Angle by Angle Increase Factor.
[Save the state and start a new Branch.
]End the current Branch and restore the state.