Sunday, November 25, 2012

LINE CLIPPING USING COHEN SUTHERLAND ALGORITHM

LINE CLIPPING USING COHEN SUTHERLAND ALGORITHM #include<stdio.h> #include<conio.h> #include<graphics.h> #define FALSE 0 #define TRUE 1 #define LEFTEDGE 0x1 #define RIGHTEDGE 0x2 #define TOPEDGE 0x8 #define BOTTOMEDGE 0x4 #define INSIDE(a) (!a) #define REJECT(a,b) (a&b) #define ACCEPT(a,b) (!(a|b)) unsigned char encode(int x,int y,int minx,int maxx,int miny,int maxy) {            ...

LINE CLIPPING USING LIANG BARSKY ALGORITHM

LINE CLIPPING USING LIANG BARSKY ALGORITHM #include<stdio.h> #include<conio.h> #include<graphics.h> #include<dos.h> #define ROUND(a)((int)(a+0.5)) int cliptest(float p,float q,float *u1,float *u2) {             float r;             int retval=1;            ...

DRAW A CIRCLE USING MIDPOINT ALGORITHM

DRAW A CIRCLE USING MIDPOINT ALGORITHM #include <graphics.h> #include <stdlib.h> #include <stdio.h> #include <conio.h> #include<dos.h> void main() {    /* request auto detection */    int gdriver = DETECT, gmode, errorcode;    int x1,x2,x3,x4,xc,yc,r,y1,y2;    char msg[15];    /* initialize graphics and local variables */    initgraph(&gdriver,...

DRAW A LINE USING DDA ALGORITHM

DRAW A LINE USING DDA ALGORITHM #include <graphics.h> #include <stdlib.h> #include <stdio.h> #include <conio.h> #include<dos.h> #define ROUND(a)((int)(a+0.5)) int main(void) {    /* request auto detection */    int gdriver = DETECT, gmode, errorcode;    int xa,xb,ya,yb;   // int y=0,x=0,i;    char msg[25];    /* initialize graphics and local variables...

DRAW A LINE USING BRESENHAM ALGORITHM

DRAW A LINE USING BRESENHAM ALGORITHM #include <graphics.h> #include <stdlib.h> #include <stdio.h> #include <conio.h> #include<dos.h> void main() {    /* request auto detection */    int gdriver = DETECT, gmode, errorcode;    int xa,xb,ya,yb,x,y;    char msg[25];    /* initialize graphics and local variables */    initgraph(&gdriver,...