Skip to content

Commit 3c1eb2f

Browse files
StartAutomatingStartAutomating
authored andcommitted
feat: Lucky turtle and random defaults ( Fixes #363, Fixes #366 )
Randomizing sun, stepcurve, twindragon, triplexity
1 parent b76b885 commit 3c1eb2f

File tree

1 file changed

+29
-13
lines changed

1 file changed

+29
-13
lines changed

Turtle.types.ps1xml

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4761,9 +4761,9 @@ return $this
47614761
#>
47624762
param(
47634763
# The DeltaX
4764-
[double]$DeltaX = $(Get-Random -Min -100.0 -Max 100.0),
4764+
[double]$DeltaX = $(Get-Random -Min -10.0 -Max 10.0),
47654765
# The DeltaY
4766-
[double]$DeltaY = $(Get-Random -Min -100.0 -Max 100.0)
4766+
[double]$DeltaY = $(Get-Random -Min -10.0 -Max 10.0)
47674767
)
47684768

47694769
# If both coordinates are empty, we aren't going anywhere.
@@ -4923,11 +4923,11 @@ return $this
49234923
param(
49244924
# The length of both arcs
49254925
[double]
4926-
$Length = 42,
4926+
$Length = $(Get-Random -Min 42 -Max 81),
49274927

49284928
# The rotation after each step
49294929
[double]
4930-
$Angle = 160,
4930+
$Rotation = $(Get-Random -Min 60 -Max 270),
49314931

49324932
# The angle of the rays of the sun
49334933
[double]
@@ -4936,11 +4936,27 @@ $RayAngle = 90,
49364936
# The number of steps to draw.
49374937
# In order to close the shape, this multiplied by the angle should be a multiple of 360.
49384938
[int]
4939-
$StepCount = 9
4939+
$StepCount = 0
49404940
)
49414941

4942-
# If there are no steps to draw, return this
4943-
if ($stepCount -eq 0) { return $this }
4942+
if ($rotation -eq 0 -and $StepCount -eq 0) {
4943+
return $this
4944+
}
4945+
4946+
4947+
# If no step count was provided
4948+
if ($StepCount -eq 0) {
4949+
# pick a random number of rotations
4950+
$revolutions = (Get-Random -Minimum 1 -Max 16)
4951+
# and figure out how many steps at our angle it takes to get there.
4952+
foreach ($n in 2..$revolutions) {
4953+
$revNumber = ($revolutions * 360)/$Rotation
4954+
$StepCount = [Math]::Ceiling($revNumber)
4955+
if ([Math]::Floor($revNumber) -eq $revNumber) {
4956+
break
4957+
}
4958+
}
4959+
}
49444960

49454961
# Every step we take
49464962
$null = foreach ($n in 1..([Math]::Abs($StepCount))) {
@@ -4950,7 +4966,7 @@ $null = foreach ($n in 1..([Math]::Abs($StepCount))) {
49504966
# then arc left
49514967
ArcLeft($length/2, $RayAngle).
49524968
# then rotate.
4953-
Rotate($Angle)
4969+
Rotate($Rotation)
49544970
}
49554971

49564972
# Return this so we never break the chain.
@@ -5251,9 +5267,9 @@ return $this
52515267
#>
52525268
param(
52535269
# The size of each segment
5254-
[double]$Size = 42,
5270+
[double]$Size = (Get-Random -Min 21 -Max 21),
52555271
# The order of magnitude (the number of expansions)
5256-
[int]$Order = 4,
5272+
[int]$Order = (2,3,4 | Get-Random),
52575273
# The default angle.
52585274
[double]$Angle = 60
52595275
)
@@ -5356,16 +5372,16 @@ return
53565372
#>
53575373

53585374
param(
5359-
[double]$Size = 20,
5360-
[int]$Order = 6,
5375+
[double]$Size = (Get-Random -Min 21 -Max 42),
5376+
[int]$Order = (3,4,5,6, 7, 8 | Get-Random ),
53615377
[double]$Angle = 90
53625378
)
53635379
return $this.LSystem('FX+FX+', [Ordered]@{
53645380
X = 'X+YF'
53655381
Y = 'FX-Y'
53665382
}, $Order, [Ordered]@{
53675383
'\+' = { $this.Rotate($Angle) }
5368-
'-' = { $this.Rotate($Angle * -1) }
5384+
'\-' = { $this.Rotate($Angle * -1) }
53695385
'[F]' = { $this.Forward($Size) }
53705386
})
53715387

0 commit comments

Comments
 (0)