Watcom C Library Reference : _getphyscoord, getpid, _getpixel, _getpixel_w, _getplotaction, gets

 

 

 

 

_getphyscoord

 

Synopsis : #include <graph.h> 

              struct xycoord _FAR _getphyscoord ( short x, short y );

 


Description : The _getphyscoord function returns the physical coordinates of the position with view coordinates (x, y). View coordinates are defined by the _setvieworg and _setviewport functions.

 

 

Returns : The _getphyscoord function returns the physical coordinates, as an xycoord structure. of the given point.

 

 

See Also : _getviewcoord, _setvieworg, _setviewport

 


Example :

#include <conio.h> 

#include <graph.h> 

#include <stdlib.h>


main( )

{
    struct xycoord pos;
   

    _setvideomode( _VRES16COLOR );

    _setvieworg( rand( ) % 640, rand( ) % 480 );

    pos = _getphyscoord ( 0, 0 );

    _rectangle( _GBORDER, - pos.xcoord, - pos.ycoord, 639 - pos.xcoord, 479 - pos.ycoord ); 

 

    getch( );

    _setvideomode ( _DEFAULTMODE );

}

 

Classification : PC Graphics
Systems : DOS, QNX

 

 

 

 

 

getpid

 

Synopsis : #include <process.h> 

              int getpid( void );

 


Description : The getpid function returns the process id for the current process.

 

 

Returns : The getpid function returns the process id for the current process.

 

 

Example :

#include <stdio.h> 

#include <process.h>


void main( )

{
    unsigned int process_id;

    auto char filename[13];


    process_id = getpid( );

 

    /* use this to create a unique file name */

    sprintf( filename, "TMP%4.4x. TMP", process_id );

}

 

Classification : POSIX 1003.1
Systems : All

 

 

 

 

 

_getpixel, _getpixel_w

 

Synopsis : #include <graph.h> 

              short _FAR _getpixel( short x, short y );
              short _FAR _getpixel_w ( double x, double y );


Description : The _getpixel functions return the pixel value for the point with coordinates (x, y). The _getpixel function uses the view coordinate system. The _getpixel_w function uses the window coordinate system.

 

 

Returns : The _getpixel functions return the pixel value for the given point when the point lies within the clipping region; otherwise, (-1) is returned.

 

 

See Also : _setpixel

 


Example :

#include <conio.h> 

#include <graph.h> 

#include <stdlib.h>


main( )

{
    int     x, y;

    unsigned i;


    _setvideomode( _VRES16COLOR );

    _rectangle( _GBORDER, 100, 100, 540, 380 );

    for( i = 0; i <= 60000; ++i) {
        x = 101 + rand( ) % 439;

        y = 101 + rand( ) % 279;

        _setcolor( _getpixel ( x, y ) + 1 );

        _setpixel ( x, y );

    }


    getch( );

    _setvideomode( _DEFAULTMODE );

}

 

Classification : PC Graphics
Systems : _getpixel - DOS, QNX

             _getpixel_w - DOS, QNX

 

 

 

 

 

_getplotaction

 

Synopsis : #include <graph.h> 

              short _FAR _getplotaction( void );

 


Description : The _getplotaction function returns the current plotting action.
The drawing functions cause pixels to be set with a pixel value. By default, the value to be set is obtained by replacing the original pixel value with the supplied pixel value. Alternatively, the replaced value may be computed as a function of the original and the supplied pixel values.


The plotting action can have one of the following values :

 Value  Meaning
 _GPSET  replace the original screen pixel value with the supplied pixel value
 _GAND  replace the original screen pixel value with the bitwise and of the original pixel value and the supplied pixel value
 _GOR  replace the original screen pixel value with the bitwise or of the original pixel value and the supplied pixel value
 _GXOR  replace the original screen pixel value with the bitwise exclusive-or of the original pixel value and the supplied pixel value. Performing this operation twice will restore the original screen contents, providing an efficient method to produce animated effects.

 

 

Returns : The _getplotaction function returns the current plotting action.

 

 

See Also : _setplotaction

 


Example :

#include <conio.h> 

#include <graph.h>


main( )

{
    int     old_act;

 

    _setvideomode( _VRES16COLOR );

    old_act = _getplotaction( );

    _setplotaction( _GPSET );

    _rectangle( _GFILLINTERIOR, 100, 100, 540, 380);

    getch( );

 

    _setplotaction( _GXOR );

    _rectangle( _GFILLINTERIOR, 100, 100, 540, 380);

    getch( );

 

   _setplotaction( old_act );

    _setvideomode( _DEFAULTMODE );

}

 

Classification : PC Graphics
Systems : DOS, QNX

 

 

 

 

 

gets

 

Synopsis : #include <stdio.h> 

              char *gets( char *buf );

 


Description : The gets function gets a string of characters from the file designated by stdin and stores them in the array pointed to by buf until end-of-file is encountered or a new-line character is read. Any new-line character is discarded, and a null character is placed immediately after the last character read into the array.


It is recommended that fgets be used instead of gets because data beyond the array buf will be destroyed if a new-line character is not read from the input stream stdin before the end of the array buf is reached.


A common programming error is to assume the presence of a new-line character in every string that is read into the array. A new-line character may not appear as the last character in a file, just before end-of-file.

 

 

Returns : The gets function returns buf if successful. NULL is returned if end-of-file is encountered, or if a read error occurs. When an error has occurred, errno contains a value indicating the type of error that has been detected.

 

 

See Also : fopen, getc, fgetc, fgets, ungetc

 


Example :

#include <stdio.h>


void main( )

{
    char     buffer[80];

 

    while( gets ( buffer ) != NULL ) {
        puts( buffer );

    }

}

 

Classification : ANSI
Systems : All

 

 

 

 

 

 

 

 

This manual describes the WATCOM C library for DOS, Windows, and OS/2, It includes the Standard C Library (as defined in the ANSI C Standard).

 

WATCOM C Language Reference manual describes the ANSI C Programming language and extensions to it which are supported by WATCOM C/C++ (32bit)

 

 

 

 

728x90
반응형
Posted by 전화카드
,