Welcome to the Turtorial
Patterning comes with a bult in 'turtle' to create lines.
Make sure you have the turtle included in your requirements :
[patterning.library.turtle :refer [basic-turtle]]
The turtle is set up with a default angle to turn, a default distance to move, and takes a string containing a sequence of moves and turns.
(basic-turtle start-position step initial-angle turning angle program-string leaf-map style)
For example :
(basic-turtle [-0.4 -0.4] 0.2 0 (/ PI 4) "FFFF+F+F+F+FFFFF+F+F+F+F"
{} {:stroke-weight 2
:stroke(p-color 100 50 100)})
In the program string "F" is a move-forward command, "+" is turn-right, "-" is turn left.
(basic-turtle [-0.4 -0.4] 0.2 0 (/ PI 4) "FFFF+F+F+F+FFFFF+F+F+F+F" {} {:stroke-weight 2, :stroke (p-color 100 50 100)})
The result of a turtle's drawing is a pattern that can be processed and combined just like any other in Patterning.
(four-mirror (clock-rotate 6 (basic-turtle [-0.7 -0.4] 0.1 0 (/ PI 4) "FFFF+F+F+F+FFFFF+F+F+F+F" {} {:stroke-weight 2, :stroke (p-color 100 50 100), :fill (p-color 200 150 200)})))
Recursion
The turtle also allows recursive branching.
Commands inside square-brackets are run as a "sub-turtle". When the square-brackets close, the turtle returns to the position before the sub-branch started.
In this example, the branch off to the left is drawn inside the square-brackets, then we return to the original
(basic-turtle [0 0.5] 0.2 (/ PI -2) (/ PI 4) "FFF[-F-F-F]F+F+F" {} {:stroke-weight 2, :stroke (p-color 100 50 100)})