Package: lfract
L-System Fractal GeneratorAn open-source CLI software for generating fractal images using the L-System.FeaturesRewrite and draw a 2D deterministic context-free L-System. (D0L)Support the following turtle commands:CommandDescriptionFDraw a line forwarddpixels in the current headingfMove forwarddpixels in the current heading without drawing a line+Turn right byδdegrees-Turn left byδdegrees[Push the current turtle's state into a stack]Pop a turtle's state out of the stackSupport saving and previewing the output imageSupport changing the drawing line's widthBackgroundL-System (Lindenmayer System) is a string rewriting system that uses an iterative process. An L-System starts withan axiom, an initial string, that will be rewritten following a set ofproduction ruleswhich contains pairs ofpredecessorsandsuccessors. For each iteration, each symbol or character will be replaced with its corresponding successor. Any symbols without a production rule will be replaced by themselves. For example,Axiom:NProduction Rules:PredecessorSuccessorNMNOO#Iteration 0:NIteration 1:MNOIteration 2:MMNO#Iteration 3:MMMNO##For illustration,lfractreserves some characters for controlling a drawing pen calleda turtle. The turtle keeps track of its position and heading throughout the evaluation process. After some finite number of iterations, the resulting string will be evaluated and an image will be drawn. (Supported turtle commands are listed in the previous section)The current version oflfractsupports only the deterministic and context-free version of the L-System. That is each rule has a probability of being applied of 1 and the location of each symbol in a string relative to other symbols doesn't matter.InstallationThis software is available to download on The Python Package Index (PyPI) and can be installed throughpip.Start by making sure thatpipis installed and up-to-datepython -m pip install --upgrade pipRun the following command on your terminalpip install lfractUsageInvokes the program usinglfract. There are seven optional arguments as follows:OptionDescription-x, --axiomInitial string or axiom, required-r, --rulesProduction rules. Uses "->" to seperate predecessor from successor, optional-a, --angleTurning angle,δ(degrees), default = 90-d, --distDistance,d(pixels), default = 100-n, --itersNumber of iterations, default = 0-o, --outputOutput path. If specified, the image will be saved to the given path, optional-w, --widthWidth of the drawing pen (pixels), default = 1The user must provide at least an axiom or the initial string to the L-System. All predecessors in the set of production rules must be unique. If there are duplicates,lfractwill use the latest rule.For the full usage description oflfract, type:lfract --helpExamplesHilbert curve by Prusinkiewicz and Hanan [1]lfract -x X -r X->-YF+XFX+FY- Y->+XF-YFY-FX+ -a 90 -d 50 -n 5 -w 5Hexagonal tiling by Prusunkiewicz and Hanan [1]lfract -x X -r X->[-F+F[Y]+F][+F-F[X]-F] Y->[-F+F[Y]+F][+F-F-F] -a 60 -d 50 -n 10 -w 4A fractal by Surasith Boonaneksaplfract -x A -r A->fB+AF+Fff+Bf B->Bf-FffF-FfA-Afff -a 120 -n 7 -d 50 -w 5Noteslfractadopts the L-System formal definition from [1]. It also follows the terminologies used in [1][2][3].Symbols in the L-System can be any Unicode characters.Currently not support:Stochastic L-SystemContext-sensitive L-SystemParametric L-SystemDependencyPillow 4.0.0 (Depending on the Python's version, a more recent version may be required. CheckPillow's documentation)LicenseMITReferences[1]: Prunsinkiewicz, Przemyslaw and Hanan, James; "Lecture Notes in Biomathematics: Lindenmayer Systems, Fractals, and Plants"link[2]: Wikipedia; "L-system"link[3]: Santel, Jordan; "L-systems"link