// Copyright (c) The Avalonia Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using Avalonia.Platform;
namespace Avalonia.Media
{
///
/// Describes a geometry using drawing commands.
///
///
/// This class is used to define the geometry of a . An instance
/// of is obtained by calling
/// .
///
/// TODO: This class is just a wrapper around IStreamGeometryContextImpl: is it needed?
public class StreamGeometryContext : IDisposable
{
private readonly IStreamGeometryContextImpl _impl;
///
/// Initializes a new instance of the class.
///
/// The platform-specific implementation.
public StreamGeometryContext(IStreamGeometryContextImpl impl)
{
_impl = impl;
}
///
/// Sets path's winding rule (default is EvenOdd). You should call this method before any calls to BeginFigure. If you wonder why, ask Direct2D guys about their design decisions.
///
///
public void SetFillRule(FillRule fillRule)
{
_impl.SetFillRule(fillRule);
}
///
/// Draws an arc to the specified point.
///
/// The destination point.
/// The radii of an oval whose perimeter is used to draw the angle.
/// The rotation angle of the oval that specifies the curve.
/// true to draw the arc greater than 180 degrees; otherwise, false.
///
/// A value that indicates whether the arc is drawn in the Clockwise or Counterclockwise direction.
///
public void ArcTo(Point point, Size size, double rotationAngle, bool isLargeArc, SweepDirection sweepDirection)
{
_impl.ArcTo(point, size, rotationAngle, isLargeArc, sweepDirection);
}
///
/// Begins a new figure.
///
/// The starting point for the figure.
/// Whether the figure is filled.
public void BeginFigure(Point startPoint, bool isFilled)
{
_impl.BeginFigure(startPoint, isFilled);
}
///
/// Draws a Bezier curve to the specified point.
///
/// The first control point used to specify the shape of the curve.
/// The second control point used to specify the shape of the curve.
/// The destination point for the end of the curve.
public void CubicBezierTo(Point point1, Point point2, Point point3)
{
_impl.CubicBezierTo(point1, point2, point3);
}
///
/// Draws a quadratic Bezier curve to the specified point
///
/// The control point used to specify the shape of the curve.
/// The destination point for the end of the curve.
public void QuadraticBezierTo(Point control, Point endPoint)
{
_impl.QuadraticBezierTo(control, endPoint);
}
///
/// Draws a line to the specified point.
///
/// The destination point.
public void LineTo(Point point)
{
_impl.LineTo(point);
}
///
/// Ends the figure started by .
///
/// Whether the figure is closed.
public void EndFigure(bool isClosed)
{
_impl.EndFigure(isClosed);
}
///
/// Finishes the drawing session.
///
public void Dispose()
{
_impl.Dispose();
}
}
}