Skip to content

Commit 737cd86

Browse files
StartAutomatingStartAutomating
authored andcommitted
feat: Turtle.Leg ( Fixes #288 )
1 parent b785dbb commit 737cd86

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

Turtle.types.ps1xml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
<Name>ArcR</Name>
2828
<ReferencedMemberName>ArcRight</ReferencedMemberName>
2929
</AliasProperty>
30+
<AliasProperty>
31+
<Name>Arm</Name>
32+
<ReferencedMemberName>Leg</ReferencedMemberName>
33+
</AliasProperty>
3034
<AliasProperty>
3135
<Name>Back</Name>
3236
<ReferencedMemberName>Backward</ReferencedMemberName>
@@ -1660,6 +1664,56 @@ param(
16601664
$this.Rotate($Angle * -1)
16611665
</Script>
16621666
</ScriptMethod>
1667+
<ScriptMethod>
1668+
<Name>Leg</Name>
1669+
<Script>
1670+
&lt;#
1671+
.SYNOPSIS
1672+
Draws a arm or a leg
1673+
.DESCRIPTION
1674+
Instructs our Turtle to draw an arm or a leg.
1675+
1676+
Each segment of the arm or leg can be considered a pair of vectors.
1677+
1678+
Each pair will represent a leg length followed by a leg angle.
1679+
.EXAMPLE
1680+
turtle push leg 42 90 42 90 pop push rotate -15 leg 42 90 42 90 pop rotate -30 leg 42 90 42 90
1681+
.EXAMPLE
1682+
turtle rotate 90 rotate -15 push leg 21 15 pop rotate 30 push leg 21 -15 pop show
1683+
#&gt;
1684+
param()
1685+
1686+
$pairs = @()
1687+
$pair = @()
1688+
foreach ($arg in $args) {
1689+
if ($arg -is [ValueType]) {
1690+
if ($arg -is [Numerics.Vector2] -or
1691+
$arg -is [Numerics.Vector3] -or
1692+
$arg -is [Numerics.Vector4]
1693+
) {
1694+
$pair += $arg.X
1695+
$pair += $arg.Y
1696+
} else {
1697+
$pair += $arg
1698+
}
1699+
1700+
}
1701+
elseif ($arg -as [double]) {
1702+
$pair += $arg
1703+
}
1704+
if ($pair.Count -eq 2) {
1705+
$pairs += ,$pair
1706+
$pair = @()
1707+
}
1708+
}
1709+
1710+
foreach ($pair in $pairs) {
1711+
$this = $this.Forward($pair[0]).Rotate($pair[1])
1712+
}
1713+
return $this
1714+
1715+
</Script>
1716+
</ScriptMethod>
16631717
<ScriptMethod>
16641718
<Name>LevyCurve</Name>
16651719
<Script>

0 commit comments

Comments
 (0)