Dedechild
Dedechild

Reputation: 21

Spacefilling Turtle Curve with Tikz

I'm trying to draw some space-filling curves with tikz and the Lindenmayer system.
My goal was this curve:

Goal

So I tried it out:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary[lindenmayersystems]

\begin{document}

\pgfdeclarelindenmayersystem{Turtle}{
 \rule{L -> +FFFF-FR}   %rule 1
 \rule{R -> -FFFF+FL}   %rule 2
}
\begin{tabular}{cc}
\begin{tikzpicture}
 \shadedraw [bottom color=white, top color=white, draw=black]
 [l-system={Turtle, axiom=L, order=6, step=0.25cm, angle=90}]
 lindenmayer system;
\end{tikzpicture}
\end{tabular}

\end{document}

For "order=6" this results in: Curve with Order 6

This should be the third picture in the first row of the first picture.
But when i tried it out, I ran into 2 Problems: \

  1. I don't want that last little line at the bottom right. \
  2. Rule 1 and Rule 2 are not filling up a space, but rather building a curve which keeps on getting longer and longer for bigger orders.

So my question is, is there a rule for which I get my space-filling curve which are dependend on the order? Or can this be done without the depency of the order?

As an aditional task I also tried to get a grid in the background, so that I get cells size is equal to a step, but I did not get the scale right, when I wanted to make in dependent on the order. I tried it with

...
lindenmayer system;
\draw[step=0.25cm, gray, very thin] (0,0) grid (1,1);
...

But just as before, this does not scale and we can clearly see how the curve does not fill up this space (grid):

Curve with grid

Can anybody help me or give me advise?

Upvotes: 2

Views: 92

Answers (0)

Related Questions