Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
Imports System.Drawing
Imports System.Collections
public class BezierSplines
public Shared Sub Main
Application.Run(New Form1)
End Sub
End class
Public Class Form1
Dim BendPoints As New Generic.List(Of Point)
Private Sub Form1_MouseClick(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles Me.MouseClick
BendPoints.Add(New Point(e.X, e.Y))
Me.Refresh()
End Sub
Private Sub Form1_Paint(ByVal sender As Object, _
ByVal e As System.Windows.Forms.PaintEventArgs) _
Handles Me.Paint
Dim canvas As Graphics = e.Graphics
If (BendPoints.Count >= 4) Then
canvas.DrawBezier(Pens.Black, BendPoints(0), BendPoints(1), BendPoints(2), BendPoints(3))
BendPoints.Clear()
End If
End Sub
End Class
<Global.Microsoft.VisualBasic.rupilerServices.DesignerGenerated()> _
Partial Class Form1
Inherits System.Windows.Forms.Form
"Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
MyBase.Dispose(disposing)
End Sub
"Required by the Windows Form Designer
Private components As System.ruponentModel.IContainer
"NOTE: The following procedure is required by the Windows Form Designer
"It can be modified using the Windows Form Designer.
"Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.SuspendLayout()
"
"Form1
"
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(531, 394)
Me.Name = "Form1"
Me.Text = "Drawing Bezier Splines"
Me.ResumeLayout(False)
End Sub
End Class
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class DrawBeziers1
public Shared Sub Main
Application.Run(New BeziersForm)
End Sub
End class
Public Class BeziersForm
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
"This call is required by the Windows Form Designer.
InitializeComponent()
"Add any initialization after the InitializeComponent() call
End Sub
"Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
"Required by the Windows Form Designer
Private components As System.ruponentModel.IContainer
"NOTE: The following procedure is required by the Windows Form Designer
"It can be modified using the Windows Form Designer.
"Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
components = New System.ruponentModel.Container()
Me.Text = "BeziersForm"
End Sub
#End Region
Private Sub ClosedCurves_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles MyBase.Paint
Dim g As Graphics = e.Graphics
Dim x As Integer = 0
Dim y As Integer = 0
Dim width As Integer = Me.ClientRectangle.Width / 3
Dim height As Integer = Me.ClientRectangle.Height
Dim pen As Pen = New Pen(Color.Red, 4)
Dim pointPen As Pen = New Pen(Color.Black, 3)
pointPen.StartCap = pointPen.EndCap = LineCap.SquareAnchor
Dim points As PointF() = New PointF() {New PointF(x + 25, y + height - 25), New PointF(x + width - 25, y + height - 25), New PointF(x + 25, y + 25), New PointF(x + width - 25, y + 25)}
g.DrawBeziers(pen, points)
End Sub
End Class
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class DrawBeziers2
public Shared Sub Main
Application.Run(New BeziersForm)
End Sub
End class
Public Class BeziersForm
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
"This call is required by the Windows Form Designer.
InitializeComponent()
"Add any initialization after the InitializeComponent() call
End Sub
"Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
"Required by the Windows Form Designer
Private components As System.ruponentModel.IContainer
"NOTE: The following procedure is required by the Windows Form Designer
"It can be modified using the Windows Form Designer.
"Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
components = New System.ruponentModel.Container()
Me.Text = "BeziersForm"
End Sub
#End Region
Private Sub ClosedCurves_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles MyBase.Paint
Dim g As Graphics = e.Graphics
Dim x As Integer = 0
Dim y As Integer = 0
Dim width As Integer = Me.ClientRectangle.Width / 3
Dim height As Integer = Me.ClientRectangle.Height
Dim pen As Pen = New Pen(Color.Red, 4)
Dim pointPen As Pen = New Pen(Color.Black, 3)
pointPen.StartCap = pointPen.EndCap = LineCap.SquareAnchor
Dim points As PointF()
points = New PointF() {New PointF(x + 25, y + 25), New PointF(x + width - 25, y + 25), New PointF(x + 25, y + height - 25), New PointF(x + width - 25, y + height - 25)}
g.DrawBeziers(pen, points)
End Sub
End Class
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class DrawBeziers3
public Shared Sub Main
Application.Run(New BeziersForm)
End Sub
End class
Public Class BeziersForm
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
"This call is required by the Windows Form Designer.
InitializeComponent()
"Add any initialization after the InitializeComponent() call
End Sub
"Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
"Required by the Windows Form Designer
Private components As System.ruponentModel.IContainer
"NOTE: The following procedure is required by the Windows Form Designer
"It can be modified using the Windows Form Designer.
"Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
components = New System.ruponentModel.Container()
Me.Text = "BeziersForm"
End Sub
#End Region
Private Sub ClosedCurves_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles MyBase.Paint
Dim g As Graphics = e.Graphics
Dim x As Integer = 0
Dim y As Integer = 0
Dim width As Integer = Me.ClientRectangle.Width / 3
Dim height As Integer = Me.ClientRectangle.Height
Dim pen As Pen = New Pen(Color.Red, 4)
Dim pointPen As Pen = New Pen(Color.Black, 3)
pointPen.StartCap = pointPen.EndCap = LineCap.SquareAnchor
Dim points As PointF()
points = New PointF() {New PointF(x + 25, y + 25), New PointF(x + width - 25, y + 25), New PointF(x + width - 25, y + height - 25), New PointF(x + 25, y + height - 25)}
g.DrawBeziers(pen, points)
End Sub
End Class
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class BezierCurveAndItsOutline
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)
" Define the Bezier curve"s control points.
Dim pts() As Point = { _
New Point(10, 10), _
New Point(200, 10), _
New Point(50, 200), _
New Point(200, 150), _
New Point(250, 50), _
New Point(250, 200), _
New Point(100, 250) _
}
Dim dashed_pen As New Pen(Color.Black, 0)
dashed_pen.DashStyle = Drawing2D.DashStyle.Dash
For i As Integer = 0 To pts.Length - 2
e.Graphics.DrawLine(dashed_pen, pts(i), pts(i + 1))
Next i
" .
e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
Dim bez_pen As New Pen(Color.Black, 3)
e.Graphics.DrawBeziers(bez_pen, pts)
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