Skip to content

Commit 6a846a6

Browse files
feat: Turtle.FractalShrub ( Fixes #332 )
1 parent 432a929 commit 6a846a6

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

Types/Turtle/FractalShrub.ps1

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<#
2+
.SYNOPSIS
3+
Draws a Fractal Shrub
4+
.DESCRIPTION
5+
Draws a Fractal Shrub using an an L-System.
6+
7+
This is a modification of the fractal plant will less rotation
8+
.LINK
9+
https://en.wikipedia.org/wiki/L-system#Example_7:_fractal_plant
10+
.EXAMPLE
11+
turtle FractalShrub save ./FractalShrub.svg
12+
.EXAMPLE
13+
turtle FractalShrub morph save ./FractalShrubMorph.svg
14+
#>
15+
param(
16+
# The size of each segment
17+
[double]$Size = 42,
18+
# The order of magnitude (the number of times the L-system is expanded)
19+
[int]$Order = 4,
20+
# The angle of each segment
21+
[double]$Angle = -25
22+
)
23+
return $this.Rotate(-90).LSystem('-X', [Ordered]@{
24+
'X' = 'F[[X]X]F[FX]X'
25+
'F' = 'FF'
26+
}, $Order, [Ordered]@{
27+
'F' = { $this.Forward($Size) }
28+
#'\+' = { $this.Rotate($angle)}
29+
# '\-' = { $this.Rotate($angle * -1)}
30+
'\[' = { $this.Push().Rotate($angle) }
31+
'\]' = { $this.Pop().Rotate($angle * -1) }
32+
})

0 commit comments

Comments
 (0)