User Tools

Site Tools


Sidebar

Programming Reference/Librarys

Question & Answer

Q&A is closed







c:graphics.h:setwritemode

setwritemode

Syntax of setwritemode

#include <graphics.h>
void setwritemode(int mode);
 

Description of setwritemode

The following constants are defined:
COPY_PUT = 0/* MOV */
XOR_PUT  = 1/* XOR */
Each constant corresponds to a binary operation between each byte in the
line and the corresponding bytes onscreen. COPY_PUT uses the assembly
language MOV instruction, overwriting with the line whatever is on the
screen. XOR_PUT uses the XOR command to combine the line with the screen.
Two successive XOR commands will erase the line and restore the screen to
its original appearance.
setwritemode currently works only with line, linerel, lineto, rectangle,
and drawpoly.

Example of setwritemode

/* setwritemode example */
 
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
 
int main()
{
   /* request autodetection */
   int gdriver = DETECT, gmode, errorcode;
   int xmax, ymax;
 
   /* initialize graphics and local variables */
   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);   /* terminate with an error code */
   }
 
   xmax = getmaxx();
   ymax = getmaxy();
 
   /* select XOR drawing mode */
   setwritemode(XOR_PUT);
 
   /* draw a line */
   line(0, 0, xmax, ymax);
   getch();
 
   /* erase the line by drawing over it */
   line(0, 0, xmax, ymax);
   getch();
 
   /* select overwrite drawing mode */
   setwritemode(COPY_PUT);
 
   /* draw a line */
 
   line(0, 0, xmax, ymax);
 
   /* clean up */
   getch();
   closegraph();
   return 0;
}

See also

output of setwritemode example

  no output of example at the moment
  do not hesitate and add it...  

on the occasion of the current invasion of Russia in Ukraine

Russian Stop this War
c/graphics.h/setwritemode.txt · Last modified: 2024/02/16 01:05 (external edit)

Impressum Datenschutz