Skip to content

Commit e8bf05c

Browse files
feat: Turtle.Spider ( Fixes #289 )
1 parent 737cd86 commit e8bf05c

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

Types/Turtle/Spider.ps1

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<#
2+
.SYNOPSIS
3+
Draws a Spider
4+
.DESCRIPTION
5+
Draws a Spider using a Turtle.
6+
.NOTES
7+
This example was adapted from the Apple II Logo manual
8+
.EXAMPLE
9+
turtle spider
10+
.EXAMPLE
11+
turtle spider morph @(
12+
turtle spider 42 10
13+
turtle spider 42 15
14+
turtle spider 42 10
15+
) show
16+
.LINK
17+
https://logothings.github.io/logothings/AppleLogo.html
18+
#>
19+
param(
20+
# The size of each segment of the leg
21+
[double]
22+
$LegSize = 42,
23+
24+
# The rotation between each leg segment
25+
[double]
26+
$LegRotation = 10,
27+
28+
# The angle of the leg segment
29+
[double]
30+
$LegAngle = 90,
31+
32+
# The length of the head.
33+
# One quarter of this value will be the "neck"
34+
# One half of this value will be the "head"
35+
[double]
36+
$HeadLength = 2.5
37+
)
38+
39+
# Right legs
40+
$this = $this.Push()
41+
foreach ($legNumber in 1..4) {
42+
$this = $this.
43+
Push().
44+
Leg($LegSize, $LegAngle, $LegSize, $LegAngle).
45+
Pop().
46+
Rotate(-$LegRotation)
47+
}
48+
49+
# Reset our stack and flip to the other side
50+
$this = $this.Pop().Push().Rotate(180)
51+
52+
# Left legs
53+
foreach ($legNumber in 1..4) {
54+
$this = $this.
55+
Push().
56+
Leg($LegSize, -$LegAngle, $LegSize, -$LegAngle).
57+
Pop().
58+
Rotate($LegRotation)
59+
}
60+
61+
62+
return $this.Pop().Push().
63+
Rotate(90).
64+
Forward(-$HeadLength/4).
65+
Rotate(-90).
66+
Circle(-$HeadLength/2).
67+
Pop()

0 commit comments

Comments
 (0)