VintaSoft Imaging .NET SDK 14.0: Documentation for .NET developer
Vintasoft.Imaging.Drawing Namespace / DrawingEngine Class / DrawPath Methods / DrawPath(IDrawingPen,IGraphicsPath) Method
Syntax Example Requirements SeeAlso
In This Topic
    DrawPath(IDrawingPen,IGraphicsPath) Method (DrawingEngine)
    In This Topic
    Draws a path.
    Syntax
    'Declaration
    
    Public Overloads Sub DrawPath( _
    ByVal pen
    The pen that determines the color, width, and style of the path.
    As IDrawingPen, _
    ByVal path
    The path to draw.
    As IGraphicsPath _
    )
    public void DrawPath(
    IDrawingPen pen,
    IGraphicsPath path
    )
    public: void DrawPath(
    IDrawingPen* pen,
    IGraphicsPath* path
    )
    public:
    void DrawPath(
    IDrawingPen^ pen,
    IGraphicsPath^ path
    )

    Parameters

    pen
    The pen that determines the color, width, and style of the path.
    path
    The path to draw.
    Example

    Here is an example that shows how to draw path using drawing engine.

    
    ''' <summary>
    ''' Draws objects using pens with different settings on specified drawing engine.
    ''' </summary>
    ''' <param name="drawingEngine">Drawing engine.</param>
    ''' <param name="area">Area to draw objects in.</param>
    Public Shared Sub PenExample(drawingEngine As DrawingEngine, area As RectangleF)
        Dim factory As DrawingFactory = drawingEngine.DrawingFactory
    
        ' create graphics path to draw
        Using path As IGraphicsPath = factory.CreateGraphicsPath()
            ' add path elements
            Dim linePoints As PointF() = New PointF() {New PointF(area.X + area.Width * 0.15F, area.Y + area.Height * 0.47F), New PointF(area.X + area.Width * 0.15F, area.Y + area.Height * 0.3F), New PointF(area.X + area.Width * 0.23F, area.Y)}
    
            path.AddLines(linePoints)
    
            Dim curvePoints As PointF() = New PointF() {New PointF(area.X + area.Width * 0.23F, area.Y), New PointF(area.X + area.Width * 0.47F, area.Y + area.Height * 0.1F), New PointF(area.X + area.Width * 0.47F, area.Y + area.Height * 0.2F), New PointF(area.X + area.Width * 0.35F, area.Y + area.Height * 0.22F), New PointF(area.X + area.Width * 0.27F, area.Y + area.Height * 0.24F), New PointF(area.X + area.Width * 0.27F, area.Y + area.Height * 0.35F), _
                New PointF(area.X + area.Width * 0.45F, area.Y + area.Height * 0.47F)}
    
            path.AddBezierCurves(curvePoints)
    
            path.Transform(AffineMatrix.CreateScaling(0.66F, 1, area.X, area.Y))
    
            ' set minimum pen width
            Dim minPenWidth As Single = area.Width * 0.005F
    
            ' create simple pen and draw a path
            Using pen As IDrawingPen = factory.CreatePen(Color.Red, minPenWidth * 2)
                drawingEngine.DrawPath(pen, path)
            End Using
    
            ' translate path
            path.Transform(AffineMatrix.CreateTranslation(area.Width / 3, 0))
    
            ' create pen with dash pattern and arrow cap on line end
            Using pen As IDrawingPen = factory.CreatePen(Color.Red, minPenWidth)
                Using cap As DrawingLineCap = factory.CreateLineCap(DrawingLineCapType.Arrow, area.Height * 0.1F, area.Width * 0.1F)
                    pen.DashPattern = New Single() {3, 1}
                    ' draw path
                    drawingEngine.DrawPath(pen, path, Nothing, cap)
                End Using
            End Using
            ' translate path
            path.Transform(AffineMatrix.CreateTranslation(area.Width / 3, 0))
    
            ' create pen with dash pattern and dash cap
            Using pen As IDrawingPen = factory.CreatePen(Color.Red, minPenWidth * 3)
                pen.DashPattern = New Single() {1, 1}
                pen.DashCap = LineDashCapStyle.Round
                pen.LineCap = LineCapStyle.Round
                ' draw path
                drawingEngine.DrawPath(pen, path)
            End Using
            ' translate path
            path.Transform(AffineMatrix.CreateTranslation(0, area.Height / 2))
    
            ' create pen with round line join and butt cap on line start
            Using pen As IDrawingPen = factory.CreatePen(Color.DarkGreen, minPenWidth * 7)
                Using cap As DrawingLineCap = factory.CreateLineCap(DrawingLineCapType.Butt, area.Height * 0.1F, area.Width * 0.1F)
                    pen.LineJoin = LineJoinStyle.Round
                    ' draw path
                    drawingEngine.DrawPath(pen, path, cap, Nothing)
                End Using
            End Using
            ' translate path
            path.Transform(AffineMatrix.CreateTranslation(-area.Width / 3, 0))
    
            ' create pen with bevel line join and draw path
            Using pen As IDrawingPen = factory.CreatePen(Color.Blue, minPenWidth * 6)
                pen.LineJoin = LineJoinStyle.Bevel
                drawingEngine.DrawPath(pen, path)
            End Using
            ' translate path
            path.Transform(AffineMatrix.CreateTranslation(-area.Width / 3, 0))
    
            ' create pen with dash pattern, dash offset and different line caps
            Using pen As IDrawingPen = factory.CreatePen(Color.Blue, minPenWidth)
                Using startCap As DrawingLineCap = factory.CreateLineCap(DrawingLineCapType.FilledRectangle, minPenWidth * 10, minPenWidth * 10)
                    Using endCap As DrawingLineCap = factory.CreateLineCap(DrawingLineCapType.Ellipse, minPenWidth * 10, minPenWidth * 10)
                        pen.DashOffset = 5
                        pen.DashPattern = New Single() {3, 1, 1, 1}
                        ' draw path
                        drawingEngine.DrawPath(pen, path, startCap, endCap)
                    End Using
                End Using
            End Using
        End Using
    End Sub
    
    
    
    /// <summary>
    /// Draws objects using pens with different settings on specified drawing engine.
    /// </summary>
    /// <param name="drawingEngine">Drawing engine.</param>
    /// <param name="area">Area to draw objects in.</param>
    public static void PenExample(DrawingEngine drawingEngine, RectangleF area)
    {
        DrawingFactory factory = drawingEngine.DrawingFactory;
    
        // create graphics path to draw
        using (IGraphicsPath path = factory.CreateGraphicsPath())
        {
            // add path elements
            PointF[] linePoints = new PointF[]
            {
                new PointF(area.X + area.Width * 0.15f, area.Y + area.Height * 0.47f),
                new PointF(area.X + area.Width * 0.15f, area.Y + area.Height * 0.3f),
                new PointF(area.X + area.Width * 0.23f, area.Y),
            };
    
            path.AddLines(linePoints);
    
            PointF[] curvePoints = new PointF[]
            {
                new PointF(area.X + area.Width * 0.23f, area.Y),
                new PointF(area.X + area.Width * 0.47f, area.Y + area.Height * 0.1f),
                new PointF(area.X + area.Width * 0.47f, area.Y + area.Height * 0.2f),
                new PointF(area.X + area.Width * 0.35f, area.Y + area.Height * 0.22f),
                new PointF(area.X + area.Width * 0.27f, area.Y + area.Height * 0.24f),
                new PointF(area.X + area.Width * 0.27f, area.Y + area.Height * 0.35f),
                new PointF(area.X + area.Width * 0.45f, area.Y + area.Height * 0.47f),
            };
    
            path.AddBezierCurves(curvePoints);
    
            path.Transform(AffineMatrix.CreateScaling(0.66f, 1, area.X, area.Y));
    
            // set minimum pen width
            float minPenWidth = area.Width * 0.005f;
    
            // create simple pen and draw a path
            using (IDrawingPen pen = factory.CreatePen(Color.Red, minPenWidth * 2))
                drawingEngine.DrawPath(pen, path);
    
            // translate path
            path.Transform(AffineMatrix.CreateTranslation(area.Width / 3, 0));
    
            // create pen with dash pattern and arrow cap on line end
            using (IDrawingPen pen = factory.CreatePen(Color.Red, minPenWidth))
            using (DrawingLineCap cap = factory.CreateLineCap(DrawingLineCapType.Arrow, area.Height * 0.1f, area.Width * 0.1f))
            {
                pen.DashPattern = new float[] { 3, 1 };
                // draw path
                drawingEngine.DrawPath(pen, path, null, cap);
            }
            // translate path
            path.Transform(AffineMatrix.CreateTranslation(area.Width / 3, 0));
    
            // create pen with dash pattern and dash cap
            using (IDrawingPen pen = factory.CreatePen(Color.Red, minPenWidth * 3))
            {
                pen.DashPattern = new float[] { 1, 1 };
                pen.DashCap = LineDashCapStyle.Round;
                pen.LineCap = LineCapStyle.Round;
                // draw path
                drawingEngine.DrawPath(pen, path);
            }
            // translate path
            path.Transform(AffineMatrix.CreateTranslation(0, area.Height / 2));
    
            // create pen with round line join and butt cap on line start
            using (IDrawingPen pen = factory.CreatePen(Color.DarkGreen, minPenWidth * 7))
            using (DrawingLineCap cap = factory.CreateLineCap(DrawingLineCapType.Butt, area.Height * 0.1f, area.Width * 0.1f))
            {
                pen.LineJoin = LineJoinStyle.Round;
                // draw path
                drawingEngine.DrawPath(pen, path, cap, null);
            }
            // translate path
            path.Transform(AffineMatrix.CreateTranslation(-area.Width / 3, 0));
    
            // create pen with bevel line join and draw path
            using (IDrawingPen pen = factory.CreatePen(Color.Blue, minPenWidth * 6))
            {
                pen.LineJoin = LineJoinStyle.Bevel;
                drawingEngine.DrawPath(pen, path);
            }
            // translate path
            path.Transform(AffineMatrix.CreateTranslation(-area.Width / 3, 0));
    
            // create pen with dash pattern, dash offset and different line caps
            using (IDrawingPen pen = factory.CreatePen(Color.Blue, minPenWidth))
            using (DrawingLineCap startCap = factory.CreateLineCap(DrawingLineCapType.FilledRectangle, minPenWidth * 10, minPenWidth * 10))
            using (DrawingLineCap endCap = factory.CreateLineCap(DrawingLineCapType.Ellipse, minPenWidth * 10, minPenWidth * 10))
            {
                pen.DashOffset = 5;
                pen.DashPattern = new float[] { 3, 1, 1, 1 };
                // draw path
                drawingEngine.DrawPath(pen, path, startCap, endCap);
            }
        }
    }
    
    

    Requirements

    Target Platforms: .NET9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    See Also