Working with Pens
A pen is an object that defines line-drawing characteristics. Pens are used to define color, line width, and line style (solid, dashed, and so on), and pens are used with almost all the drawing methods you'll learn about in this hour.
C# supplies a number of predefined pens, and you can also create your own. To create your own pen, use the following syntax:
Pen variable = new Pen(color, width);
After a pen is created, you can set its properties to adjust its appearance. For example, all Pen objects have a DashStyle property that determines the appearance of lines drawn with the pen. Table 10.2 lists the possible values for DashStyle.
Value | Description |
---|---|
Dash | Specifies a line consisting ... |
Get Sams Teach Yourself C#™ in 24 Hours now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.