void ddazigzag( int x1, int y1, int x2, int y2, int iSize, LPPOINTFUNC lpPointFunction ) /************************************************************************/ { int x11, y11, x12, y12; int _cdecl rand(void); x11 = rand() % max( iSize, (x2 - x1)/2 ); y11 = rand() % max( iSize, (y2 - y1)/2 ); ddaline( x1, y1, x11, y11, lpPointFunction ); x12 = rand() % max( iSize, (x2 - x11)/2 ); y12 = rand() % max( iSize, (y2 - y11)/2 ); ddaline( x11, y11, x12, y12, lpPointFunction ); ddaline( x12, y12, x2, y2, lpPointFunction ); }
void main() { int x1,x2,y1,y2,gd,gm,opt; detectgraph(&gd,&gm); initgraph(&gd,&gm,"c:\\tcc\\bgi"); cout<<"Enter the Co-ordinate of 1st End Point "; cin>>x1>>y1; cout<<"\n Enter the Co-ordinate of 2nd End Point "; cin>>x2>>y2; cout<<"Enter No to draw line by prefered algorithm "<<endl; cout<<"Your options are 1. DDA "<<endl<<"2. Bresenhams "<<endl<<"Your options are 1 or 2 "; cin>>opt; if (opt==1) { cleardevice(); cout<<"DDA Line Aloforiyhm "<<endl; ddaline(x1,y1,x2,y2); } else { cleardevice(); cout<<"Bresenhams Line Drawing Algorithm "<<endl; bresline(x1,y1,x2,y2); } getch(); closegraph(); }
void main() { float xa,xb,ya,yb; int gd=DETECT,gm,chmnu,modch; initgraph(&gd,&gm,"c:\\tc\\bgi"); do { clrscr(); cleardevice(); cout<<"\n\n\t\t****************M E N U****************\n\n"; cout<<"--------------------------------------------------"; cout<<"\n\tD D A\t\tA L G O R I T H M\n\n"; cout<<"1.THICK LINE\t2.DOTTED LINE\t3.NORMAL LINE"; cout<<"\n\n--------------------------------------------------"; cout<<"\n\n\tB R E S E N H A M' s\t\tA L G O R I T H M\n\n"; cout<<"4.THICK LINE\t5.DOTTED LINE\t6.NORMAL LINE\n\n"; cout<<"--------------------------------------------------\n7.EXIT"; cout<<"\n\nENTER CHOICE:-\t"; cin>>chmnu; if(chmnu==7) break; if(chmnu>=1 && chmnu<=3) modch=1; else modch=2; cout<<"\n\nENTER THE END POINTS OF THE LINE (xa,ya)&(xb,yb) :-\t"; cin>>xa>>ya>>xb>>yb; switch(modch) { case 1: clrscr(); cleardevice(); ddaline(xa,ya,xb,yb,chmnu); break; case 2: clrscr(); cleardevice(); breshline((int)(ceil(xa)),(int)(ceil(ya)),(int)(ceil(xb)),(int)(ceil(yb)),chmnu ); break; default: cout<<"ENTER PROPER VALUES"; } getch(); }while(1); closegraph(); }
static BOOL NEAR PathIsClear (int x1,int y1,int x2,int y2) { BOOL bClear = TRUE; int i; LPFRAME lpFrame = ImgGetBaseEditFrame (lpImage); nNumLinePoints = 0; ddaline (x1,y1,x2,y2, (LPPOINTFUNC)MazeLineProc); for (i = 0; i < nNumLinePoints; i++) { RGBS Pixel; LPTR lpLine = FramePointer (lpFrame, MazeLinePoints[i].x,MazeLinePoints[i].y,FALSE); FrameGetRGB (lpFrame,lpLine,&Pixel,1); if (!Pixel.red && !Pixel.green && !Pixel.blue) { bClear = FALSE; break; } } return bClear; }