Shiny Language Reference

Language Reference > Drawing Functions


createpen

createpen(pen PenVar, int Style, int Width, int RGBColour);

 

 

Creates a drawing pen with the specified style

CREATEPEN initializes a variable of type PEN with the specified settings. Pens are used to control the style, colour and width of drawing operations (for example, DRAWLINE). This statement only initializes a pen and does not select it for use, therefore it can be called in any handler. This statement can also be used to change the settings of a PEN, ie: it may be called twice for the same PEN. To change only the colour of the pen refer to the SETPENCOL statement.

The purpose of this statement and the PEN type is roughly equivalent to the Win32API HPEN object.

 

Parameters

PenVar

A variable declared as type PEN to configure with the specified settings.

Style

An integer value specifying the style of the pen. This may be one of the following:

0 - The pen is a solid colour

1 - The pen draws dashes ( " ------ ")

2 - The pen draws dots (" ...... ")

3 - The pen alternates between dashes and dots (" -.-.-.-.- ")

4 - The pen alternates between dashes and double dots (" -..-..-..-..- ")

If the style is set to any value other than 0, the width must be set to 1. If a pen width greater than 1 is specified with a style other than 0, style 0 (solid) will be forced.

You may also use the following names for the pen style instead of the integers. SSEdit has these definitions declared internally.

PS_SOLID - The pen is a solid colour

PS_DASH - The pen draws dashes ( " ------ ")

PS_DOT - The pen draws dots (" ...... ")

PS_DASHDOT - The pen alternates between dashes and dots (" -.-.-.-.- ")

PS_DASHDOTDOT - The pen alternates between dashes and double dots (" -..-..-..-..- ")

 

Width

The width of the pen. This controls the thickness of the lines being drawn. Take note of the width restriction when setting different pen styles.

RGBColour

The colour of the pen, specified as an RGB value packed to an integer. Use the RGB statement to create this value.

Return Value

None

 

Example Code

// Initialize MyPen as a solid, 3 pixel wide red pen
pen MyPen;
createpen(MyPen, 0, 3, RGB(255, 0, 0));

// Initialize the pen to the same settings, using the SSEdit defines:
createpen(MyPen, PS_SOLID, 3, RGB(255, 0, 0));