Graphics Context - Pen

The Pen

The pen is the graphics context object that controls how a line is drawn. The pen always has type TPen and the current pen can be accessed via the datum Pen.

A new pen can only be construct based on an existing pen, using the structure modification operator. The current default pen is always constant.

The TPen Type

The TPen type is a system defined structure with the following fields :-

Number width

This is the width in pixels of any line drawn with this pen.

Colour colour

This is the colour of any line drawn with this pen.

EOverwrite overwrite

This controls the way the colour of the pen interacts with the background colour. It only has an affect if the opacity of the colour is less than 100%.

The options for this are :-

Add - This will cause additive mixing ( like light ).

Subtract - This will cause subtractive mixing ( like pigments ).

Invert - This will cause the current colour to be inverted.

EDashMode dashmode

This controls the way dashed lines are drawn.

The options for this are :-

Solid - the line will be solid ( not dashed ).

Fixed - The dash lengths will be used as specified. The system will cycle around the array as many times as necessary.

Single - The dash lengths will be adjusted so that only a single cycle is used in drawing the entire line.

Multiple - The dash lengths will be adjusted for a integer number of cycles to be used. The array will cycle around that number of times.

Continuous - When drawing multiple line segments the dashing will treat them as a continuous section.

If the mode is anything other than Solid then there must be dash list. The default system pen does not have one so at some point in the inheritance chain for the pen a dashlist needs to be specified. It there is no list then a general runtime "Structure call error" will be generated.

NumberArray dashlist

This contains a list of dash and space lengths to be used when drawing a dashed line. The array consists of alternating mark and space length - the actual length of the segments in pixels will be the value in the array times the pen width. There must be at least two entries in the array.

pen_dash.grs Sample of dash modes