Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class ClosedCurve
public Shared Sub Main
Application.Run(New Form1)
End Sub
End class
public class Form1
Inherits System.Windows.Forms.Form
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
Dim pts() As Point = { _
New Point(10, 50), _
New Point(200, 30), _
New Point(120, 200), _
New Point(230, 150), _
New Point(150, 50), _
New Point(250, 200), _
New Point(100, 250) _
}
e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
For tension As Single = 0 To 1 Step 0.25
Dim curve_pen As New Pen(Color.Black, tension * 4 + 1)
e.Graphics.DrawClosedCurve(curve_pen, pts, tension, Drawing2D.FillMode.Alternate)
Next tension
' Draw rectangles on the control points.
For i As Integer = 0 To pts.Length - 1
e.Graphics.FillRectangle(Brushes.White, pts(i).X - 2, pts(i).Y - 2, 5, 5)
e.Graphics.DrawRectangle(Pens.Black, pts(i).X - 2, pts(i).Y - 2, 5, 5)
Next i
End Sub
Public Sub New()
MyBase.New()
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
End Sub
End Class