Microsoft Small Basic

Program Listing: RWJ975-0
' Draw Ellipse with Turtle
' Version 0.4
' Copyright © 2018 Nonki Takahashi. The MIT License.
' Challenge 2018-09
' Last update 2018-09-15
' Program ID RWJ975-0

GraphicsWindow.Title = "Ellipse by Turtle 0.4"
Init()
a = 150
b = 100
x = ox - a
y = oy - b
GraphicsWindow.PenColor = "Orange"
Turtle.Speed = 9
toRight = "True"
Turtle.Turn(-90)
For y1 = oy - b To oy + b Step 2
y = y1 - oy
x = Math.SquareRoot(b * b - y * y) / b * a
x1 = ox - x
x2 = ox + x
Turtle.PenUp()
If toRight Then
Turtle.X = x1
Turtle.Y = y1
Turtle.Turn(-180)
Else
Turtle.X = x2
Turtle.Y = y1
Turtle.Turn(180)
EndIf
Turtle.PenDown()
Turtle.Move(x2 - x1)
toRight = Not[toRight]
EndFor
GraphicsWindow.PenColor = "Black"
For θ = 0 To 360 Step 5
_θ = Math.GetRadians(θ)
x = ox - a * Math.Sin(_θ)
y = oy + b * Math.Cos(_θ)
If θ = 0 Then
Turtle.X = x
Turtle.Y = y
Else
Turtle.MoveTo(x, y)
EndIf
EndFor

Sub Init
Not = "False=True;True=False;"
gw = 598
gh = 428
GraphicsWindow.Width = gw
GraphicsWindow.Height = gh
ox = gw / 2
oy = gh / 2
EndSub