Brush


The Brush object determines how areas are filled when you draw them using the Graphics object’s methods FillClosedCurve, FillEllipse, FillPath, FillPie, FillPolygon, FillRectangle, and FillRectangles. Different types of Brushes fill areas with solid colors, hatch patterns, and color gradients.

The Brush class itself is an abstract or MustInherit class, so you cannot make instances of the Brush class itself. Instead, you can create instances of one of the derived classes SolidBrush, TextureBrush, HatchBrush, LinearGradientBrush, and PathGradientBrush. The following table briefly describes these classes.

Open table as spreadsheet

Class

Purpose

SolidBrush

Fills areas with a single solid color

TextureBrush

Fills areas with a repeating image

HatchBrush

Fills areas with a repeating hatch pattern

LinearGradientBrush

Fills areas with a linear gradient of two or more colors

PathGradientBrush

Fills areas with a color gradient that follows a path

The following sections describe these classes in more detail and provide examples.

SolidBrush

A SolidBrush class fills areas with a single solid color. This class is extremely simple. It provides a single constructor that takes a parameter giving the brush’s color. Its only commonly useful property is Color, which determines the brush’s color.

A program can create a SolidBrush using its constructor, or it can use one of the 280+ predefined solid brushes defined by the Brushes class. The following code demonstrates both techniques. First, it creates a red SolidBrush and uses it to fill a rectangle. Then, it uses the Brushes class’s Blue property to get a standard blue solid brush and fills another rectangle with that brush.

  Private Sub Form1_Paint(ByVal sender As Object, _  ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint     Dim red_brush As New SolidBrush(Color.Red)     e.Graphics.FillRectangle(red_brush, 10, 10, 200, 100)     Dim blue_brush As Brush = Brushes.Blue     e.Graphics.FillRectangle(blue_brush, 10, 120, 200, 100) End Sub  

TextureBrush

A TextureBrush class fills areas with an image, usually a Bitmap. The following table describes this class’s most useful properties and methods.

Open table as spreadsheet

Property or Method

Purpose

Image

The image that the brush uses to fill areas.

MultiplyTransform

Multiplies the brush’s current transformation by another transformation matrix.

ResetTransform

Resets the brush’s transformation to the identity transformation.

RotateTransform

Adds a rotation transformation to the brush’s current transformation.

ScaleTransform

Adds a scaling transformation to the brush’s current transformation.

Transform

A transformation that the brush applies to its image before using it to fill areas.

TranslateTransform

Adds a translation transformation to the brush’s current transformation.

WrapMode

Determines how the brush wraps the image. This property can take the values Clamp (use a single copy that overlaps the origin of the shape’s bounding rectangle), Tile (tile normally), TileFipX (tile flipping every other column of images over horizontally), TileFlipY (tile flipping every other row of images over vertically), and TileFlipXY (tile flipping every other column horizontally and every other row vertically). Figure 21-8 shows examples of these settings.

If you look closely at Figure 21-8, you’ll see that the images do not always begin in the upper-left corner of the shape being filled. The brush essentially sets its tiling origin to the form’s upper-left corner and then spaces its images accordingly.

image from book
Figure 21-8: The TextureBrush class’s WrapMode property determines how the brush tiles its image.

If you want to move the tiling origin, you can apply a translation transformation to the brush to move the image to the new origin. The following code creates a TextureBrush using a PictureBox’s Image property to define its image and sets WrapMode to TileFlipXY. It translates the brush to the point (50, 100) and then fills a rectangle with upper-left corner at this same point. This ensures that the first copy of the brush’s image is placed exactly in the rectangle’s upper-left corner. It also ensures that the first image is not flipped vertically or horizontally.

  ' Make a TextureBrush using the smiley face. Using texture_brush As New TextureBrush(picSmiley.Image)     texture_brush.WrapMode = System.Drawing.Drawing2D.WrapMode.TileFlipXY     texture_brush.TranslateTransform(50, 100)     DrawSample(e.Graphics, texture_brush, 50, 100) End Using  

The following code uses a transformed TextureBrush. First, it generates points to define a star-shaped polygon and creates a TextureBrush using a PictureBox Image property to define its image. Next, the program scales the brush by a factor of 2 in the X direction, making the smiley face wider than normal. It then rotates the brush by 30 degrees, fills the star-shaped polygon with the brush, and then outlines the polygon in black.

  Private Sub Form1_Paint(ByVal sender As Object, _  ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint     ' Generate points to draw a star shape.     Dim cx As Integer = Me.ClientSize.Width \ 2     Dim cy As Integer = Me.ClientSize.Height \ 2     Dim r1 As Integer = Min(cx, cy) - 10     Dim r2 As Integer = Min(cx, cy) \ 2     Dim pts(9) As Point     For i As Integer = 0 To 9 Step 2         pts(i).X = cx + CInt(r1 * Cos(i * PI / 5 - PI / 2))         pts(i).Y = cy + CInt(r1 * Sin(i * PI / 5 - PI / 2))         pts(i + 1).X = cx + CInt(r2 * Cos((i + 1) * PI / 5 - PI / 2))         pts(i + 1).Y = cy + CInt(r2 * Sin((i + 1) * PI / 5 - PI / 2))     Next i     ' Make a TextureBrush using the smiley face.     Using texture_brush As New TextureBrush(picSmiley.Image)         texture_brush.ScaleTransform(2, 1, MatrixOrder.Append)         texture_brush.RotateTransform(30, MatrixOrder.Append)         e.Graphics.FillPolygon(texture_brush, pts)     End Using     e.Graphics.DrawPolygon(Pens.Black, pts) End Sub 

Figure 21-9 shows the result. Note that not only is the image transformed, but the tiled rows and columns are also transformed.

image from book
Figure 21-9: This star is filled with a TextureBrush that is scaled and rotated.

HatchBrush

A TextureBrush class gives you complete control over every pixel in the filled area. You could build your own images to use as hatch patterns, but it’s generally easier to use the HatchBrush class.

HatchBrush is a relatively simple class. Its three most useful properties are BackgroundColor, ForegroundColor, and HatchStyle. ForegroundColor and BackgroundColor determine the colors the brush uses. HatchStyle can take one of 54 values. Figure 21-10 lists the HatchStyle values and shows samples.

image from book
Figure 21-10: The HatchStyle enumeration determines which of 54 patterns a HatchBrush uses to fill an area.

The following code shows how a program can fill a rectangle with a HatchBrush. It makes a brush using the LargeConfetti style with a blue foreground and light blue background. It calls a Graphics object’s FillRectangle method to fill a rectangle with this brush, and then calls DrawRectangle to outline the rectangle in black.

  Using the_brush As New HatchBrush(HatchStyle.LargeConfetti, _   Color.Blue, Color.LightBlue)     gr.FillRectangle(the_brush, 10, 10, 200, 200)     gr.DrawRectangle(Pens.Black, 10, 10, 200, 200) End Using 

LinearGradientBrush

A LinearGradientBrush class fills areas with a linear gradient of two or more colors. The simplest of these brushes shades an area smoothly from one color to another along a specified direction. For example, a rectangle might be red at one end and shade smoothly to blue at the other.

With some extra work, you can specify exactly how the colors blend from one to the other. For example, you could make the colors blend quickly at the start and then slowly across the rest of the rectangle.

You can also specify more than two colors for the brush. You could make the colors blend from red to green to blue.

The following table describes the LinearGradientBrush class’s most useful properties and methods.

Open table as spreadsheet

Property or Method

Purpose

Blend

A Blend object that determines how quickly the colors blend across the brush. By default, this is a simple linear blending.

InterpolationColors

A ColorBlend object that determines the colors (possibly more than two) that the brush blends and their positions within the blend.

LinearColors

An array of two colors that determines the starting and ending colors for a simple linear blend.

MultiplyTransform

Multiplies the brush’s current transformation by another transformation matrix.

ResetTransform

Resets the brush’s transformation to the identity transformation.

RotateTransform

Adds a rotation transformation to the brush’s current transformation.

ScaleTransform

Adds a scaling transformation to the brush’s current transformation.

SetBlendTriangularShape

Makes the brush use a midpoint gradient where the color blends from the start color to the end color, and then back to the start color. You could do something similar with the Blend property, but this is easier.

SetSigmaBellShape

Makes the brush’s color gradient change according to a bell curve instead of linearly.

Transform

A transformation that the brush applies to its gradient before using it to fill areas.

TranslateTransform

Adds a translation transformation to the brush’s current transformation.

WrapMode

Determines how the brush wraps when it doesn’t completely fill the area. This property can take the values Clamp, Tile, TileFipX, TileFlipY, and TileFlipXY. Because the brush is infinitely tall in the direction perpendicular to the line that determines its direction, not all of these values make a difference for all brushes.

Figure 21-11 shows an assortment of LinearGradientBrush objects.

image from book
Figure 21-11: LinearGradientBrush objects can produce all these effects and more.

The following code fills the rectangles shown in Figure 21-11. As you step through the code, refer to the figure to see the result.

The code begins by making a relatively straightforward LinearGradientBrush shading from black to white along the line starting at (9, 10) and ending at (210, 10). It then fills a rectangle with the brush. Notice that the points defining the brush determine the brush’s drawing origin. The rectangle’s X coordinates cover the same range as those of the brush, so the brush’s origin lines up nicely with the rectangle. If the two did not line up, then the brush would finish its gradient before it reached the end of the rectangle and it would need to wrap. Usually, you will want the brush to line up with the object it is filling. You can arrange that by carefully defining the brush to fit over the object or by using a transformation to make it fit.

Next, the code creates a ColorBlend object. It passes the object’s constructor the value 3 to indicate that it will use three colors. The code sets the ColorBlend object’s Colors property to an array containing the three colors black, white, and black. This example uses black and white, so the result will show up well in the book, but you could use any colors here such as orange, hot pink, and blue. Next, the code sets the ColorBlend object’s Positions property to an array of Singles that define the positions within the blend where the colors should be located. In this example, the first color (black) begins 0.0 of the way through the blend, the second color (white) sits 0.2 or 20 percent of the distance through the blend, and the third color (black again) sits at the end of the blend. You can see in Figure 21-11 that the white area is to the left of the center in this rectangle.

The code then creates a Blend object, passing its constructor the parameter 4 to indicate that the program will set four blend points. It sets the object’s Factors property to an array of Singles that determine the fraction of the blend that should occur at the four points. It then sets the object’s Positions property to an array that sets the positions of the blend points. In this example, the point 0.0 of the distance through the blend has factor 0.0, so the blend has not begun and that point has the start color. The point 0.2 of the distance through the blend has a factor of 0.5, so the blend should be half done at that point. The point 0.8 of the distance through the blend has a factor of 0.5, so the blend should still be only half done at that point. Finally, the point at the end of the blend should have the end color. The result is a blend that changes quickly initially, remains fixed for a stretch in the middle, and then finishes quickly. (An optical illusion makes the area on the left of the flat region in the middle appear brighter than it really is, and the area on the right appears darker than it really is.)

Next, the program makes a LinearGradientBrush that is defined by points too close together to cover its whole rectangle. The brush repeats its gradient as many times as necessary to cover the rectangle.

The program then changes the previous brush’s WrapMode property to TileFlipX. When the brush must repeat its gradient to fill the rectangle, it reverses the start and end colors to produce a series of gradient bands.

Next, the program calls a brush’s SetBlendTriangularShape method. This makes the gradient shade from the start color to the end color and back. The SetBlendTriangularShape method’s parameter gives the position in the gradient where the end color should occur. You could get a similar affect using a Blend, but this method is easier for this kind of fill.

The program then calls the brush’s SetSigmaBellShape method. It uses the same position parameter 0.5 as the previous call to SetBlendTriangularShape, so it places the end color in the middle of the gradient. The effect is similar to the triangular brush, except that the colors vary according to a bell curve instead of linear relationship. These two rectangles are lined up vertically in Figure 21-11, so it is easy to see the difference.

The code defines the final brush with a line that is not horizontal, so its gradient moves diagonally across its rectangle.

  Private Sub Form1_Paint(ByVal sender As Object, _  ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint     Dim y As Integer = 10     Dim x As Integer = 10     Dim wid As Integer = 200     Dim hgt As Integer = 50     ' Make a rectangle that shades from black to white.     e.Graphics.DrawString("Simple", Me.Font, Brushes.Black, x, y)     y += 15     Using black_white_brush As New _         LinearGradientBrush( _             New Point(x, y), New Point(x + wid, y), _             Color.Black, Color.White)         e.Graphics.FillRectangle(black_white_brush, _             x, y, wid, hgt)         y += hgt + 10         ' ColorBlend.         e.Graphics.DrawString("ColorBlend", Me.Font, Brushes.Black, x, y)         y += 15         Dim color_blend As New ColorBlend(3)         color_blend.Colors = New Color() {Color.Red, Color.Green, Color.Blue}         color_blend.Colors = New Color() {Color.Black, Color.White, Color.Black}         color_blend.Positions = New Single() {0.0, 0.2, 1.0}         black_white_brush.InterpolationColors = color_blend         e.Graphics.FillRectangle(black_white_brush, _             x, y, wid, hgt)         y += hgt + 10         ' Make a brush that makes 50 percent of the color change         ' in the first 20 percent of the distance, stays there         ' until 80 percent of the distance, and then finishes         ' in the remaining distance.         e.Graphics.DrawString("Blend", Me.Font, Brushes.Black, x, y)         y += 15         Dim the_blend As New Blend(4)         the_blend.Factors = New Single() {0.0, 0.5, 0.5, 1.0}         the_blend.Positions = New Single() {0.0, 0.2, 0.8, 1.0}         black_white_brush.Blend = the_blend         e.Graphics.FillRectangle(black_white_brush, _             x, y, wid, hgt)         y += hgt + 10         ' This brush's line is too short to cross the whole rectangle.         e.Graphics.DrawString("Short", Me.Font, Brushes.Black, x, y)         y += 15         Using short_brush As New _                 LinearGradientBrush( _                     New Point(x, y), New Point(x + 50, y), _                      Color.Black, Color.White)             e.Graphics.FillRectangle(short_brush, _                 x, y, wid, hgt)             y += hgt + 10             x += wid + 10             y = 10             ' Change the brush's WrapMode.             e.Graphics.DrawString("WrapMode = TileFlipX", Me.Font, _                 Brushes.Black, x, y)             y += 15             short_brush.WrapMode = WrapMode.TileFlipX             e.Graphics.FillRectangle(short_brush, _                 x, y, wid, hgt)             y += hgt + 10         End Using ' short_brush         ' Trangular brush.         e.Graphics.DrawString("SetBlendTriangularShape", Me.Font, _             Brushes.Black, x, y)         y += 15         black_white_brush.SetBlendTriangularShape(0.5)         e.Graphics.FillRectangle(black_white_brush, _             x, y, wid, hgt)         y += hgt + 10     End Using ' black_white_brush     ' Sigma bell shape.     e.Graphics.DrawString("SetSigmaBellShape", Me.Font, Brushes.Black, x, y)     y += 15     black_white_brush.SetSigmaBellShape(0.5, 1)     e.Graphics.FillRectangle(black_white_brush, _         x, y, wid, hgt)     y += hgt + 10     ' A diagonal brush.     x += wid + 10     y = 10     wid = hgt     e.Graphics.DrawString("Diagonal", Me.Font, Brushes.Black, x, y)     y += 15     Dim diag_brush As New _         LinearGradientBrush( _             New Point(x, y), New Point(x + wid, y + hgt), _             Color.Black, Color.White)     e.Graphics.FillRectangle(diag_brush, _         x, y, wid, hgt)     y += hgt + 10 End Sub   

PathGradientBrush

A PathGradientBrush object fills areas with a color gradient that blends colors from a center point to the points along a path. For example, you might shade from white in the middle of an ellipse to blue along its edges.

The Blend, InterpolationColors, SetBlendTriangularShape, SetSigmaBellShape, and other properties and methods that deal with the characteristics of the blend work along lines running from the center point to the points on the path. For example, you can use this object’s Blend property to determine how quickly colors blend across the brush. In the LinearGradientBrush class, this property determines how the colors blend from one side of the brush to the other. In a PathGradientBrush, it controls how the colors blend from the center point to the path’s points.

The following table describes the PathGradientBrush object’s most useful properties and methods.

Open table as spreadsheet

Property or Method

Purpose

Blend

A Blend object that determines how quickly the colors blend across the brush. By default, this is a simple linear blending.

CenterColor

Determines the color at the center point.

CenterPoint

Determines the location of the center point. By default, this point is set to the center of the path.

InterpolationColors

A ColorBlend object that determines the colors (possibly more than two) that the brush blends and their positions within the blend.

MultiplyTransform

Multiplies the brush’s current transformation by another transformation matrix.

ResetTransform

Resets the brush’s transformation to the identity transformation.

RotateTransform

Adds a rotation transformation to the brush’s current transformation.

ScaleTransform

Adds a scaling transformation to the brush’s current transformation.

SetBlendTriangularShape

Makes the brush use a midpoint gradient where the color blends from the start color to the end color and then back to the start color. You could do something similar with the Blend property, but this is easier.

SetSigmaBellShape

Makes the brush’s color gradient change according to a bell curve instead of linearly.

SurroundColors

An array of Colors that correspond to the points on the path. The color gradient blends from the CenterColor to these colors around the edge of the path. If there are more points in the path than colors, the final color is repeated as needed. Note that curves such as ellipses define a large number of colors that you do not explicitly specify, so making these colors match up with points on the curve can be difficult. This property is easier to understand for polygons.

Transform

A transformation that the brush applies to its gradient before using it to fill areas.

TranslateTransform

Adds a translation transformation to the brush’s current transformation.

WrapMode

Determines how the brush wraps when it doesn’t completely fill the area. This property can take the values Clamp, Tile, TileFipX, TileFlipY, and TileFlipXY. Because the brush is infinitely tall in the direction perpendicular to the line that determines its direction, not all of these values make a difference for all brushes.

Figure 21-12 shows an assortment of PathGradientBrush objects.

image from book
Figure 21-12: PathGradientBrush objects can produce all these effects and more.

The following code fills the shapes shown in Figure 21-12. As you step through the code, refer to the fig-ure to see the result.

The code first creates an array of Point objects initialized to form a rectangle. It passes those points to the constructor for a PathGradientBrush and then uses the brush to fill that rectangle. This is about the simplest PathGradientBrush you can build, so it’s worth studying a bit before moving on to more confusing examples. Notice that the color shades smoothly from black in the center to white on the rectangle’s edges (those are the default colors).

Next, the program makes a GraphicsPath object and adds an ellipse to it. It passes the GraphicsPath to the PathGradientBrush object’s constructor. It then sets the brush’s CenterColor and SurroundColors properties. The SurroundColors array doesn’t contain enough values for every point on the elliptical path, so the last color (black) is repeated as much as necessary. The program fills the ellipse with this brush.

The code then creates a new GraphicsPath object, adds a new ellipse, and uses it to make a Path?GradientBrush as before. It also sets the brush’s CenterColor and SurroundColors properties as before. The program then calls the brush’s SetBlendTriangularShape method to make the colors along the lines from the center point to the path’s edges blend from the end color to the start color and back. The parameter 0.5 makes the start color appear halfway from the center point to the edge.

Next, the program repeats these same steps, except that it calls the brush’s SetSigmaBellShape method instead of SetBlendTriangularShape. The result is similar to the previous result, except that the colors vary according to a bell curve instead of a linear relationship.

The code then generates an array of points that defines a star shape. It creates a new GraphicsPath object and calls its AddPolygon method to add the star. It passes this GraphicsPath object to the PathGradientBrush object’s constructor to make the brush use the star as its path. The program then sets the brush’s SurroundPoints property to an array containing the Colors it should use for each of the star’s points. The code fills the star using this brush to draw a star where the tips of the star are black and the rest of the shape’s points vary from white to black.

Finally, the program repeats the previous steps to define a new star-shaped brush. It creates a new Blend object and sets its Position and Factors properties to indicate how the gradient should progress from the center point to the shape’s edges. The Positions values give locations along a line from the center to an edge point. The Factors values indicate how far the blend should have progressed for the corresponding point. For example, this code’s second entries for those arrays are 0.25 and 1.0 to indicate that the point one quarter of the distance from the center point to an edge point should have blended completely to the end color. This example sets its Factors values so the color blends from the start color to the end color several times.

  Private Sub Form1_Paint(ByVal sender As Object, _  ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint     Dim x As Integer = 10     Dim y As Integer = 10     Dim wid As Integer = 100     Dim hgt As Integer = 50     ' Fill a rectangle.     Dim rect_pts() As Point = { _         New Point(x, y), _         New Point(x + wid, y), _         New Point(x + wid, y + hgt), _         New Point(x, y + hgt) _     }     Dim path_brush As New PathGradientBrush(rect_pts)     e.Graphics.FillPolygon(path_brush, rect_pts)     y += hgt + 10     ' Fill an ellipse setting CenterColor and SurroundColors.     Dim ellipse_path As New GraphicsPath     ellipse_path.AddEllipse(x, y, wid, hgt)     path_brush = New PathGradientBrush(ellipse_path)     path_brush.CenterColor = Color.White     path_brush.SurroundColors = New Color() {Color.Black}     e.Graphics.FillEllipse(path_brush, x, y, wid, hgt)     y += hgt + 10     ' Fill an ellipse using SetBlendTriangularShape.     ellipse_path = New GraphicsPath     ellipse_path.AddEllipse(x, y, wid, hgt)     path_brush = New PathGradientBrush(ellipse_path)     path_brush.CenterColor = Color.White     path_brush.SurroundColors = New Color() {Color.Black}     path_brush.SetBlendTriangularShape(0.5)     e.Graphics.FillEllipse(path_brush, x, y, wid, hgt)     y += hgt + 10     ' Fill an ellipse using SetSigmaBellShape.     ellipse_path = New GraphicsPath     ellipse_path.AddEllipse(x, y, wid, hgt)     path_brush = New PathGradientBrush(ellipse_path)     path_brush.CenterColor = Color.White     path_brush.SurroundColors = New Color() {Color.Black}     path_brush.SetSigmaBellShape(0.5, 1)     e.Graphics.FillEllipse(path_brush, x, y, wid, hgt)     y += hgt + 10     ' Fill a star shape.     x += wid + 10     y = 10     wid = 150     hgt = 150     Dim cx As Integer = x + wid \ 2     Dim cy As Integer = y + hgt \ 2     Dim r1 As Integer = CInt(wid * 0.5)     Dim r2 As Integer = CInt(hgt * 0.25)     Dim star_pts(9) As Point     For i As Integer = 0 To 9 Step 2         star_pts(i).X = cx + CInt(r1 * Cos(i * PI / 5 - PI / 2))         star_pts(i).Y = cy + CInt(r1 * Sin(i * PI / 5 - PI / 2))         star_pts(i + 1).X = cx + CInt(r2 * Cos((i + 1) * PI / 5 - PI / 2))         star_pts(i + 1).Y = cy + CInt(r2 * Sin((i + 1) * PI / 5 - PI / 2))     Next i     Dim star_path As New GraphicsPath     star_path.AddPolygon(star_pts)     Dim star_brush As New PathGradientBrush(star_pts)     star_brush.CenterColor = Color.Black     star_brush.SurroundColors = New Color() { _         Color.Black, Color.White, _         Color.Black, Color.White, _         Color.Black, Color.White, _         Color.Black, Color.White, _         Color.Black, Color.White _     }     e.Graphics.FillPolygon(star_brush, star_pts)     y += hgt + 10     ' Fill a star shape.     cx = x + wid \ 2     cy = y + hgt \ 2     r1 = CInt(wid * 0.5)     r2 = CInt(hgt * 0.25)     For i As Integer = 0 To 9 Step 2         star_pts(i).X = cx + CInt(r1 * Cos(i * PI / 5 - PI / 2))         star_pts(i).Y = cy + CInt(r1 * Sin(i * PI / 5 - PI / 2))         star_pts(i + 1).X = cx + CInt(r2 * Cos((i + 1) * PI / 5 - PI / 2))         star_pts(i + 1).Y = cy + CInt(r2 * Sin((i + 1) * PI / 5 - PI / 2))     Next i     star_path = New GraphicsPath     star_path.AddPolygon(star_pts)     star_brush = New PathGradientBrush(star_pts)     star_brush.CenterColor = Color.White     star_brush.SurroundColors = New Color() { _         Color.White, Color.Black, _         Color.White, Color.Black, _         Color.White, Color.Black, _         Color.White, Color.Black, _         Color.White, Color.Black _     }     Dim star_blend As New Blend     star_blend.Positions = New Single() {0.0, 0.25, 0.5, 0.75, 1.0}     star_blend.Factors = New Single() {0.0, 1.0, 0.0, 1.0, 0.0}     star_brush.Blend = star_blend     e.Graphics.FillPolygon(star_brush, star_pts)     ' Draw the outline in white to remove some     ' incorrectly drawn pixels.     e.Graphics.DrawPolygon(Pens.White, star_pts)     path_brush.Dispose()     ellipse_path.Dispose()     star_brush.Dispose()     star_path.Dispose() End Sub 




Visual Basic 2005 with  .NET 3.0 Programmer's Reference
Visual Basic 2005 with .NET 3.0 Programmer's Reference
ISBN: 470137053
EAN: N/A
Year: 2007
Pages: 417

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net