Microsoft Small Basic

Program Listing: BHN895
' SmallBasic Version 1.2
' Program: FilledEllipseTurtle
' Changelog:
' Author: Pappa Lapub
' Website: https://social.msdn.microsoft.com/Forums/en-US/0059173a-594e-4da4-afa6-e9c6ac9241fa/challenge-of-the-month-september-2018
' ImportURL: http://smallbasic.com/program/?
' SBOnline: http://smallbasic-publicwebsite-dev.azurewebsites.net/Program/view.aspx?
' Extension: ---
' Comment: Draw a filled ellispse with the turtle (DON'T use the Shapes or Controls methods)
' https://social.msdn.microsoft.com/Forums/en-US/b9ab0f8c-469e-41f5-85d4-f6bd070cdefc/challenge-of-the-month-december-2015
' Variables:
' ToDo:
'===============================================================================
cx = GraphicsWindow.Width/2 ' 312
cy = GraphicsWindow.Height/2 ' 221
Turtle.Speed = 10

a = 200
b = 150
VertUpCart()
a = 150
b = 200
HorzRightCart()
'Turtle.Show()


' //////////////////// SUBs ////////////////////
' vertical up-lines between -a and +a, lineStart kartes. x;y(x)
Sub VertUpCart
'Turtle.Hide()
For x = -a To a
'If x = 0 Then
' GraphicsWindow.PenColor = "Lime"
'EndIf
y = b * Math.SquareRoot(1 - x*x/a/a)
Turtle.X = cx + x
Turtle.Y = cy + y
Turtle.Move(2*y) ' default direction up/north
EndFor
EndSub

' horiz. right-lines between +b and -b, lineStart kartes. x(y);y
Sub HorzRightCart
'Turtle.Show()
Turtle.Turn(90) ' not if hidden
'Turtle.Hide()
GraphicsWindow.PenColor = "Yellow"
For y = -b To b
'If y = 0 Then
' GraphicsWindow.PenColor = "Blue"
'EndIf
x = a * Math.SquareRoot(1 - y*y/b/b)
Turtle.X = cx - x
Turtle.Y = cy + y
Turtle.Move(2*x)
EndFor
EndSub