Nothing really changed from the original version... two new rules:
A → B-A-B
B → A+B+A
And our starting axiom is A
.
Both A
and B
mean to draw forward at the current angle, -
means to turn left 60 degrees, and +
means turn right 60 degrees.
Iterations 1: B-A-B
Iteration 2: A+B+A-B-A-B-A+B+A
...
Tweaked the code a little to scale the canvas rather than changing the step length. To ensure it looks good I increase the line width by the inverse of the scale. Due to the way the rules are applied, the triangle is rendered inverted every other iteration. To compensate I use the iteration counter to flip the starting angle to keep it visible.