VintaSoft Imaging .NET SDK 14.0: Документация для .NET разработчика
Vintasoft.Imaging.Drawing Namespace / DrawingEngine Class / DrawPath Methods / DrawPath(IDrawingPen,IGraphicsPath,DrawingLineCap,DrawingLineCap) Method
Синтаксис Example Требования Смотрите также
В этом разделе
    DrawPath(IDrawingPen,IGraphicsPath,DrawingLineCap,DrawingLineCap) Метод (DrawingEngine)
    В этом разделе
    Рисует путь с указанными концами линий.
    Синтаксис
    'Declaration
    
    Public Overloads Sub DrawPath( _
    ByVal pen
    Перо, которое следует использовать для рисования пути.
    As IDrawingPen, _
    ByVal path
    Путь, который будет нарисован.
    As IGraphicsPath, _
    ByVal startCap
    Конец линии, который следует использовать для рисования начального конца линии.
    As DrawingLineCap, _
    ByVal endCap
    Конец линии, который следует использовать для рисования конца линии.
    As DrawingLineCap _
    )

    Parameters

    pen
    Перо, которое следует использовать для рисования пути.
    path
    Путь, который будет нарисован.
    startCap
    Конец линии, который следует использовать для рисования начального конца линии.
    endCap
    Конец линии, который следует использовать для рисования конца линии.
    Пример

    Вот пример, показывающий, как нарисовать путь с помощью механизма рисования.

    
    ''' <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);
            }
        }
    }
    
    

    Требования

    Целевые платформы: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    Смотрите также