Cómo: Dibujar una secuencia de curvas spline de Bézier

Actualización: noviembre 2007

Puede utilizar el método DrawBeziers de la clase Graphics para dibujar una secuencia de curvas spline de Bézier conectadas.

Ejemplo

En el ejemplo siguiente se dibuja una curva formada por dos curvas spline de Bézier conectadas. El extremo de la primera curva spline de Bézier es el punto de inicio de la segunda curva spline de Bézier.

En la ilustración siguiente se muestran la curvas spline conectadas y los siete puntos.

' Point(10, 100) = start point of first spline
' Point(75, 10) = first control point of first spline
' Point(80, 50) = second control point of first spline

' Point(100, 150) = endpoint of first spline and start point of second spline

' Point(125, 80) = first control point of second spline
' Point(175, 200) = second control point of second spline
' Point(200, 80)} = endpoint of second spline
Dim p As Point() = { _
       New Point(10, 100), _
       New Point(75, 10), _
       New Point(80, 50), _
       New Point(100, 150), _
       New Point(125, 80), _
       New Point(175, 200), _
       New Point(200, 80)}

Dim pen As New Pen(Color.Blue)
e.Graphics.DrawBeziers(pen, p)

Point[] p = {
   new Point(10, 100),   // start point of first spline
   new Point(75, 10),    // first control point of first spline
   new Point(80, 50),    // second control point of first spline

   new Point(100, 150),  // endpoint of first spline and 
                         // start point of second spline

   new Point(125, 80),   // first control point of second spline
   new Point(175, 200),  // second control point of second spline
   new Point(200, 80)};  // endpoint of second spline

Pen pen = new Pen(Color.Blue);
e.Graphics.DrawBeziers(pen, p);

Compilar el código

El ejemplo anterior está diseñado para formularios Windows Forms y requiere PaintEventArgs e, que es un parámetro del controlador del evento Paint.

Vea también

Conceptos

Curvas spline de Bézier en GDI+

Otros recursos

Gráficos y dibujos en formularios Windows Forms

Crear y dibujar curvas