#include<stdio.h> #include <stdlib.h> #include<graphics.h> #include<conio.h> #include<math.h> void draw2d(int,int [],int [],int,int); void main() { int gd=DETECT,gm; int x[20],y[20],tx=0,ty=0,i,fs; int mx,my; initgraph(&gd,&gm,""); printf("No of sides : "); scanf("%d",&fs); printf("Co-ordinates : "); for(i=0;i<fs;i++) { printf("(x%d,y%d)",i,i); scanf("%d%d",&x[i],&y[i]); } draw2d(fs,x,y,tx,ty); printf("magnification (x,y) : "); scanf("%d%d",&mx,&my); for(i=0;i<fs;i++) { x[i]=x[i]*mx; y[i]=y[i]*my; } draw2d(fs,x,y,tx,ty); getch(); } void draw2d(int fs,int x[20],int y[20],int tx,int ty) { int i; for(i=0;i<fs;i++) { if(i!=(fs-1)) line(x[i]+tx,y[i]+ty,x[i+1]+tx,y[i+1]+ty); else line(x[i]+tx,y[i]+ty,x[0]+tx,y[0]+ty); } }
Javascript tips and tricks, JQuery tips & tricks, JQuery Plugins, CSS Tricks and Tips, things you may not know about javascript, AngularJS tips and tricks, Laravel, PHP tips and tricks, computer programming, grapical user interface using c, c header files, computer graphics lab program, 2d translation, 3d translation, line drawing algorithm, circle drawing algorithm, DDA, Midpoint, 3D projection using c, Personal diary, Mini project using c, Graphical User Interface using C