circle.c 708 Bytes
#include "libfb.h"
/*---------------------------------------------------------------------
                  Make a circle on the screen
  ---------------------------------------------------------------------*/
void
fbCircle(int x0, int y0, int r, u16 color)
{
  int	x, y, f;

  x = r;
  y = 0;
  f = -2 * r + 3;
  
  while (x >= y) {
    fbPixel(x0 + x, y0 + y, color);
    fbPixel(x0 - x, y0 + y, color);
    fbPixel(x0 + x, y0 - y, color);
    fbPixel(x0 - x, y0 - y, color);
    fbPixel(x0 + y, y0 + x, color);
    fbPixel(x0 - y, y0 + x, color);
    fbPixel(x0 + y, y0 - x, color);
    fbPixel(x0 - y, y0 - x, color);
    if (f >= 0) {
      x --;
      f -= x*4;
    }
    y++;
    f += 4*y + 2;
  }
}