User Tools

Site Tools


c:graphics.h:setwritemode

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

c:graphics.h:setwritemode [2015/05/06 23:06]
c:graphics.h:setwritemode [2024/02/16 01:05] (current)
Line 1: Line 1:
 +===== setwritemode =====
 +
 +
 +====Syntax of setwritemode ==== 
 + <code c>
 +#include <graphics.h>
 +void setwritemode(int mode);
 +  </code>
 +
 +
 +==== Description of setwritemode ==== 
 +<code c>
 +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.
 +</code>
 +
 +
 +==== Example of setwritemode ====
 +<code c>
 +/* 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;
 +}
 +</code>
 +
 +
 +==== See also ====
 +[[lineto]]
 +[[putimage]]
 +
 +
 +===== 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

Impressum Datenschutz