Header file:
graphics.h
Synopsis:
void setwritemode(int mode);
Description:
setwritemode() sets the current writing mode for line drawing. Mode can be COPY_PUT or XOR_PUT.
COPY_PUT - overwrites with the line on screen
XOR_PUT - uses XOR command to mix line with the screen
setwritemode function in c graphics
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main() {
/* request auto detection */
int graphicDriver = DETECT, graphicMode, err;
/* initialize graphics and local variables */
initgraph(&graphicDriver, &graphicMode,
"C:/TURBOC3/BGI");
/* read result of initialization */
err = graphresult();
if (err != grOk) {
/* an error occurred */
printf("Graphics error: %s\n",
grapherrormsg(err));
getch();
return 0;
}
/* select XOR drawing mode */
setwritemode(XOR_PUT);
/* draw a line */
line(0, 0, getmaxx(), getmaxy());
getch();
/* erase the line by drawing over it */
line(0, 0, getmaxx(), getmaxy());
getch();
/* select overwrite drawing mode */
setwritemode(COPY_PUT);
/* draw a line */
line(0, 0, getmaxx(), getmaxy());
/* clean up */
getch();
closegraph();
return 0;
}
Output: (setwritemode built-in function in c graphics.h)
No comments:
Post a Comment