Skip to content

Commit 658dc03

Browse files
StartAutomatingStartAutomating
authored andcommitted
feat: Turtle.FractalShrub ( Fixes #332 )
1 parent 6a846a6 commit 658dc03

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

Turtle.types.ps1xml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,6 +1433,43 @@ return $this.Rotate(-90).LSystem('-X', [Ordered]@{
14331433
'\-' = { $this.Rotate($angle * -1)}
14341434
'\[' = { $this.Push() }
14351435
'\]' = { $this.Pop() }
1436+
})
1437+
</Script>
1438+
</ScriptMethod>
1439+
<ScriptMethod>
1440+
<Name>FractalShrub</Name>
1441+
<Script>
1442+
&lt;#
1443+
.SYNOPSIS
1444+
Draws a Fractal Shrub
1445+
.DESCRIPTION
1446+
Draws a Fractal Shrub using an an L-System.
1447+
1448+
This is a modification of the fractal plant will less rotation
1449+
.LINK
1450+
https://en.wikipedia.org/wiki/L-system#Example_7:_fractal_plant
1451+
.EXAMPLE
1452+
turtle FractalShrub save ./FractalShrub.svg
1453+
.EXAMPLE
1454+
turtle FractalShrub morph save ./FractalShrubMorph.svg
1455+
#&gt;
1456+
param(
1457+
# The size of each segment
1458+
[double]$Size = 42,
1459+
# The order of magnitude (the number of times the L-system is expanded)
1460+
[int]$Order = 4,
1461+
# The angle of each segment
1462+
[double]$Angle = -25
1463+
)
1464+
return $this.Rotate(-90).LSystem('-X', [Ordered]@{
1465+
'X' = 'F[[X]X]F[FX]X'
1466+
'F' = 'FF'
1467+
}, $Order, [Ordered]@{
1468+
'F' = { $this.Forward($Size) }
1469+
#'\+' = { $this.Rotate($angle)}
1470+
# '\-' = { $this.Rotate($angle * -1)}
1471+
'\[' = { $this.Push().Rotate($angle) }
1472+
'\]' = { $this.Pop().Rotate($angle * -1) }
14361473
})
14371474
</Script>
14381475
</ScriptMethod>

0 commit comments

Comments
 (0)