Skip to content

Commit f5213f3

Browse files
feat: Lucky turtle and random defaults ( Fixes #363, Fixes #366 )
Making StepSpiral a little _less_ random
1 parent 95d5890 commit f5213f3

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

Types/Turtle/StepSpiral.ps1

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,21 @@
1414
.EXAMPLE
1515
turtle @('StepSpiral',3, 120, 'rotate',120 * 3) save ./StepSpiralx3.svg
1616
.EXAMPLE
17-
turtle @('StepSpiral',3, 90, 'rotate',90 * 3) save ./StepSpiralx4.svg
17+
turtle @('StepSpiral',3, 90, 'rotate',90 * 4) save ./StepSpiralx4.svg
18+
.EXAMPLE
19+
turtle @('StepSpiral',3, -6, 0, (360/6 * 2), 'rotate',30 * (360/6))
20+
.EXAMPLE
21+
turtle @('StepSpiral',3, -60, 0, (360/60 * 2), 'rotate',60 * (360/60)) morph @(
22+
turtle @('StepSpiral',3, -60, 0, (360/60 * 2), 'rotate',60 * (360/60))
23+
turtle @('StepSpiral',2, 60, 0, (360/60 * 2), 'rotate',60 * (360/60))
24+
turtle @('StepSpiral',3, -60, 0, (360/60 * 2), 'rotate',60 * (360/60))
25+
) save ./StepSpiralSmoothMorph.svg
26+
.EXAMPLE
27+
turtle @('StepSpiral',3, -6, 0, (360/6 * 2), 'rotate',30 * (360/6)) morph @(
28+
turtle @('StepSpiral',3, -6, 0, (360/6 * 2), 'rotate',30 * (360/6))
29+
turtle @('StepSpiral',3, 6, 0, (360/6 * 2), 'rotate',30 * (360/6))
30+
turtle @('StepSpiral',3, -6, 0, (360/6 * 2), 'rotate',30 * (360/6))
31+
) save ./StepSpiralSmoothMorph.svg
1832
#>
1933
param(
2034
# The length of the first step
@@ -30,20 +44,23 @@ param(
3044
) | Get-Random
3145
),
3246
# The amount of change per step
33-
[double]$StepSize = $(Get-Random -Min 2.0 -Max 5.0),
47+
[double]$StepSize = 0,
3448
# The number of steps.
3549
[int]$StepCount = 0
3650
)
3751

3852
if ($Rotation -eq 0) { return $this }
3953

54+
if (-not $StepSize) {
55+
$StepSize = $Length * 2
56+
}
57+
4058
# If no step count was provided
4159
if ($StepCount -eq 0) {
42-
# pick a random number of rotations
43-
$revolutions = (Get-Random -Minimum 4 -Max 12)
60+
# we want to use a fixed number of steps
4461
# and figure out how many steps at our angle it takes to get there.
45-
46-
$StepCount = ($revolutions * 360)/$Angle
62+
$revolutions = 4
63+
$StepCount = [Math]::Ceiling(($revolutions*360)/$angle)
4764
}
4865

4966
# If the step size or count is negative

0 commit comments

Comments
 (0)