Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<conio.h>
- #include<graphics.h>
- #include<dos.h>
- int xround(float m){
- int p=int(m);
- if(m-p>=0.5)
- return p+1;
- else
- return p;
- }
- void dda(int x1,int y1,int x2,int y2,int color){
- int i,dx=x2-x1,dy=y2-y1;
- float steps;
- if(dx>dy)
- steps=dx;
- else
- steps=dy;
- float xinc=float(dx)/steps;
- float x=x1;
- float y=y1;
- float yinc=float(dy)/steps;
- putpixel(xround(x),xround(y),color);
- for(i=0 ; i<steps ; i++){
- x=x+xinc;
- y=y+yinc;
- putpixel(xround(x),xround(y),color);
- }
- }
- void main(){
- clrscr();
- int x1,x2,y1,y2;
- int gd=DETECT, gm;
- initgraph(&gd,&gm,"c:\\tC\\bgi");
- dda(50,100,100,50,WHITE);
- dda(100,50,300,50,WHITE);
- dda(100,50,150,100,WHITE);
- dda(300,50,350,100,WHITE);
- dda(150,100,350,100,WHITE);
- dda(50,100,50,250,WHITE);
- dda(150,100,150,250,WHITE);
- dda(350,100,350,250,WHITE);
- dda(50,250,350,250,WHITE);
- dda(75,150,125,150,WHITE);
- dda(75,150,75,250,WHITE);
- dda(125,150,125,250,WHITE);
- dda(200,150,300,150,WHITE);
- dda(200,150,200,200,WHITE);
- dda(200,200,300,200,WHITE);
- dda(300,150,300,200,WHITE);
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement