Microsoft Small Basic

Program Listing: XGD977
' Turtle Flower 3
' Copyright © 2020 Nonki Takahahsi. The MIT License.

GraphicsWindow.PenColor = "DarkViolet"
e = 120
Init()
For i = 1 To 6
Turtle.Move(10)
For s = 10 To e - 10 Step 10
Petal()
EndFor
Turtle.Move(10)
Turtle.Turn(60)
EndFor

Sub Init
gw = 300
gh = 300
GraphicsWindow.Width = gw
GraphicsWindow.Height = gh
Turtle.Speed = 10
Turtle.X = gw / 2 - (e + 10) / 2 * Math.SquareRoot(3)
Turtle.Y = gh / 2 + (e + 10) / 2
EndSub

Sub Petal
Turtle.Move(e - (s - 10))
Turtle.Turn(120)
Turtle.Move(s)
h = s * LDMath.Cos(30)
v = (e - s) - (s * LDMath.Sin(30))
d = Math.SquareRoot(h * h + v * v)
a = LDMath.ArcCos(LDMath.Cos(30) * s / d)
If v < 0 Then
a = -a
EndIf
Turtle.Turn(150 - a)
Turtle.Move(d)
Turtle.Turn(a + 90)
EndSub