Last active
January 26, 2017 14:15
-
-
Save amalaugustinejose/58f403441c50d7ffffaf21e113b725ee to your computer and use it in GitHub Desktop.
Draw a polygon using mouse clicks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<graphics.h> | |
#include<dos.h> | |
void main() { | |
int gd = DETECT, gm, gate, fx, fy, ax, ay, bx, by; | |
union REGS i, o; | |
initgraph(&gd, &gm, "C:\\TurboC3\\BGI"); | |
i.x.ax = 0; | |
int86(0x33, &i, &o); | |
i.x.ax = 1; | |
int86(0x33, &i, &o); | |
while (gate) { | |
gate = 1; | |
i.x.ax = 5; | |
i.x.bx = 0; | |
int86(0x33, &i, &o); | |
if (o.x.bx == 1) { | |
gate = 0; | |
fx = o.x.cx; | |
fy = o.x.dx; | |
} | |
} | |
ax = fx; | |
ay = fy; | |
do { | |
gate = 1; | |
while(gate) { | |
i.x.ax = 5; | |
i.x.bx = 0; | |
int86(0x33, &i, &o); | |
if (o.x.bx == 1) { | |
gate = 0; | |
bx = o.x.cx; | |
by = o.x.dx; | |
} | |
} | |
line(ax, ay, bx, by); | |
ax = bx; | |
ay = by; | |
}while (!kbhit()); | |
line(fx, fy, ax, ay); | |
delay(5000); | |
getch(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment