#include /* Needed for sin and cos functions */ void Circle(int xOffset, int yOffset, int radius, unsigned char C) { float xPlot, yPlot; /* Current pixel being plotted */ float angle, angleRad; /* Current angle degrees & radiens */ for (angle = 0.; angle < 360.; angle += 1) { /* 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) xPlot = 0; else if (xPlot >= ScreenWidth) xPlot = ScreenWidth - 1; if (yPlot < 0) yPlot = 0; else if (yPlot >= ScreenHeight) yPlot = ScreenHeight - 1; /* Plot the pixel on the graphics screen */ SetPixel((int)xPlot, (int)yPlot, C); } }