08-23-2022, 05:37 PM
(This post was last modified: 08-23-2022, 05:38 PM by James D Jarvis.)
my weak ellipse drawing for you if you don't want to use circle. My pset method is missing something because I do not recall the math in that area where sqr() can't be called. Bplus is better here. The method using draw actually comes out decent enough.
Code: (Select All)
'badellipse
Screen _NewImage(800, 600, 256)
'pset ellipse
ex = 200
ey = 300
a = 160
b = 50
For y = 0 To 100 Step 0.2
n = (1 - y ^ 2 / b ^ 2) * a ^ 2 'have to calculate outside sqr() to avoid math error
If n > 0 Then
x = Sqr(n)
PSet (x + ex, y + ey), 15
PSet (ex - x, y + ey), 15
PSet (ex - x, ey - y), 15
PSet (x + ex, ey - y), 15
End If
Next y
'draw ellipse
ex = 600
ey = 300
a = 160
b = 50
Draw "bm" + Str$(ex) + "," + Str$(ey)
For y = 0 To 100 Step 1 'using larger steps than earlier because draw is slower but laying down line segments
n = (1 - y ^ 2 / b ^ 2) * a ^ 2
If n > 0 Then
x = Sqr(n)
If y < 1 Then Draw "bm" + Str$(x + ex) + "," + Str$(y + ey)
Draw "m" + Str$(x + ex) + "," + Str$(y + ey)
End If
Next y
For y = 100 To 0 Step -1
n = (1 - y ^ 2 / b ^ 2) * a ^ 2
If n > 0 Then
x = Sqr(n)
If y > 99 Then Draw "bm" + Str$(x + ex) + "," + Str$(y + ey)
Draw "m" + Str$(ex - x) + "," + Str$(y + ey)
End If
Next y
For y = 0 To 100 Step 1
n = (1 - y ^ 2 / b ^ 2) * a ^ 2
If n > 0 Then
x = Sqr(n)
If y < 0 Then Draw "bm" + Str$(x + ex) + "," + Str$(y + ey)
Draw "m" + Str$(ex - x) + "," + Str$(ey - y)
End If
Next y
For y = 100 To 0 Step -1
n = (1 - y ^ 2 / b ^ 2) * a ^ 2
If n > 0 Then
x = Sqr(n)
If y > 99 Then Draw "bm" + Str$(x + ex) + "," + Str$(y + ey)
Draw "m" + Str$(x + ex) + "," + Str$(ey - y)
End If
Next y