GDI+: Introduction to Brushes |
|
Line-based and closed shapes figure require a pen to show their shape. The particularity with closed shapes is that they can be filled, with a color, a picture, or a pattern. A brush is an object that holds a color, a picture, or a drawing pattern and that is used to fill the interior of a closed shape. This definition also means that there are various types of brushes with different goals. To meet these goals, the .NET Framework provides support for brushes in various namespaces with different classes. The parent of all brushes is the Brush class defined in the System.Drawing namespace.
Because the main job of a brush is to fill a closed shape, the Graphics class provides a method that corresponds to each of the closed shapes we reviewed to draw in the previous lesson in order to fill it. The methods are:
To fill out a shape, call one of these methods, pass it a brush value, followed by the location and dimensions of the shape. For example, if you want to draw a rectangle and fill it with a brush, you would use code similar to: Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) _ Handles MyBase.Paint e.Graphics.FillRectangle(SomeBrush, 20, 20, 200, 160) End Sub Over all, there are four types of brushes. |
|
||
Home | Copyright © 2004-2010 FunctionX, Inc. | |
|