VintaSoft Imaging .NET SDK 15.1: Документация для .NET разработчика
Vintasoft.Imaging.Drawing Namespace / DrawingEngine Class / FillPath Methods / FillPath(IDrawingBrush,IGraphicsPath) Method
Синтаксис Example Требования Смотрите также
В этом разделе
FillPath(IDrawingBrush,IGraphicsPath) Метод (DrawingEngine)
В этом разделе
Заполняет внутреннюю часть пути.
Синтаксис
'Declaration

Public Overloads Sub FillPath( _
ByVal brush
Кисть, определяющая характеристики заливки.
As IDrawingBrush, _
ByVal path
Путь для заполнения.
As IGraphicsPath _
)

Parameters

brush
Кисть, определяющая характеристики заливки.
path
Путь для заполнения.
Пример

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


''' <summary>
''' Fills objects with different types of brushes on specified drawing engine.
''' </summary>
''' <param name="drawingEngine">Drawing engine.</param>
''' <param name="area">Area to draw objects in.</param>
Public Shared Sub BrushExample(drawingEngine As DrawingEngine, area As RectangleF)
    Dim factory As DrawingFactory = drawingEngine.DrawingFactory

    ' create graphics path to fill
    Using path As IGraphicsPath = factory.CreateGraphicsPath()
        ' add path elements
        path.AddLine(New PointF(area.X, area.Y + area.Height * 0.47F), New PointF(area.X + area.Width * 0.23F, area.Y))

        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)

        ' create solid brush and fill graphics path
        Using brush As IDrawingBrush = factory.CreateSolidBrush(Color.LightGreen)
            drawingEngine.FillPath(brush, path)
        End Using

        ' translate path
        path.Transform(AffineMatrix.CreateTranslation(area.Width / 2, 0))

        ' create gradient rectangle for linear gradient brush
        Dim gradientRect As New RectangleF(0, 0, area.Width / 3, area.Height / 3)
        ' create linear gradient brush and fill graphics path
        Using brush As IDrawingBrush = factory.CreateLinearGradientBrush(gradientRect, Color.Orange, Color.Purple)
            drawingEngine.FillPath(brush, path)
        End Using

        ' translate path
        path.Transform(AffineMatrix.CreateTranslation(0, area.Height / 2))

        ' create hatch brush and fill graphics path
        Using brush As IDrawingBrush = factory.CreateHatchBrush(BrushHatchStyle.DiagonalCross, Color.Yellow, Color.Black)
            drawingEngine.FillPath(brush, path)
        End Using

        ' translate path
        path.Transform(AffineMatrix.CreateTranslation(-area.Width / 2, 0))

        ' path to image file for image brush
        ' this image is located in <install path>/VintaSoft/Imaging .NET/Images/
        Dim imagePath As String = "VintasoftLogo.gif"

        ' create VintaSoft image and use it to create image brush
        Using brushImage As New VintasoftImage(imagePath)
            Using brush As IDrawingBrush = factory.CreateImageBrush(brushImage, True)
                drawingEngine.FillPath(brush, path)
            End Using
        End Using
    End Using
End Sub


/// <summary>
/// Fills objects with different types of brushes on specified drawing engine.
/// </summary>
/// <param name="drawingEngine">Drawing engine.</param>
/// <param name="area">Area to draw objects in.</param>
public static void BrushExample(DrawingEngine drawingEngine, RectangleF area)
{
    DrawingFactory factory = drawingEngine.DrawingFactory;

    // create graphics path to fill
    using (IGraphicsPath path = factory.CreateGraphicsPath())
    {
        // add path elements
        path.AddLine(
            new PointF(area.X, area.Y + area.Height * 0.47f),
            new PointF(area.X + area.Width * 0.23f, area.Y));

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

        // create solid brush and fill graphics path
        using (IDrawingBrush brush = factory.CreateSolidBrush(Color.LightGreen))
            drawingEngine.FillPath(brush, path);

        // translate path
        path.Transform(AffineMatrix.CreateTranslation(area.Width / 2, 0));

        // create gradient rectangle for linear gradient brush
        RectangleF gradientRect = new RectangleF(0, 0, area.Width / 3, area.Height / 3);
        // create linear gradient brush and fill graphics path
        using (IDrawingBrush brush = factory.CreateLinearGradientBrush(gradientRect, Color.Orange, Color.Purple))
            drawingEngine.FillPath(brush, path);

        // translate path
        path.Transform(AffineMatrix.CreateTranslation(0, area.Height / 2));

        // create hatch brush and fill graphics path
        using (IDrawingBrush brush = factory.CreateHatchBrush(BrushHatchStyle.DiagonalCross, Color.Yellow, Color.Black))
            drawingEngine.FillPath(brush, path);

        // translate path
        path.Transform(AffineMatrix.CreateTranslation(-area.Width / 2, 0));

        // path to image file for image brush
        // this image is located in <install path>/VintaSoft/Imaging .NET/Images/
        string imagePath = "VintasoftLogo.gif";

        // create VintaSoft image and use it to create image brush
        using (VintasoftImage brushImage = new VintasoftImage(imagePath))
        using (IDrawingBrush brush = factory.CreateImageBrush(brushImage, true))
            drawingEngine.FillPath(brush, path);
    }
}

Требования

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

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