| 1 |
% Copyright 2018 by Mark Wibrow |
| 2 |
% |
| 3 |
% This file may be distributed and/or modified |
| 4 |
% |
| 5 |
% 1. under the LaTeX Project Public License and/or |
| 6 |
% 2. under the GNU Public License. |
| 7 |
% |
| 8 |
% See the file doc/generic/pgf/licenses/LICENSE for more details. |
| 9 |
|
| 10 |
\usepgflibrary{lindenmayersystems}% |
| 11 |
|
| 12 |
\def\tikz@@lsystem-system{% |
| 13 |
\pgfutil@ifnextchar[{\tikz@lsystem@options}{\tikz@lsystem@options[]}}% |
| 14 |
|
| 15 |
\def\tikz@lsystem indenmayer system{% |
| 16 |
\pgfutil@ifnextchar[{\tikz@lsystem@options}{\tikz@lsystem@options[]}}% |
| 17 |
|
| 18 |
\def\tikz@lsystem@options[#1]{% |
| 19 |
\tikzset{#1}% |
| 20 |
\ifx\tikz@lsystem@rules\pgfutil@empty% |
| 21 |
\else% |
| 22 |
\tikz@lsystem@declare% |
| 23 |
\def\tikz@lsystem@name{tikz@temp}% |
| 24 |
\fi% |
| 25 |
\ifx\tikz@lsystem@anchor\pgfutil@empty% |
| 26 |
\pgfpathmoveto{\pgfqpoint{\tikz@lastxsaved}{\tikz@lastysaved}}% |
| 27 |
\pgflindenmayersystem{\tikz@lsystem@name}{\tikz@lsystem@axiom}{\tikz@lsystem@order}% |
| 28 |
\else% |
| 29 |
\pgfextract@process\tikz@lsystem@pos{\pgfqpoint{\tikz@lastxsaved}{\tikz@lastysaved}}% |
| 30 |
\setbox\pgfnodeparttextbox=\hbox{% |
| 31 |
\pgfinterruptpicture% |
| 32 |
\pgfpicture% |
| 33 |
\pgfpathmoveto{\pgfpointorigin}% |
| 34 |
\pgflindenmayersystem{\tikz@lsystem@name}{\tikz@lsystem@axiom}{\tikz@lsystem@order}% |
| 35 |
\begingroup% |
| 36 |
\tikz@finish% |
| 37 |
\endpgfpicture% |
| 38 |
\endpgfinterruptpicture% |
| 39 |
}% |
| 40 |
{% |
| 41 |
\pgftransformshift{\tikz@lsystem@pos}% |
| 42 |
\tikzset{inner sep=0pt, outer sep=0pt, minimum size=0pt}% |
| 43 |
\pgfmultipartnode{rectangle}{\tikz@lsystem@anchor}{lindenmayer system}{\pgfusepath{discard}}% |
| 44 |
}% |
| 45 |
\fi% |
| 46 |
\tikz@scan@next@command}% |
| 47 |
|
| 48 |
\tikzset{% |
| 49 |
lindenmayer system/.style={/pgf/lindenmayer system/.cd, #1,/tikz/.cd}, |
| 50 |
l-system/.style={lindenmayer system={#1}}, |
| 51 |
}% |
| 52 |
\pgfkeys{/pgf/lindenmayer system/.cd, |
| 53 |
name/.code=\edef\tikz@lsystem@name{#1}\let\tikz@lsystem@rules=\pgfutil@empty,% |
| 54 |
axiom/.store in=\tikz@lsystem@axiom,% |
| 55 |
order/.store in=\tikz@lsystem@order, |
| 56 |
.unknown/.code={% |
| 57 |
\pgfutil@ifundefined{pgf@lsystem@\pgfkeyscurrentname}{% |
| 58 |
\pgfkeys{/errors/unknown key={/pgf/lindenmayer system/\pgfkeyscurrentname}{#1}}% |
| 59 |
\let\tikz@lsystem@name=\pgfutil@empty% |
| 60 |
}% |
| 61 |
{\edef\tikz@lsystem@name{\pgfkeyscurrentname}} |
| 62 |
},% |
| 63 |
anchor/.store in=\tikz@lsystem@anchor,% |
| 64 |
rule set/.store in=\tikz@lsystem@rules |
| 65 |
}% |
| 66 |
\let\tikz@lsystem@anchor=\pgfutil@empty% |
| 67 |
\let\tikz@lsystem@rules=\pgfutil@empty% |
| 68 |
|
| 69 |
\def\tikz@lsystem@declare{% |
| 70 |
\expandafter\let\csname pgf@lsystem@tikz@temp\endcsname=\relax% |
| 71 |
\pgfdeclarelindenmayersystem{tikz@temp}{% |
| 72 |
\expandafter\tikz@lsystem@parse@rules\tikz@lsystem@rules,\tikz@stop,% |
| 73 |
}% |
| 74 |
}% |
| 75 |
\def\tikz@lsystem@parse@rules#1,{% |
| 76 |
\ifx#1\tikz@stop% |
| 77 |
\else% |
| 78 |
\rule{#1}% |
| 79 |
\expandafter\tikz@lsystem@parse@rules% |
| 80 |
\fi% |
| 81 |
}% |