This topic provides examples that demonstrate how to draw lines of different widths and styles.
The examples assume common start and end points have been defined as follows:
... // set up a pair of points for drawing diagonal lines TPoint startPoint(50,50); TPoint endPoint(590,190); ...
You can draw a thin line diagonally across the screen using DrawLine() . This illustrates how thin a single pixel width line is, and the visible stepping:
Note : The line width is a single pixel by default.
Use SetPenSize() to increase the pen size to three pixels.
Use DrawLine() to draw a wide line diagonally across the screen.
Use SetPenWidth() to set the pen width to thirty pixels wide.
Use DrawLine() to draw a thirty pixel wide line, (x dimension), diagonally across the screen.
// Set up a "fat" size for the pen tip TSize penSizeFat(30,30); ... // draw a rather wide line from top left to bottom right, // illustrating rounded ends and their clipping gc.SetPenWidth(penSizeFat); gc.DrawLine(startPoint,endPoint); ...
Use SetPenStyle() to set the style of the pen to dotted.
Use DrawLine() to draw a thin dotted line diagonally across the screen.
... // draw a dotted line from top left to bottom right gc.SetPenStyle(CGraphicsContext::EDottedPen); gc.DrawLine(startPoint,endPoint); ...
Note : The pen style remains in effect until changed by another call to SetPenStyle() or the graphics context is reset to its default settings.
Use SetPenStyle() to set the style of the pen to dot-dashed.
Use DrawLine() to draw a thin dot-dashed line diagonally across the screen.
All rights reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License v1.0.