'Watcom C Reference/G - H - I'에 해당되는 글 16건

  1. 2021.06.28 Watcom C Library : gcvt, _getactivepage, _getarcinfo, _getbkcolor

 

 

 

Watcom C Library Reference : gcvt, _getactivepage, _getarcinfo, _getbkcolor

 

 

 

 

gcvt

 

Synopsis : #include <stdlib.h> 

              char *gcvt( double value, int ndigits, char *buffer );

 


Description : The gcvt function converts the floating-point number value into a character string and stores the result in buffer. The parameter ndigits specifies the number of significant digits desired. The converted number will be rounded to this position.


If the exponent of the number is less than -4 or is greater than or equal to the number of significant digits wanted, then the number is converted into E-format, otherwise the number is formatted using F-format.

 

 

Returns : The gcvt function returns a pointer to the string of digits.

 

 

See Also : ecvt, fcvt, printf

 


Example :

#include <stdio.h> 

#include <stdlib.h>


void main( )

{
    char     buffer[80];
   

    printf( "%s\n", gcvt ( -123.456789, 5, buffer ) );

    printf( "%s\n", gcvt ( 123.456789E+12, 5, buffer ) );

}

 


produces the following :
-123.46

1.2346E+014

 

Classification : WATCOM
Systems : All

 

 

 

 

 

_getactivepage

 

Synopsis : #include <graph.h> 

              short _FAR _getactivepage ( void );

 


Description : The _getactivepage function returns the number of the currently selected active graphics page.

 

Only some combinations of video modes and hardware allow multiple pages of graphics to exist. When multiple pages are supported, the active page may differ from the visual page. The graphics information in the visual page determines what is displayed upon the screen. Animation may be accomplished by alternating the visual page. A graphics page can be constructed without affecting the screen by setting the active page to be different than the visual page.

 

The number of available video pages can be determined by using the _getvideoconfig function. The default video page is 0.

 

 

Returns : The _getactivepage function returns the number of the currently selected active graphics page.

 

 

See Also : _setactivepage, _setvisualpage, _getvisualpage, _getvideoconfig

 


Example :

#include <conio.h> 

#include <graph.h>


main( ) 

{
    int     old_apage;

    int     old_vpage;


    _setvideomode ( _HRES16COLOR );

    old_apage = _getactivepage( );

    old_vpage = _getvisualpage( );

 

    /* draw an ellipse on page 0 */

    _setactivepage( 0 ); 

    _setvisualpage( 0 );

    _ellipse( _GFILLINTERIOR, 100, 50, 540, 150 );

 

    /* draw a rectangle on page 1 */

    _setactivepage( 1 );

    _rectangle( _GFILLINTERIOR, 100, 50, 540, 150 );

    getch( );

     /* display page 1 */

    _setvisualpage( 1 );

    getch( );

    _setactivepage ( old_apage );

    _setvisualpage( old_vpage );

    _setvideomode ( _DEFAULTMODE );

}

 

Classification : PC Graphics
Systems : DOS, QNX

 

 

 

 

 

_getarcinfo

 

Synopsis : #include <graph.h> 

              short _FAR _getarcinfo ( struct xycoord _FAR *start_pt,
                                         struct xycoord _FAR *end_pt,

                                         struct xycoord _FAR *inside_pt );

 


Description : The _getarcinfo function returns information about the arc most recently drawn by the _arc or _pie functions. The arguments start_pt and end_pt are set to contain the endpoints of the arc. The argument inside_pt will contain the coordinates of a point within the pie. The points are all specified in the view coordinate system.


The endpoints of the arc can be used to connect other lines to the arc. The interior point can be used to fill the pie.

 

 

Returns : The _getarcinfo function returns a non-zero value when successful. If the previous arc or pie was not successfully drawn, zero is returned.

 

 

See Also : _arc, _pie

 


Example :

#include <conio.h> 

#include <graph.h>


main( )

{
    struct xycoord start_pt, end_pt, inside-pt;


    _setvideomode( _VRES16COLOR );

    _arc ( 120, 90, 520, 390, 520, 90, 120, 390 );

    _getarcinfo( &start_pt, &end_pt, &inside-pt );

    _moveto( start_pt.xcoord, start_pt.ycoord );

    _lineto( end_pt.xcoord, end_pt.ycoord );

    getch( );

 

    _setvideomode ( _DEFAULTMODE );

}

 


produces the following :

 


Classification : PC Graphics
Systems : DOS, QNX

 

 

 

 

 

 

_getbkcolor

 

Synopsis : #include <graph.h> 

              long _FAR _getbkcolor( void );

 


Description : The _getbkcolor function returns the current background color. In text modes, the background color controls the area behind each individual character. In graphics modes, the background refers to the entire screen. The default background color is 0.

 

 

Returns : The _getbkcolor function returns the current background color.

 

 

See Also : _setbkcolor, _remappalette

 


Example :

#include <conio.h> 

#include <graph.h>


long colors [16] = {
    _BLACK, B_LUE, _GREEN, _CYAN, _RED,

    _MAGENTA, _BROWN, _WHITE, _GRAY,

    _LIGHTBLUE, LIGHTGREEN, _LIGHTCYAN, _LIGHTRED,

    _LIGHTMAGENTA, _YELLOW, _BRIGHTWHITE

};

 


main( )

{
    long  old_bk;

    int     bk;


    _setvideomode( _VRES16COLOR );

    old_bk = _getbkcolor( );

    for( bk = 0; bk < 16; ++bk ) {
        _setbkcolor( colors [bk] );

        getch( );

    }


    _setbkcolor( old_bk );

    _setvideomode( _DEFAULTMODE );

}

 

Classification : PC Graphics
Systems : DOS, QNX

 

 

 

 

 

 

 

 

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 전화카드
,