## Bresenhams line drawing algorithm

#include #include #include #include void main() { int Xs,Ys,Xe,Ye,dx,dy; float X,Y,p; int gd=DETECT,gm ; initgraph(&gd,&gm,”C:\\tc\\bgi”); printf (“Enter the value of (Xs , Xs ) & (Xe , Ye)\n”); scanf (“%d%d%d%d”, &Xs ,&Ys , &Xe , &Ye); dy=Ye-Ys; dx=Xe-Xs; p=(2*dy)-dx; X=Xs; Y=Ys; cleardevice( ); putpixel(X,Y,YELLOW); while(X!=Xe && Y!=Ye) { if(p<1) { X=X+1; p=p+(2*dy); putpixel (X,Y,RED); } … Read more

## Implementation of Bresenhams circle drawing algorithm

#include #include #include #include void main() { int r,x,y,p,xc=320,yc=240; int gd=DETECT,gm; initgraph(&gd,&gm,”C:\\TC\\BGI”); cleardevice(); printf(“Enter the radius “); scanf(“%d”,&r); putpixel(xc,yc,YELLOW); x=0; y=r; putpixel(xc+x,yc-y,1); p=3-(2*r); for(x=0;x<=y;x++) { if (p<0) { y=y; p=(p+(4*x)+6); } else { y=y-1; p=p+((4*(x-y)+10)); } putpixel(xc+x,yc-y,1); putpixel(xc-x,yc-y,2); putpixel(xc+x,yc+y,3); putpixel(xc-x,yc+y,4); putpixel(xc+y,yc-x,5); putpixel(xc-y,yc-x,6); putpixel(xc+y,yc+x,7); putpixel(xc-y,yc+x,8); } getch(); closegraph(); }

## Implementation of Bezier curve plotting

#include #include #include #include void bezier (int x[4], int y[4]) { int gd = DETECT, gm; int i; double t; initgraph (&gd, &gm, “..\\bgi”); for (t = 0.0; t < 1.0; t += 0.0005) { double xt = pow (1-t, 3) * x[0] + 3 * t * pow (1-t, 2) * x[1] + 3 … Read more