-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLAB1-DDA.CPP
More file actions
47 lines (40 loc) · 917 Bytes
/
LAB1-DDA.CPP
File metadata and controls
47 lines (40 loc) · 917 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
void Lined(int x0,int y0,int x1,int y1,int c);
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
/* initialize graphics mode */
initgraph(&gdriver, &gmode, "");
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* return with error code */
}
/* draw a line */
Lined(10,10,450,450,15);
/* clean up */
getch();
closegraph();
return 0;
}
void Lined(int x0,int y0,int x1,int y1,int c)
{
int x;
double dy=y1-y0;
double dx=x1-x0;
double y=y0;
double m=dy/dx;
for(x=x0;x<=x1;x++)
{
putpixel(x,abs(y),c);
y+=m;
}
}