Brushes in GDI+

In the .NET Framework library, the Brush class is an abstract base class, which means you cannot create an instance of it without using it's derived classes. All usable classes are inherited from the abstract Brush class.

 

Figure 4.1. Classes inherited from the Brush class

GDI+ provides four different kinds of brushes; solid, hatch, texture, gradient.

Figure 4.2. Brush types and their classes

Brushes Class

The Brushes class is a sealed class( it cannot be inherited). Brushes provides more than 140 static memebers(properties), and each of these members respesents a brush with a particular color.

Solid Brushes

A solid brush is a brush that fill an area with single solid color.

SolidBrush( Color );

Hatch Brushes

Hatch brushes are brushes with a hatch style, a foreground color, and a  background color. Hatches are a combination of rectangle lines and the area between the lines. The foreground color defines the color of lines; the background color defines the color between lines.

HatchBrush( HatchStyle, Color );

HatchBrush( HatchStyle, Color, Color );

Texture Brushes

Texture brushes allow us to use an image as a brush and fill GDI+ object with the brush. Texture brushes are useful when you need to fill a graphics object with images in a pattern such as tile.

Gradient Brushes

Linear gradient brushes allow you to blend two colors together, generating an indefinite range of shades.

LinearGradientBrush( Rectangle, Color, Color, LinearGaridentMode );

Path Gradient Brushes

A graphics path is a collection of lines and curves. In GDI+, the PathGradientBrush object fills a graphics paths with a gradient.

Like LinearGradientBrush, PathGradientBrush is a combination of two colors ,but instead of starting with one color and ending with another, PathGradientBrush starts from the center of a graphics path and ends at the outside boundary of the path.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章