TRANSLATION PROGRAM IN C
Similar Programs
- Flood Fill program in C
- Triangle Rotation Program
- Text animation program in C
- C program for fixed point scaling and rotation
- C Program for shearing of triangle, line and rectangle
- C program to plot different types of lines
- Scaling program in C
- Font animation program in C
- Midpoint ellipse drawing program in C
- Circle Midpoint program in C
- Translation program in C
- Bresenhem Circle drawing program in C
- String Generation program in C
- Bresenhem Line drawing program in C
- Plotting a pixel in C
- DDA line drawing program in C
- Boundary fill program in C
- Character Generation program in C
- Triangle Rotation program in C
//***PROGRAM FOR TANSLATION*****// #include<stdio.h> #include<conio.h> #include<stdlib.h> #include<graphics.h> void circlemid(int,int,int); void circlepoint(int,int,int,int); int r,x1,x2,y1,y2,x3,y3,x4,y4; int ch; int x,y; void main() { int gd = DETECT, gm; initgraph(&gd,&gm,"c:\\tc\\bgi"); { cleardevice(); do { clrscr(); printf("TRANSLATION\n"); printf("PRESS 1 FOR LINE\n"); printf("PRESS 2 FOR RECTANGALE\n"); printf("PRESS 3 FOR CIRCLE\n"); printf("PRESS ANY KEY TO EXIT\n"); scanf("%d",&ch); switch(ch) { case 1: printf("ENTER STARING POINT\n"); scanf("%d%d",&x1,&y1); printf("ENTER THE ENDPOINT"); scanf("%d%d",&x2,&y2); setcolor(RED); line(x1,y1,x2,y2); printf("ENTER TRANSLATION FACTOR"); scanf("%d%d",&x,&y); setcolor(RED); x3 = x1+x; x4 = x2+x; y3 = y1+y; y4 = y2+y; line(x3,y3,x4,y4); getch(); break; case 2: printf("ENTER STARING POINT\n"); scanf("%d%d",&x1,&y1); printf("ENTER THE ENDPOINT"); scanf("%d%d",&x2,&y2); setcolor(RED); rectangle(x1,y1,x2,y2); printf("ENTER TRANSLATION FACTOR"); scanf("%d%d",&x,&y); setcolor(RED); x3 = x1+x; x4 = x2+x; y3 = y1+y; y4 = y2+y; rectangle(x3,y3,x4,y4); getch(); break; case 3: printf("ENTER STARING POINT\n"); scanf("%d%d",&x,&y); printf("Enter radius of circle"); scanf("%d",&r); setcolor(RED); circlemid(x,y,r); printf("ENTER TRANSLATION FACTOR"); scanf("%d%d",&x1,&y1); x=x+x1; y=y+y1; circlemid(x,y,r); setcolor(RED); getch(); break; default: exit(0); } } while(ch!=0); getch(); closegraph(); } } void circlemid(int xc,int yc,int rd) { int x =0; int y =rd; int p = 1-rd; while(x<y) { x++; if(p<0) p = p+2*x+1; else { y--; p = p+2*(x-y)+1; } circlepoint(xc,yc,x,y); delay(200); } } void circlepoint(int xc,int yc,int x,int y) { putpixel(xc+x,yc+y,1); putpixel(xc+y,yc+x,1); putpixel(xc-y,yc+x,1); putpixel(xc-x,yc+y,1); putpixel(xc+x,yc-y,1); putpixel(xc-y,yc-x,1); putpixel(xc+y,yc-x,1); putpixel(xc-x,yc-y,1); }
0 comments:
Post a Comment