C Language Development Kit/Functions/SetPixel

From OptiWiki

Jump to: navigation, search
Description Sets, clears or inverts a pixel on the display.
Syntax
void setpixel(int x, int y, int state);
Arguments
int x, int y
The x and y coordinates of the pixel that is to be set.
int state
state can have one of the following values:
0 Clears the pixel.
1 Sets the pixel.
2 Inverts the pixel. Sets when it was clear and clears when it was set.
Returns None
Remarks The following table shows the possible screen coordinates.
OPH100x PHL1300 PHL1700 PHL2700 OPL97xx DCL153x
Upper left corner 0,0 0,0 0,0 0,0 0,0 0,0
Bottom right corner 127,127 111,127 95,63 95,47 127,63 111,63 111,63
Example
#include "lib.h"
#include <stdio.h>
 
void main( void )
{
    int x, y, z;
    z=0;
 
    while( 1 )
    {
        z = 1-z;
        for( y=0; y < 48; y++)
        {
            for( x=0; x < 96; x++)
                setpixel( x, y, z);
        }
 
        gotoxy( 3, 1);
        printf("Press a key");
        resetkey();
        while( !kbhit())
            idle();
    }
}


Views
Personal tools