Filling Shapes

So far, we've dealt with the outline of a shape. Now we will focus on the interior, or fill area, of a shape. GDI+ gives us the concept of a brush to indicate how a shape is filled. Brushes are useful when blending colors for a desired effect like a fade or indicating a shape's texture like sand, stone, or brick. Brushes can be a single solid color, a blend of colors, a texture, a bitmap, or a hatched pattern.

To create brush objects in our code, we use a derivative of the Brush class. Brush is an abstract base class. Classes that derive from Brush are as follows: SolidBrush, TextureBrush, RectangleGradientBrush, LinearGradientBrush, and HatchBrush. This section discusses the various Brush derivatives.

SolidBrush

The SolidBrush ...

Get Visual Basic® Programmer's Guide to the .NET Framework Class Library 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.