3

I need help on Tikz lindenmayersystem library. In this topic, JLDiaz presented a solution to draw segments of several lengths thanks to the command:

\symbol{S}{\pgflsystemstep=0.6\pgflsystemstep}

Is there a way to do the same thing with angles? I would like to use + or - 60 degree rotation and + or - 85 degree rotation to draw my figure.

I've tried:

\documentclass[tikz]{standalone}
\usepackage{tikz}

\usetikzlibrary{lindenmayersystems}

\begin{document}

\begin{tikzpicture}
\pgfdeclarelindenmayersystem{mySystem}{
    \symbol{a}{\pgflsystemleftangle = 60}
    \symbol{b}{\pgflsystemrightangle = 60}
  \rule{X -> FaF+F-F-F+FbF}
}

\draw  [l-system={mySystem, step=10pt, angle=85, axiom=X, order=1}]
  lindenmayer system ;
\end{tikzpicture}

\end{document}

without any success: "a" and "b" symbol are ignored.

Could you help me on this? Thank you!

2

You need to use \def\pgflsystemleftangle{60} or \def\pgflsystemrightangle{60} (note that the manual has some typos and inserts and extra r in the macro names in a couple of places). You can set them both at once with a custom macro as I have done below. Note that the angle remains changed in the current scope.

\documentclass[tikz]{standalone}
\usepackage{tikz}

\usetikzlibrary{lindenmayersystems}
\def\pgflsystemsetangle#1{%
  \def\pgflsystemleftangle{#1}%
  \def\pgflsystemrightangle{#1}%
}
\begin{document}

\begin{tikzpicture}
\pgfdeclarelindenmayersystem{mySystem}{
    \symbol{a}{\pgflsystemsetangle{30}}
    \symbol{b}{\pgflsystemsetangle{60}}
    \symbol{c}{\pgflsystemsetangle{90}}
  \rule{X -> Fa+Fb+Fc+Fa-Fb-Fc-F}
}

\draw  [l-system={mySystem, step=10pt, angle=85, axiom=X, order=1}]
  lindenmayer system ;
\end{tikzpicture}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.