_getlinestyle

Description

Gets the current line style.

#include <graph.h>

unsigned short __far _getlinestyle( void );

Remarks

Some graphics routines (_lineto, _polygon, and _rectangle) output straight lines to the screen. The type of line can be controlled with the current line-style mask.

The _getlinestyle function returns the current line-style mask. The mask is a 16-bit array in which each bit represents a pixel in the line being drawn. If the bit is 1, the corresponding pixel is set to the color of the line (the current color). If the bit is 0, the corresponding pixel is left unchanged. The mask is repeated over the length of the line. The default mask is 0xFFFF (a solid line).

Return Value

If no mask has been set, _getlinestyle returns the default mask.

Compatibility

Standards:None

16-Bit:DOS

32-Bit:None

See Also

_lineto functions, _polygon functions, _rectangle functions, _setlinestyle, _setwritemode

Example

/* GLINESTY.C: This program illustrates _setlinestyle and _getlinestyle. */

#include <conio.h>

#include <stdlib.h>

#include <graph.h>

void zigzag( short x1, short y1, short size );

void main( void )

{

/* Find a valid graphics mode. */

if( !_setvideomode( _MAXCOLORMODE ) )

exit( 1 );

/* Set line style and draw rectangle. */

_setlinestyle( 0x4d );

_rectangle( _GBORDER, 10, 10, 60, 60 );

_getch();

/* Draw figure with function that changes and restores line style. */

zigzag( 100, 100, 90 );

_getch();

/* Original style reused. */

_rectangle( _GBORDER, 190, 190, 130, 130 );

_getch();

_setvideomode( _DEFAULTMODE );

}

/* Draw box with changing line styles. Restore original style. */

void zigzag( short x1, short y1, short size )

{

short x, y, oldcolor;

unsigned short oldstyle;

unsigned short style[16] = { 0x0001, 0x0003, 0x0007, 0x000f,

0x001f, 0x003f, 0x007f, 0x00ff,

0x01ff, 0x03ff, 0x07ff, 0x0fff,

0x1fff, 0x3fff, 0x7fff, 0xffff };

oldcolor = _getcolor();

oldstyle = _getlinestyle(); /* Save old line style. */

for( x = 3, y = 3; x < size; x += 3, y += 3 )

{

_setcolor( x % 16 );

_setlinestyle( style[x % 16] ); /* Set and use new line styles */

_rectangle( _GBORDER, x1 - x, y1 - y, x1 + x, y1 + y );

}

_setlinestyle( oldstyle ); /* Restore old line style. */

_setcolor( oldcolor );

}