File tree Expand file tree Collapse file tree 2 files changed +24
-8
lines changed
Expand file tree Collapse file tree 2 files changed +24
-8
lines changed Original file line number Diff line number Diff line change 1- if ($this .' .Stack' -isnot [Collections.Stack ]) {
2- return
3- }
1+ <#
2+ . SYNOPSIS
3+ Pops the Turtle Stack
4+ . DESCRIPTION
5+ Pops the Turtle back to the last location and heading in the stack.
46
5- if ($this .' .Stack' .Count -eq 0 ) {
6- return
7- }
7+ By pushing and popping, we can draw multiple branches.
8+ . EXAMPLE
9+ # Draws a T shape by pushing and popping
10+ turtle rotate -90 forward 42 push rotate 90 forward 21 pop rotate -90 forward 21 show
11+ #>
12+ if ($this .' .Stack' -isnot [Collections.Stack ]) { return }
13+
14+ if ($this .' .Stack' .Count -eq 0 ) { return }
815
916$popped = $this .' .Stack' .Pop()
10- $this.PenUp ().Goto($popped.Position.X , $popped.Position.Y ).PenDown()
17+ $null = $ this.PenUp ().Goto($popped.Position.X , $popped.Position.Y ).PenDown()
1118$this.Heading = $popped.Heading
1219return $this
Original file line number Diff line number Diff line change 1+ <#
2+ . SYNOPSIS
3+ Pushes the Turtle Stack
4+ . DESCRIPTION
5+ Pushes the current state of this Turtle onto a stack.
6+
7+ If this stack is popped, the Turtle will teleport back to the location where it was pushed.
8+
9+ By pushing and popping, we can draw multiple branches.
10+ #>
111if (-not $this .' .Stack' ) {
212 $this | Add-Member NoteProperty ' .Stack' ([Collections.Stack ]::new()) - Force
313}
4-
514$this .' .Stack' .Push(@ {
615 Position = [Ordered ]@ {X = $this.Position.X ;Y = $this.Position.Y }
716 Heading = $this.Heading
You can’t perform that action at this time.
0 commit comments