DRAWING BASICS

The previous section describes the UsePrintPreview example program, which draws some simple shapes and text. It focuses mostly on the PrintDocument events that support the printing process, however, and glosses over exactly how the graphics are drawn.

A program uses three things to produce graphics: a Graphics object, pens, and brushes. It uses those things whether the output should be printed on a printer, displayed on the screen, or drawn into an image file such as a bitmap or JPG file.

The following sections describe Graphics objects, pens, and brushes.

Graphics Objects

A Graphics object represents a drawing surface. You can think of it as the canvas or paper on which the program will draw.

The Graphics class provides many methods for drawing lines, rectangles, curves, and other shapes. The following table summarizes these methods.

METHOD DESCRIPTION
DrawArc Draws an arc of an ellipse.
DrawBezier Draws a Bézier curve.
DrawBeziers Draws a series of Bézier curves.
DrawClosedCurve Draws a smooth closed curve that joins a series of points, connecting the final point to the first point.
DrawCurve Draws a smooth curve that joins a series of points. This is similar to a DrawClosedCurve, except that it doesn’t connect the final point to the first point.
DrawEllipse Draws an ellipse. (To draw a circle, draw an ellipse with equal width and height.)
DrawIcon Draws an icon.
DrawIconUnstretched Draws an icon without scaling. If you know that you will not ...

Get Visual Basic 2012 Programmer's Reference 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.