Posts

Showing posts from March 27, 2011

FOR TRANSLATION

#include<stdio.h> #include<conio.h> #include<graphics.h> #include<math.h> void dda(int x1,int x2,int y1,int y2) { float dx,dy,steps,x,y; float xinc,yinc; int k; dx=abs(x2-x1); dy=abs(y2-y1); if(dx>dy) steps=dx; xinc=dx/steps; yinc=dy/steps; x=x1; y=y1; putpixel(x,y,10); for(k=0;k<=steps;k++) {        x+=xinc; y+=yinc; putpixel(x,y,10); } getch(); } void main() { int tx,ty,x1,x2,y1,y2; float xinc,yinc; int gd=DETECT,gm; initgraph(&gd,&gm,""); printf("enter the starting coordinate"); scanf("%d,%d",&x1,&y1); printf("enter the end coordinate"); scanf("%d,%d",&x2,&y2); dda(x1,y1,x2,y2); printf("enter the xaxis translation" ); scanf("%d",&ty); x1+=tx; x2+=tx; y1+=ty; y2+=ty ; printf("translation line"); dda(x1,x2,y1,y2); closegraph(); }

CIRCLE IN CIRCLE

#include<stdio.h> #include<conio.h> #include<graphics.h> void main() {  int gd=DETECT,gm;  initgraph(&gd,&gm,"c\\tc\bin");  setcolor(1);  circle(320,120,10);  setcolor(2);  circle(320,120,20);  setcolor(3);  circle(320,120,30);  getch();  }

TRIANGLE IN TRIANGLE

#include<stdio.h> #include<conio.h> #include<graphics.h> void main() {  int gd=DETECT,gm;  initgraph(&gd,&gm,"c\\tc\bin");  setcolor(1);  line(80,80,60,100);  line(60,100,100,100);  line(100,100,80,80);  setcolor(2);   line(80,60,40,120);  line(40,120,120,120);  line(120,120,80,60);  setcolor(3);   line(80,40,20,140); line(20,140,140,140);  line(140,140,80,40);  getch();  closegraph();  }

Google

Google