|
|
|
@ -28,17 +28,17 @@ namespace Perspex.Cairo.Media |
|
|
|
|
|
|
|
public void BeginFigure(Point startPoint, bool isFilled) |
|
|
|
{ |
|
|
|
this.impl.Operations.Enqueue(new BeginOp { Point = startPoint, IsFilled = isFilled }); |
|
|
|
this.context.MoveTo(startPoint.ToCairo()); |
|
|
|
} |
|
|
|
|
|
|
|
public void BezierTo(Point point1, Point point2, Point point3) |
|
|
|
{ |
|
|
|
this.impl.Operations.Enqueue(new CurveToOp { Point = point1, Point2 = point2, Point3 = point3 }); |
|
|
|
this.context.CurveTo(point1.ToCairo(), point2.ToCairo(), point3.ToCairo()); |
|
|
|
} |
|
|
|
|
|
|
|
public void LineTo(Point point) |
|
|
|
{ |
|
|
|
this.impl.Operations.Enqueue(new LineToOp { Point = point }); |
|
|
|
this.context.LineTo(point.ToCairo()); |
|
|
|
} |
|
|
|
|
|
|
|
private Cairo.Context context; |
|
|
|
@ -46,38 +46,12 @@ namespace Perspex.Cairo.Media |
|
|
|
|
|
|
|
public void EndFigure(bool isClosed) |
|
|
|
{ |
|
|
|
this.impl.Operations.Enqueue(new EndOp { IsClosed = isClosed }); |
|
|
|
|
|
|
|
var clone = new Queue<GeometryOp>(this.impl.Operations); |
|
|
|
|
|
|
|
while (clone.Count > 0) |
|
|
|
{ |
|
|
|
var current = clone.Dequeue(); |
|
|
|
if (isClosed) |
|
|
|
this.context.ClosePath(); |
|
|
|
|
|
|
|
if (current is BeginOp) |
|
|
|
{ |
|
|
|
var bo = current as BeginOp; |
|
|
|
context.MoveTo(bo.Point.ToCairo()); |
|
|
|
} |
|
|
|
else if (current is LineToOp) |
|
|
|
{ |
|
|
|
var lto = current as LineToOp; |
|
|
|
context.LineTo(lto.Point.ToCairo()); |
|
|
|
} |
|
|
|
else if (current is EndOp) |
|
|
|
{ |
|
|
|
if (((EndOp)current).IsClosed) |
|
|
|
context.ClosePath(); |
|
|
|
} |
|
|
|
else if (current is CurveToOp) |
|
|
|
{ |
|
|
|
var cto = current as CurveToOp; |
|
|
|
context.CurveTo(cto.Point.ToCairo(), cto.Point2.ToCairo(), cto.Point3.ToCairo()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
var extents = context.StrokeExtents(); |
|
|
|
var extents = this.context.StrokeExtents(); |
|
|
|
this.impl.Bounds = new Rect(extents.X, extents.Y, extents.Width, extents.Height); |
|
|
|
this.impl.Path = this.context.CopyPath(); |
|
|
|
} |
|
|
|
|
|
|
|
public void Dispose() |
|
|
|
|