Skip to content

Commit 48531cd

Browse files
Merge pull request #127 from PowerShellWeb/turtle-upgrades
Turtle 0.1.4
2 parents 8a8b121 + 2bad1f9 commit 48531cd

36 files changed

+1259
-187
lines changed

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
## Turtle 0.1.4
2+
3+
* `Turtle` Upgrades
4+
* `turtle` will return an empty turtle (#112)
5+
* `turtle` now splats to script methods, enabling more complex input binding (#121)
6+
* `LSystem` is faster and more flexible (#116)
7+
* New Properties:
8+
* `get/set_Opacity` (#115)
9+
* `get/set_PathAnimation` (#117)
10+
* `get/set_Width/Height` (#125)
11+
* New Methods:
12+
* `HorizontalLine/VerticalLine` (#126)
13+
* `Petal` (#119)
14+
* `FlowerPetal` (#124)
15+
* `Spirolateral` (#120)
16+
* `StepSpiral` (#122)
17+
* Fixes:
18+
* `Turtle.Towards()` returns a relative angle (#123)
19+
20+
---
21+
122
## Turtle 0.1.3
223

324
* Fixing `Get-Turtle` inline sets (#108, #107)

Commands/Get-Turtle.ps1

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ function Get-Turtle {
8888
# We want to keep track of the current member,
8989
# and continue to the next word until we find a member name.
9090
$currentMember = $null
91-
$outputTurtle = $false
91+
# We want to output the turtle by default, in case we were called with no parameters.
92+
$outputTurtle = $true
9293

9394
# To do this in one pass, we will iterate through the words and arguments.
9495
# We use an indexed loop so we can skip past claimed arguments.
@@ -116,15 +117,13 @@ function Get-Turtle {
116117
}
117118
# Now we know how long it took to get to the next member name.
118119

119-
# And we can determine if we have any parameters
120+
# And we can determine if we have any parameters.
121+
# (it is important that we always force any parameters into an array)
120122
$argList =
121-
if ($methodArgIndex -eq ($argIndex + 1)) {
122-
@()
123-
}
124-
else {
123+
@(if ($methodArgIndex -ne ($argIndex + 1)) {
125124
$wordsAndArguments[($argIndex + 1)..($methodArgIndex - 1)]
126125
$argIndex = $methodArgIndex - 1
127-
}
126+
})
128127

129128
# Look up the member information for the current member.
130129
$memberInfo = $turtleType.Members[$currentMember]
@@ -145,8 +144,18 @@ function Get-Turtle {
145144
) {
146145
# If we have arguments,
147146
if ($argList) {
148-
# pass them to the method.
149-
$currentTurtle.$currentMember.Invoke($argList)
147+
# and we have a script method
148+
if ($memberInfo -is [Management.Automation.Runspaces.ScriptMethodData]) {
149+
# set this to the current turtle
150+
$this = $currentTurtle
151+
# and call the script, splatting positional parameters
152+
# (this allows more complex binding, like ValueFromRemainingArguments)
153+
. $currentTurtle.$currentMember.Script @argList
154+
} else {
155+
# Otherwise, we pass the parameters directly to the method
156+
$currentTurtle.$currentMember.Invoke($argList)
157+
}
158+
150159
} else {
151160
# otherwise, just invoke the method with no arguments.
152161
$currentTurtle.$currentMember.Invoke()

Examples/BoxFractal.svg

Lines changed: 2 additions & 1 deletion
Loading

Examples/EndlessBoxFractal.svg

Lines changed: 2 additions & 1 deletion
Loading

Examples/EndlessHilbert.svg

Lines changed: 2 additions & 1 deletion
Loading

0 commit comments

Comments
 (0)