Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleUse a Pen object's CompoundArray property to give the pen longitudinal stripes in Visual Basic 2005
DescriptionThis example shows how to use a Pen object's CompoundArray property to give the pen longitudinal stripes in Visual Basic 2005.
KeywordsPen, CompoundArray, longitudinal stripes, Visual Basic 2005
CategoriesGraphics, VB.NET
 
To make longitudinal stripes in a line, set a Pen object's CompoundArray property. The values in this array give the fraction of the line's width where drawing should start and stop. The values must be in ascending order, must be between 0.0 and 1.0, and must include an even number of elements (start/stop pairs).

This example uses two pens with different CompoundArray values to draw an ellipse and a diamond.

 
Using the_pen As New Pen(Color.Green, 10)
    the_pen.CompoundArray = New Single() {0.0, 0.1, 0.3, _
        0.7, 0.9, 1.0}
    e.Graphics.DrawEllipse(the_pen, 20, 20, 200, 100)
End Using

Using the_pen As New Pen(Color.Blue, 20)
    Dim pts() As Point = { _
        New Point(150, 50), _
        New Point(250, 150), _
        New Point(150, 250), _
        New Point(50, 150) _
    }
    the_pen.Color = Color.Blue
    the_pen.CompoundArray = New Single() {0.0, 0.1, 0.2, _
        0.4, 0.6, 1.0}
    e.Graphics.DrawPolygon(the_pen, pts)
End Using
 
 
Copyright © 1997-2006 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated