Skip to content

Commit 0998aa0

Browse files
feat: Lucky turtle and random defaults ( Fixes #363, Fixes #366 )
Randomizing sierpinski triangle, square, and star
1 parent 85defb8 commit 0998aa0

4 files changed

Lines changed: 16 additions & 6 deletions

File tree

Types/Turtle/Lucky.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ $luckyArgs = @(
44

55
$shapes = @(
66
"flower", "starflower", "goldenflower", 'triflower',
7-
"arcygon", "polygon",
7+
"arcygon", "polygon", 'star',
88
"square", "circle", "rectangle", 'righttriangle',
99
"sierpinskitriangle","sierpinskiarrowheadcurve",
1010
"sierpinskicurve","sierpinskisquarecurve",

Types/Turtle/SierpinskiTriangle.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
$turtle.Pattern.Save("$pwd/SierpinskiTriangle2.svg")
2424
#>
2525
param(
26-
[double]$Size = 200,
27-
[int]$Order = 2,
26+
[double]$Size = (Get-Random -Min 42 -Max 84),
27+
[int]$Order = $(Get-Random -Min 3 -Max 5),
2828
[double]$Angle = 120
2929
)
3030
return $this.LSystem('F-G-G', [Ordered]@{

Types/Turtle/Square.ps1

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
param([double]$Size = 50)
1+
<#
2+
.SYNOPSIS
3+
Draws a square
4+
.DESCRIPTION
5+
Draws a square using Turtle graphics
6+
.EXAMPLE
7+
turtle square 42
8+
#>
9+
param(
10+
[double]$Size = $(Get-Random -Min 21 -Max 42)
11+
)
212
$null = foreach ($n in 1..4) {
313
$this.Forward($Size)
414
$this.Rotate(90)

Types/Turtle/Star.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
#>
2121
param(
2222
# The approximate size of the star
23-
[double]$Size = 50,
23+
[double]$Size = $(Get-Random -Min 21 -Max 42),
2424
# The number of points in the star
25-
[int]$Points = 6
25+
[int]$Points = $(Get-Random -Min 5 -Max 7)
2626
)
2727

2828
# To determine the angle, divide 360 by the number of points

0 commit comments

Comments
 (0)