|
|
|
GDI+ supports two different forms of a complex curve that can't be represented as an arc of a circle or an ellipse: a cardinal spline and a Bézier spline. A cardinal spline is the curve that you would create by taking a piece of flexible material-such as a thin stripe of iron or wood-and making it pass through a given set of fixed points on the X-Y plane. Unless the material you're using is infinitely flexible (as it would be a string of rope or rubber), the path drawn by the material would be a curve that doesn't create any sharp angles at the connecting points. Depending on the degree of flexibility (also known as tension) of the material used, a given set of points can generate different curves. The default tension is 0.5. The following code snippet draws five cardinal splines, with a tension that goes from 0 (which corresponds to a material with infinite flexibility, which therefore draws straight lines) to 2: |
Click here to copy the following block |
Dim gr As Graphics = Me.CreateGraphics Dim points() As Point = {New Point(100, 100), New Point(200, 200), _ New Point(250, 30), New Point(350, 100)} Dim tension As Single For tension = 0 To 2 Step 0.5 gr.DrawCurve(Pens.Blue, points, tension) Next gr.Dispose |
You can also draw a closed cardinal spline by using the DrawClosedCurve method, which takes an array of Point objects.
|
|
|
|
Submitted By :
Nayan Patel
(Member Since : 5/26/2004 12:23:06 PM)
|
|
|
Job Description :
He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting. |
View all (893) submissions by this author
(Birth Date : 7/14/1981 ) |
|
|