// -----------------------------------------------------------------------
//
// Copyright 2015 MIT Licence. See licence.md for more information.
//
// -----------------------------------------------------------------------
namespace Perspex.Media
{
using Perspex.Platform;
using Splat;
///
/// Represents the geometry of a rectangle.
///
public class RectangleGeometry : Geometry
{
///
/// Initializes a new instance of the class.
///
/// The rectangle bounds.
public RectangleGeometry(Rect rect)
{
IPlatformRenderInterface factory = Locator.Current.GetService();
IStreamGeometryImpl impl = factory.CreateStreamGeometry();
using (IStreamGeometryContextImpl context = impl.Open())
{
context.BeginFigure(rect.TopLeft, true);
context.LineTo(rect.TopRight);
context.LineTo(rect.BottomRight);
context.LineTo(rect.BottomLeft);
context.EndFigure(true);
}
this.PlatformImpl = impl;
}
///
public override Rect Bounds
{
get { return this.PlatformImpl.Bounds; }
}
///
public override Geometry Clone()
{
return new RectangleGeometry(this.Bounds);
}
}
}