void drawCircle( int xCenter, int yCenter, int radius, COLOR fillColor ) { int x = 0, y = radius, p = 1 - radius; circlePlotPoints( xCenter, yCenter, x, y ); circleFillColor(xCenter, yCenter, x, y, fillColor); while( x < y ) { x++; if( p < 0 ) { p += (2 * x) + 1; } else { y--; p += ( 2*(x-y) ) +1; } circlePlotPoints(xCenter, yCenter, x, y); circleFillColor(xCenter, yCenter, x, y, fillColor); } //colorFill(xCenter, yCenter, fillColor); }
void circleMidPoint(GLint xc, GLint yc, GLint radius) { screenPoint circlePoint; //initialize value for midpoint parameter GLint p = 1-radius; //set coordinates for top point of circle circlePoint.setCoordinates(0,radius); //function prototype void circlePlotPoints(GLint, GLint, screenPoint); //plot the initial point in each quadrant circlePlotPoints(xc, yc, circlePoint); //calculate the next point and plot in each octant while(circlePoint.getx() < circlePoint.gety()) { circlePoint.incrementx(); if(p<0) p += 2 * circlePoint.getx() + 1; else{ circlePoint.decrementy (); p += 2 * (circlePoint.getx () - circlePoint.gety ()) + 1; } circlePlotPoints(xc, yc, circlePoint); } }