QB64 Phoenix Edition
EllipseFill - Printable Version

+- QB64 Phoenix Edition (https://staging.qb64phoenix.com)
+-- Forum: QB64 Rising (https://staging.qb64phoenix.com/forumdisplay.php?fid=1)
+--- Forum: Prolific Programmers (https://staging.qb64phoenix.com/forumdisplay.php?fid=26)
+---- Forum: SMcNeill (https://staging.qb64phoenix.com/forumdisplay.php?fid=29)
+---- Thread: EllipseFill (/showthread.php?tid=64)



EllipseFill - SMcNeill - 04-20-2022

Code: (Select All)
SUB EllipseFill (cx AS INTEGER, cy AS INTEGER, rx AS INTEGER, ry AS INTEGER, c AS LONG)
   DIM a AS LONG, b AS LONG
   DIM x AS LONG, y AS LONG
   DIM xx AS LONG, yy AS LONG
   DIM sx AS LONG, sy AS LONG
   DIM e AS LONG

   a = 2 * rx * rx
   b = 2 * ry * ry
   x = rx
   xx = ry * ry * (1 - rx - rx)
   yy = rx * rx
   sx = b * rx

   DO WHILE sx >= sy
       LINE (cx - x, cy - y)-(cx + x, cy - y), c, BF
       IF y <> 0 THEN LINE (cx - x, cy + y)-(cx + x, cy + y), c, BF

       y = y + 1
       sy = sy + a
       e = e + yy
       yy = yy + a

       IF (e + e + xx) > 0 THEN
           x = x - 1
           sx = sx - b
           e = e + xx
           xx = xx + b
       END IF
   LOOP

   x = 0
   y = ry
   xx = rx * ry
   yy = rx * rx * (1 - ry - ry)
   e = 0
   sx = 0
   sy = a * ry

   DO WHILE sx <= sy
       LINE (cx - x, cy - y)-(cx + x, cy - y), c, BF
       LINE (cx - x, cy + y)-(cx + x, cy + y), c, BF

       DO
           x = x + 1
           sx = sx + b
           e = e + xx
           xx = xx + b
       LOOP UNTIL (e + e + yy) > 0

       y = y - 1
       sy = sy - a
       e = e + yy
       yy = yy + a

   LOOP

END SUB



RE: EllipseFill - vince - 04-20-2022

Single letter variable names? No comments? Not even a ;-)? You can do better, Steve!


RE: EllipseFill - SMcNeill - 04-20-2022

I *could*, but that requires more work and brainpower than what I'm willing to put into things. LOL! Consider this code to be optimized for QB45 days, when such things were the common practice to reduce memory usage.

I'm just sharing code here... I never said it was MODERN code... Some of my crap is absolutely antique by now! Wink