' //////////////////// SUBs ////////////////////
Sub Circle
GraphicsWindow.Title = "Circle y = √(r² -x²)"
GraphicsWindow.PenColor = GraphicsWindow.GetRandomColor()
Turtle.X = r
For x = -r To r
y = Math.SquareRoot(r*r - x*x)
GraphicsWindow.PenWidth = 2*y
Turtle.Move(1)
EndFor
EndSub
Sub Ellipse ' with a = 2*b = r
GraphicsWindow.Title = "Ellipse y = b/a * √(a² -x²)"
GraphicsWindow.PenColor = GraphicsWindow.GetRandomColor()
Turtle.X = r
For x = -r To r
y = Math.SquareRoot(r*r - x*x)
GraphicsWindow.PenWidth = y
Turtle.Move(1)
EndFor
EndSub
Sub Parabola
GraphicsWindow.Title = "Parabola y = p * √x | y = q * x²"
GraphicsWindow.PenColor = GraphicsWindow.GetRandomColor()
Turtle.X = r
p = 12 ' = r/sqrt(r) = 150/sqrt(150) = 12.24745
For x = -r To r
y = p * Math.SquareRoot(Math.Abs(x)) ' horz. OR ..
'y = x * x / r ' vert. (r = 150)
GraphicsWindow.PenWidth = 2*y
Turtle.Move(1)
EndFor
EndSub
Sub Hyperbola ' with a = 2*b = r
GraphicsWindow.Title = "Hyperbola y = b/a * √(x² - a²)"
GraphicsWindow.PenColor = GraphicsWindow.GetRandomColor()
Turtle.X = 0
For x = -2*r To 2*r
y = Math.SquareRoot(x*x - r*r)
GraphicsWindow.PenWidth = 2*y
' Walk over undefined area
If y = 0 Then ' If x = -r Then
Turtle.Move(2*r-1)
x = r
EndIf
Turtle.Move(1)
EndFor
EndSub