A cross-platform UI framework for .NET
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

69 lines
2.0 KiB

// -----------------------------------------------------------------------
// <copyright file="StreamGeometryContextImpl.cs" company="Steven Kirk">
// Copyright 2013 MIT Licence. See licence.md for more information.
// </copyright>
// -----------------------------------------------------------------------
namespace Perspex.Direct2D1.Media
{
using Perspex.Platform;
using SharpDX.Direct2D1;
public class StreamGeometryContextImpl : IStreamGeometryContextImpl
{
private GeometrySink sink;
public StreamGeometryContextImpl(GeometrySink sink)
{
this.sink = sink;
}
public void ArcTo(
Point point,
Size size,
double rotationAngle,
bool isLargeArc,
Perspex.Media.SweepDirection sweepDirection)
{
this.sink.AddArc(new ArcSegment
{
Point = point.ToSharpDX(),
Size = size.ToSharpDX(),
RotationAngle = (float)rotationAngle,
ArcSize = isLargeArc ? ArcSize.Large : ArcSize.Small,
SweepDirection = (SweepDirection)sweepDirection,
});
}
public void BeginFigure(Point startPoint, bool isFilled)
{
this.sink.BeginFigure(startPoint.ToSharpDX(), isFilled ? FigureBegin.Filled : FigureBegin.Hollow);
}
public void BezierTo(Point point1, Point point2, Point point3)
{
this.sink.AddBezier(new BezierSegment
{
Point1 = point1.ToSharpDX(),
Point2 = point2.ToSharpDX(),
Point3 = point3.ToSharpDX(),
});
}
public void LineTo(Point point)
{
this.sink.AddLine(point.ToSharpDX());
}
public void EndFigure(bool isClosed)
{
this.sink.EndFigure(isClosed ? FigureEnd.Closed : FigureEnd.Open);
}
public void Dispose()
{
this.sink.Close();
this.sink.Dispose();
}
}
}