// Circle.cpp // ---------------------------------------------------- // Shows off the core of the midpoint algorithm // for scan conversion of circles. // ---------------------------------------------------- #include "MFC_Framework.h" void eighthArc( CDC& dc, int r, COLORREF color ) // Draw a 45 degree arc from "6 o'clock" to "4:30". { int x= 0 ; int y= r ; int p= 5 - 4*r ; dc.SetPixel( x, y, color ) ; while ( x < y ) { ++x ; if ( p < 0 ) p+= 8*x + 4 ; else { --y ; p+= 8*x + 4 - 8*y ; } dc.SetPixel( x, y, color ) ; } } void paint( CDC& dc, int width, int height ) { for ( int r= 10 ; r < 450 ; r+= 10 ) eighthArc( dc, r, RGB(0,0,0) ) ; }