Click here if you are stuck in someone else's frames.
Drawing Circles in QBasic

Let's not forget everyone in the QBasic / QuickBASIC land of programming.   Just as with the 'Line' statement, QBasic also has a circle statement that allows you to draw circles of various sizes and colors.  To use it, just type a statement similiar to this one:

     CIRCLE (160, 100), 90, 15

This draws a circle with a center point at coordinates (160, 100) with a radius of 90 pixels with color 16 (high intensity white).  If you are a glutton for punishment, you can create your own circle function like so:

     SUB DrawCircle (xOffset%, yOffset%, radius%, C%)
          DIM xPlot!, yPlot!     ' Current pixel being plotted.
          DIM angle!, angleRad!  ' Current angle in degrees & radiens.

          FOR angle! = 0! TO 360! STEP 0.5

               ' Convert degrees to radiens.
               angleRad! = angle! * (3.141592654 / 180!)

               ' Convert polar to rectangular coordinates.
               xPlot! = (radius! * COS(angleRad!)) + xOffset%
               yPlot! = (radius! * SIN(angleRad!)) + yOffset%

               ' Check boundaries.
               IF xPlot! < 0 THEN xPlot! = 0 ELSEIF xPlot! > 319 THEN xPlot! = 319
               IF yPlot! < 0 THEN yPlot! = 0 ELSEIF yPlot! > 199 THEN yPlot! = 199

               ' Plot the pixel on the graphics screen.
               PSET(xPlot!, yPlot!), C%
          NEXT angle!
     END SUB

Previous Page | Main Page | Next page