Ok, i'm totally new to Gapidraw and don't know anything about MFC. I was wondering how i can draw a circle on a CGapiSurface.
GapiDraw dosen't have any drawing capabilities what i am aware of. You have to do it by yourself. Simply by setting the pixels by hand.
Search for "circle drawing algorithm" on google and you will find code and examples.
PocketFrog has the circle drawing algorithm implemented (and many others). Take a look at the available source code.
void DrawCircle(int nX, int nY, int nR, COLORREF Color)
{
int x,y,dt,dt1,dt2,dr;
x=0;y=nR;dt=2-nR-nR;
while(y>=0)
{
//SetPixelColor is a draw point fun
SetPixelColor(nX+x,nY+y,Color);
SetPixelColor(nX+x,nY-y,Color);
SetPixelColor(nX-x,nY+y,Color);
SetPixelColor(nX-x,nY-y,Color);
if(dt<0)
{
dt1=dt+dt+y+y-1;
if(dt1<=0)dr=1;
else dr=2;
}
else if(dt>0)
{
dt2=dt+dt-x-x-1;
if(dt2<=0)dr=2;
else dr=3;
}else dr=2;
switch(dr)
{
case 1: x++;dt+=x+x+1;
break;
case 2: x++;y--;dt+=x+x-y-y-1;
break;
case 3: y--;dt+=1-y-y;
break;
}
}
}
Hi,
Thanks for posting circle drawing logic. If i wanted to draw a circle in CGapiSurface, how can i call the method DrawCircle? and how to associate with CGapiSurface
and there are some method call like SetPixelColor, what is that? where is the definition of that
simply i need a complete example, how circle can be drawn on the CGapiSurface
Thanks