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
 
 
 
 
 
TitleDraw a smooth closed curve that passes through several points and returns to its start in VB.NET
DescriptionThis example shows how to draw a smooth closed curve that passes through several points and returns to its start in VB.NET. This example demonstrates the Graphics object's DrawClosedCurve method.
Keywordscurve, DrawClosedCurve, smooth curve, VB.NET
CategoriesGraphics, VB.NET
 
This example builds an array of Point objects and passes it to the Graphics object's DrawClosedCurve method. It then loops through the array drawing a white rectangle with a black outline to showe where each point lies.
 
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As _
    System.Windows.Forms.PaintEventArgs) Handles _
    MyBase.Paint
    Dim pts() As Point = { _
        New Point(50, 50), _
        New Point(250, 150), _
        New Point(150, 200), _
        New Point(100, 90), _
        New Point(50, 120) _
    }
    e.Graphics.SmoothingMode = _
        Drawing2D.SmoothingMode.AntiAlias

    ' Draw the curve.
    e.Graphics.DrawClosedCurve(Pens.Black, pts)

    ' Draw the points.
    For i As Integer = 0 To pts.Length - 1
        e.Graphics.FillRectangle(Brushes.White, pts(i).X - _
            2, pts(i).Y - 2, 4, 4)
        e.Graphics.DrawRectangle(Pens.Black, pts(i).X - 2, _
            pts(i).Y - 2, 4, 4)
    Next i
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated