Top Banner
/* DDA Techinique to Draw a striaght Line */ #include <stdio.h> #include <conio.h> #include <graphics.h> #include <math.h> void main() { int gd=DETECT,gm; int x1,x2,y1,y2,xinc,yinc; int i,step; float dx,dy; initgraph(&gd,&gm,"c:\\tc\\bgi"); printf("\nEnter 1st End Points x1 & y1 : \n"); scanf("%d %d",&x1,&y1); printf("\nEnter 2nd End points x2 & y2 : \n "); scanf("%d %d",&x2,&y2); dx=x2-x1; dy=y2-y1; if(abs(dx) > abs(dy)) step=abs(dx); else step=abs(dy); xinc=dx/step; yinc=dy/step; putpixel(x1,y1,BLUE); for(i=1; i<=step; i++) {
24

practical record for computer graphics (B.tech cse) UPTU

Jul 15, 2015

Download

Engineering

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript

/* DDA Techinique to Draw a striaght Line */#include #include #include #include void main() { int gd=DETECT,gm; int x1,x2,y1,y2,xinc,yinc; int i,step; float dx,dy; initgraph(&gd,&gm,"c:\\tc\\bgi"); printf("\nEnter 1st End Points x1 & y1 : \n"); scanf("%d %d",&x1,&y1); printf("\nEnter 2nd End points x2 & y2 : \n "); scanf("%d %d",&x2,&y2); dx=x2-x1; dy=y2-y1; if(abs(dx) > abs(dy)) step=abs(dx); else step=abs(dy); xinc=dx/step; yinc=dy/step; putpixel(x1,y1,BLUE); for(i=1; i