Skip to content

Commit 653d229

Browse files
feat: Lucky turtle and random defaults ( Fixes #363, Fixes #366 )
1 parent 4f96920 commit 653d229

17 files changed

+145
-50
lines changed

Types/Turtle/Alias.psd1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
# Common transposition errors
5252
FlowerStar = 'StarFlower'
5353
FlowerGolden = 'GoldenFlower'
54+
PetalFlower = 'FlowerPetal'
5455

5556
# Technically accurate aliases to more helpful names
5657
Href = 'Link'

Types/Turtle/Arc.ps1

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
param(
1212
# The X Radius of the arc.
1313
[double]
14-
$RadiusX,
14+
$RadiusX = $(Get-Random -Min -42 -Max 42),
1515

1616
# The Y Radius of the arc.
1717
[double]
18-
$RadiusY,
18+
$RadiusY = $(Get-Random -Min -42 -Max 42),
1919

2020
# The rotation along the x-axis.
2121
[double]
@@ -25,22 +25,26 @@ $Rotation = 0,
2525
# If set to 0, will draw a small arc
2626
[ValidateSet(0,1, "Large", "Small", $true, $false)]
2727
[PSObject]
28-
$IsLargeArc = 1,
28+
$IsLargeArc = $(1,0 | Get-Random),
2929

3030
# By default, the arc will be drawn clockwise
3131
# If this is set to 1, the arc will be drawn counterclockwise
3232
# If set to 1, will draw an arc counterclockwise
3333
[ValidateSet(0, 1, 'Clockwise','CounterclockWise', 'cw', 'ccw', $true, $false)]
3434
[PSObject]
35-
$IsCounterClockwise = 0,
35+
$IsCounterClockwise = $(1,0 | Get-Random),
3636

3737
# The deltaX
3838
[double]
39-
$DeltaX,
39+
$DeltaX = $(
40+
(Get-Random -Min 42 -Max 84) * (1,-1 | Get-Random)
41+
),
4042

4143
# The deltaY
4244
[double]
43-
$DeltaY
45+
$DeltaY = $(
46+
(Get-Random -Min 42 -Max 84) * (1,-1 | Get-Random)
47+
)
4448
)
4549

4650
if ($DeltaX -or $DeltaY) {

Types/Turtle/ArcLeft.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
param(
1212
# The radius of a the circle, were it to complete the arc.
1313
[double]
14-
$Radius = 10,
14+
$Radius = (Get-Random -Min 42 -Max 84),
1515

1616
# The angle of the arc
1717
[double]
18-
$Angle = 60
18+
$Angle = (Get-Random -Min 30 -Max 90)
1919
)
2020

2121
# Rather than duplicate logic, we will simply reverse the angle

Types/Turtle/ArcRight.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
param(
1212
# The radius of a the circle, were it to complete the arc.
1313
[double]
14-
$Radius = 10,
14+
$Radius = (Get-Random -Min 42 -Max 84),
1515

1616
# The angle of the arc
1717
[double]
18-
$Angle = 60,
18+
$Angle = (Get-Random -Min 30 -Max 90),
1919

2020
# The number of steps. If not provided, will default to half of the angle.
2121
[int]

Types/Turtle/Backward.ps1

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@
44
.DESCRIPTION
55
Moves the turtle backwards by a specified distance.
66
.EXAMPLE
7-
Move-Turtle Forward 10 |
8-
Move-Turtle Backward 5 |
9-
Move-Turtle Rotate 90 |
10-
Move-Turtle Forward 20 |
11-
Save-Turtle ./DrawT.svg
7+
turtle id 'tshape' forward 10 backward 5 rotate 90 forward 20
128
#>
139
param(
1410
# The distance to move backwards
1511
[double]
16-
$Distance = 10
12+
$Distance = (Get-Random -Min 10 -Max 100)
1713
)
1814

1915
$this.Forward($Distance * -1)

Types/Turtle/BarGraph.ps1

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,22 @@ param(
4343
[double[]]$Points
4444
)
4545

46+
if ($width -and -not $Height) {
47+
$height = $width
48+
} elseif ($height -and -not $Width) {
49+
$width = $height
50+
} elseif (-not $width -and -not $height) {
51+
$width = (Get-Random -Min 10 -Max 100) * (1,-1| Get-Random)
52+
$height = (Get-Random -Min 10 -Max 100)
53+
}
54+
4655

4756
# If there were no points, we are drawing nothing, so return ourself.
48-
if (-not $points) { return $this}
57+
if (-not $points) {
58+
$points = foreach ($n in 1..(Get-Random -Min 4 -Max 20)) {
59+
Get-Random -Min 0 -Max 100
60+
}
61+
}
4962

5063
# Divide the width by the number of points to get a very snug bar graph
5164
$barWidth = $width / $points.Length

Types/Turtle/BezierCurve.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,19 @@
2626
param(
2727
# The X control point
2828
[double]
29-
$ControlX,
29+
$ControlX = (Get-Random -Max 42),
3030

3131
# The Y control point
3232
[double]
33-
$ControlY,
33+
$ControlY = (Get-Random -Max 42),
3434

3535
# The delta X
3636
[double]
37-
$DeltaX,
37+
$DeltaX = (Get-Random -Min 0 -Max 100),
3838

3939
# The delta Y
4040
[double]
41-
$DeltaY
41+
$DeltaY = (Get-Random -Min 0 -Max 100)
4242
)
4343

4444

Types/Turtle/BoardFractal.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
#>
1717
param(
1818
# The size of each segment
19-
[double]$Size = 200,
19+
[double]$Size = (Get-Random -Min 100 -Max 200),
2020
# The order of magnitude (the number of expansions)
21-
[int]$Order = 4,
21+
[int]$Order = (2,3,4 | Get-Random),
2222
# The default angle.
2323
[double]$Angle = 90
2424
)

Types/Turtle/BoxFractal.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
$turtle.Pattern.Save("$pwd/BoxFractal2.svg")
1818
#>
1919
param(
20-
[double]$Size = 20,
21-
[int]$Order = 4,
20+
[double]$Size = (Get-Random -Min 21 -Max 42),
21+
[int]$Order = (2,3,4 | Get-Random),
2222
[double]$Angle = 90
2323
)
2424
return $this.LSystem('F-F-F-F', [Ordered]@{

Types/Turtle/CircleArc.ps1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,15 @@
2626
param(
2727
# The radius of the circle
2828
[double]
29-
$Radius = 42,
29+
$Radius = $(
30+
(Get-Random -Min 42 -Max 84) *(1,-1|Get-Random)
31+
),
3032

3133
# The angle of the arc
3234
[double]
33-
$Angle = 30
35+
$Angle = $(
36+
(Get-Random -Min 30 -Max 90) *(1,-1|Get-Random)
37+
)
3438
)
3539

3640
# If we wanted an angle that was a multiple of 360

0 commit comments

Comments
 (0)