A Drawing Program

Vector graphics deals with drawing geometric shapes such as lines, curves, and polygons. In this section we illustrate vector graphics in GDI+ with an interactive drawing program. Later in the chapter we will introduce raster graphics and bitmaps.

Our sample program, DrawDemo, allows you to draw a picture consisting of rectangles and ellipses of various sizes, colors, and patterns. The program illustrates both standard painting (implemented by an override of OnPaint) and “rubber-band” drawing, in which a shape is temporarily outlined as the mouse is moved. We also illustrate use of a clipping rectangle, which can make for more efficient drawing.

Rubber-Band Drawing

Version 1 of DrawDemo illustrates drawing a single rectangle. ...

Get Application Development Using Visual Basic® and .NET 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.