Re: Happy Pi day!!!

Jeff Stokes
 

Here’s my attempt from a few years ago to write an efficient circle routine for either Power-C or Super C for the C64 (I forget which one) because there was no included graphics library.

I don’t have a screen shot, but if I remember correctly the subroutine did not draw a perfect circle.

 

 

/* Draw a circle on screen */

void circle(cx, cy, radius)

int cx;

int cy;

int radius;

{

              int x = 0;

              int y = radius;

              int p = (5 - radius * 4) / 4;

 

              /* Initial Plot */

              setPixel(cx, cy + y);

              setPixel(cx, cy - y);

              setPixel(cx + y, cy);

              setPixel(cx - y, cy);

             

              while (x < y)

              {

                             x++;

                            

                             if (p < 0)

                             {

                                           p += 2 * x + 1;

                             }

                             else

                             {

                                           y--;

                                           p += 2 * (x - y) + 1;

                             }

                            

                             /* Plot Points */

                             if (x == y)

                             {

                                           setPixel(cx + x, cy + y);

                                           setPixel(cx - x, cy + y);

                                           setPixel(cx + x, cy - y);

                                           setPixel(cx - x, cy - y);

                             }

                             else if (x < y)

                             {

                                           setPixel(cx + x, cy + y);

                                           setPixel(cx - x, cy + y);

                                           setPixel(cx + x, cy - y);

                                           setPixel(cx - x, cy - y);

                                           setPixel(cx + y, cy + x);

                                           setPixel(cx - y, cy + x);

                                           setPixel(cx + y, cy - x);

                                           setPixel(cx - y, cy - x);

                             }

                            

              } // while()

}

 

Sent from Mail for Windows 10

 

From: Raj Wurttemberg
Sent: Saturday, March 14, 2020 3:57 PM
To: main@ahcs.groups.io
Subject: [ahcs] Happy Pi day!!!

 

Hey All!

 

Happy Pi Day!  I think that since we are all “grounded”, that it would be a fun challenge for everyone to make a BASIC or ML program to draw a circle on our respective vintage computers.

 

Fun challenge! :)  Post your circle pics!  (Groups.io) can handle pictures.

 

/Raj

 

 

Join main@ahcs.groups.io to automatically receive all group messages.