09-14-2023, 04:02 PM
elcircle is a pretty quick subroutine to draw filled ellipses (and circles) that doesn't have the problems using Paint does. It's not a fast as fcircle but it's speedy and it can do ellipses.
Code: (Select All)
'elcircle demo ' by James D. Jarvis ' a fast subroutine to fill an ellipsoid or a circlc without using PAINT 'expanded from a circle routine by Chuck Venoit here https://basicanywheremachine-news.blogsp...nVdETyxJk4 Screen _NewImage(800, 500, 256) Randomize Timer e = 64000 t1 = Timer For c = 1 To e elcircle Rnd * _Width, Rnd * _Height, Int(10 + c / 1000), 1.5, Int(Rnd * 256) Next c t2 = Timer For c = 1 To e elcircle2 Rnd * _Width, Rnd * _Height, Int(10 + c / 1000), 0.5, Int(Rnd * 256) Next c t3 = Timer Print "elcircle"; t2 - t1; " elcircle 2 "; t3 - t2; " press any key to continue" Sleep Cls Print "use standard circle comands if you wish to add a 1 pixel outline to the circles" elcircle 200, 200, 100, 0.5, 12 Circle (200, 200), 100, 15, , , 0.5 elcircle 400, 200, 100, 3.5, 12 Circle (400, 200), 100, 15, , , 3.5 Sub elcircle (cx, cy, crad, aspectr, klr As _Unsigned Long) 'elcircle does not render correctly if ascpect ratio is <1 If aspectr < 1 Then elcircle2 cx, cy, crad, aspectr, klr Else For xy = 0 To crad * 0.75 a = Sqr(crad * crad - xy * xy) a_ar = a / aspectr xy_ar = xy / aspectr Line (cx - a_ar, cy - xy)-(cx + a_ar, cy - xy), klr, BF Line (cx - a_ar, cy + xy)-(cx + a_ar, cy + xy), klr, BF Line (cx - xy_ar, cy - a)-(cx + xy_ar, cy - a), klr, BF Line (cx - xy_ar, cy + a)-(cx + xy_ar, cy + a), klr, BF Next xy End If End Sub Sub elcircle2 (cx, cy, crad, aspectr, klr As _Unsigned Long) 'elcircle2 renders aspect ratios <1 correctly but it is slower than elcircle itself For xy = 0 To (crad * 0.75) a = Sqr(crad * crad - xy * xy) a_ar = a * aspectr xy_ar = xy * aspectr Line (cx - xy, cy + a_ar)-(cx + xy, cy - a_ar), klr, BF Line (cx - a, cy + xy_ar)-(cx + a, cy - xy_ar), klr, BF Next xy End Sub