URGENT:circle scaling using bresenham - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

URGENT:circle scaling using bresenham

reemareema Posts: 3Member
hello,
I've already build a code to draw a circle using bresenham's circle algorithm in Turbo C.i'd like somebody to help me add to this code a part (in function)that apply scaling (or any geometric transformation (shearing,translation)) on this circle. if anybody can help, plz send me urgently.
here is the circle drawing code:

#include
#include
#include
#include

int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int xc,yc;

int radius = 130;
int x=0,y=radius,d;

/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");

/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s
", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}

xc = getmaxx() / 2;
yc = getmaxy() / 2;
setcolor(getmaxcolor());

/* draw the circle */
d=3-2*radius;

while(x!=y)
{
putpixel(xc+x,yc+y,70);
putpixel(xc+x,yc-y,70);
putpixel(xc-x,yc+y,70);
putpixel(xc-x,yc-y,70);
putpixel(xc+y,yc+x,50);
putpixel(xc+y,yc-x,50);
putpixel(xc-y,yc+x,50);
putpixel(xc-y,yc-x,50);

if(d<0)
{
d=d+(4*x)+6;
}
else
{
d=d+((x-y)*4)+10;
y--;
}
x++;
}

/* clean up */
getch();
closegraph();
return 0;
}
Sign In or Register to comment.