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

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

# URGENT:circle scaling using bresenham

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.