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 curve that passes through several points in VB.NET
DescriptionThis example shows how to draw a smooth curve that passes through several points in VB.NET. This example demonstrates the Graphics object's DrawCurve method.
Keywordscurve, DrawCurve, smooth curve, VB.NET
CategoriesGraphics, VB.NET
 
This example builds an array of Point objects and passes it to the Graphics object's DrawCurve 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.DrawCurve(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