67.1.4 Line Attributes

Every device context contains a number of attributes which affect line and curve output. These attributes and their purpose are described in the following list:

Attribute Purpose

current position Specifies the starting point for any drawing operation. The coordinates of this point are specified in world (or logical) units.
brush style Specifies the style (or pattern) used to fill wide lines which were drawn with a geometric pen.
brush color Specifies the color of the pattern used to fill wide lines which were drawn with a geometric pen.
pen style Specifies the pattern that is used to draw a line or curve. This pattern can be solid, dashed, dotted, dashed and dotted, invisible, or a custom pattern that is specified by the application.
pen color Specifies the color that is used to draw a line or curve.
pen width Specifies the width of a line or curve.
pen type Specifies whether the line's width is specified in device units (cosmetic) or world units (geometric); also specifies whether or not the line has an associated join-style or end-cap.
pen join-style Specifies how consecutive lines or curves which were drawn with a geometric pen are joined.
pen end-cap Specifies the appearance of the ends of lines or curves which were drawn with a geometric pen.
world transformation Specifies a transformation which affects the width, location, and appearance of a line or curve that is drawn with a geometric pen.

67.1.4.1 The Current Position

The default current position for any device context is located at the logical-coordinates (0,0). You can set these coordinates to a new position by calling the MoveToEx function and passing a new set of coordinates.

Windows provides two sets of line- and curve-drawing functions: the first set leaves a device context's current position intact, the second set alters the current position. You can identify those functions that alter the current position by examining the function name. If the function name ends with the preposition “To”, (LineTo, ArcTo, PolylineTo, or PolyBezierTo), it [the function] sets the current position to the endpoint of the last line drawn. If the function name does not end with this preposition, it leaves the current position intact.

67.1.4.2 The Brush

The default brush is a white brush. You can create a new brush by calling the CreateBrushIndirect function and specifying the appropriate arguments. Once you've created a brush, you can select it into your application's device context by calling the SelectObject function.

Windows provides a complete set of functions that you can use to create, select, and alter the brush in your application's device context. For more information about these functions and about brushes in general, see Chapter 64, “Brushes.”

67.1.4.3 The Pen

The default pen is a cosmetic, black-pen that is one pixel wide. You can create a new pen by calling the ExtCreatePen function and specifying the appropriate arguments. Once you've create a pen, you can select it into your application's device context by calling the SelectObject function.

Windows provides a complete set of functions that you can use to create, select, and alter the pen in your application's device context. For more information about these functions and about pens in general, see Chapter 65, “Pens.”

67.1.4.4 The World Transformation

The default transformation is the unity transformation. You can specify a new transformation by calling the SetWorldTransform function and supplying the appropriate arguments.

Windows provides a set of functions that you can use to transform lines and curves by altering their width, location, and general appearance. For more information about these functions, see Chapter 73, “Coordinate Spaces and Transformations.”