Leadtools Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
ToBezierPoints Method
See Also  Example
Leadtools Namespace > RasterCurve Class : ToBezierPoints Method



Converts the curve points to an array of Bezier points.

Syntax

Visual Basic (Declaration) 
Public Function ToBezierPoints() As Point()
Visual Basic (Usage)Copy Code
Dim instance As RasterCurve
Dim value() As Point
 
value = instance.ToBezierPoints()
C# 
public Point[] ToBezierPoints()
C++/CLI 
public:
array<Point>^ ToBezierPoints(); 

Return Value

An array of Point values that contain the Bezier points.

Example

This sample draws a smooth closed curve on a graphics that goes through five points.

Visual BasicCopy Code
Public Sub ToBezierPointsExample()
 ' Define the curve
 Dim curve As RasterCurve = New RasterCurve()

 curve.Points.Add(New Point(130, 130))
 curve.Points.Add(New Point(130, 300))
 curve.Points.Add(New Point(230, 230))
 curve.Points.Add(New Point(175, 175))
 curve.Points.Add(New Point(230, 130))

 curve.Type = RasterCurveType.Standard
 curve.FillMode = FillMode.Winding
 curve.Tension = 0.5
 curve.Close = RasterCurveClose.Close

 ' convert this curve into bezier points
 Dim bezierPoints As Point() = curve.ToBezierPoints()

 ' Draw this curve on a bitmap
 Dim btmp As Bitmap = New Bitmap(400, 400)
 Dim g As Graphics = Graphics.FromImage(btmp)
 g.FillRectangle(Brushes.White, New Rectangle(0, 0, 400, 400))
 g.DrawBeziers(Pens.Black, bezierPoints)
 g.Dispose()

 ' save this image to disk
 Dim fileName As String = LeadtoolsExamples.Common.ImagesPath.Path + "ToBezierPoints.bmp"
 btmp.Save(fileName, ImageFormat.Bmp)

 btmp.Dispose()
      End Sub
C#Copy Code
public void ToBezierPointsExample() 

   // Define the curve 
   RasterCurve curve = new RasterCurve(); 
 
   curve.Points.Add(new Point(130, 130)); 
   curve.Points.Add(new Point(130, 300)); 
   curve.Points.Add(new Point(230, 230)); 
   curve.Points.Add(new Point(175, 175)); 
   curve.Points.Add(new Point(230, 130)); 
 
   curve.Type = RasterCurveType.Standard; 
   curve.FillMode = FillMode.Winding; 
   curve.Tension = 0.5; 
   curve.Close = RasterCurveClose.Close; 
 
   // convert this curve into bezier points 
   Point[] bezierPoints = curve.ToBezierPoints(); 
 
   // Draw this curve on a bitmap 
   Bitmap btmp = new Bitmap(400, 400); 
   Graphics g = Graphics.FromImage(btmp); 
   g.FillRectangle(Brushes.White, new Rectangle(0, 0, 400, 400)); 
   g.DrawBeziers(Pens.Black, bezierPoints); 
   g.Dispose(); 
 
   // save this image to disk 
   string fileName = LeadtoolsExamples.Common.ImagesPath.Path + "ToBezierPoints.bmp"; 
   btmp.Save(fileName, ImageFormat.Bmp); 
 
   btmp.Dispose(); 
}

Remarks

This method is used to convert a standard curve to an array of Bezier control points. A standard curve (RasterCurveType.Standard) is defined by the current RasterCurve. The standard curve passes through all of the points in the Points collection, and is continuous at each point. This method can be used to draw a curve by converting it to an array of Bezier points, using Graphics.DrawBeziers to draw the equivalent Bezier(s).

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family

See Also