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