committed by
GitHub
15 changed files with 234 additions and 62 deletions
@ -0,0 +1,25 @@ |
|||
// 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 SkiaSharp; |
|||
|
|||
namespace Avalonia.Skia |
|||
{ |
|||
/// <summary>
|
|||
/// A Skia implementation of a <see cref="Avalonia.Media.EllipseGeometry"/>.
|
|||
/// </summary>
|
|||
internal class EllipseGeometryImpl : GeometryImpl |
|||
{ |
|||
public override Rect Bounds { get; } |
|||
public override SKPath EffectivePath { get; } |
|||
|
|||
public EllipseGeometryImpl(Rect rect) |
|||
{ |
|||
var path = new SKPath(); |
|||
path.AddOval(rect.ToSKRect()); |
|||
|
|||
EffectivePath = path; |
|||
Bounds = rect; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
// 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 SkiaSharp; |
|||
|
|||
namespace Avalonia.Skia |
|||
{ |
|||
/// <summary>
|
|||
/// A Skia implementation of a <see cref="Avalonia.Media.LineGeometry"/>.
|
|||
/// </summary>
|
|||
internal class LineGeometryImpl : GeometryImpl |
|||
{ |
|||
public override Rect Bounds { get; } |
|||
public override SKPath EffectivePath { get; } |
|||
|
|||
public LineGeometryImpl(Point p1, Point p2) |
|||
{ |
|||
var path = new SKPath(); |
|||
path.MoveTo(p1.ToSKPoint()); |
|||
path.LineTo(p2.ToSKPoint()); |
|||
|
|||
EffectivePath = path; |
|||
Bounds = new Rect( |
|||
new Point(Math.Min(p1.X, p2.X), Math.Min(p1.Y, p2.Y)), |
|||
new Point(Math.Max(p1.X, p2.X), Math.Max(p1.Y, p2.Y))); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
// 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 SkiaSharp; |
|||
|
|||
namespace Avalonia.Skia |
|||
{ |
|||
/// <summary>
|
|||
/// A Skia implementation of a <see cref="Avalonia.Media.RectangleGeometry"/>.
|
|||
/// </summary>
|
|||
internal class RectangleGeometryImpl : GeometryImpl |
|||
{ |
|||
public override Rect Bounds { get; } |
|||
public override SKPath EffectivePath { get; } |
|||
|
|||
public RectangleGeometryImpl(Rect rect) |
|||
{ |
|||
var path = new SKPath(); |
|||
path.AddRect(rect.ToSKRect()); |
|||
|
|||
EffectivePath = path; |
|||
Bounds = rect; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
// 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 SharpDX.Direct2D1; |
|||
|
|||
namespace Avalonia.Direct2D1.Media |
|||
{ |
|||
/// <summary>
|
|||
/// A Direct2D implementation of a <see cref="Avalonia.Media.EllipseGeometry"/>.
|
|||
/// </summary>
|
|||
internal class EllipseGeometryImpl : GeometryImpl |
|||
{ |
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="StreamGeometryImpl"/> class.
|
|||
/// </summary>
|
|||
public EllipseGeometryImpl(Rect rect) |
|||
: base(CreateGeometry(rect)) |
|||
{ |
|||
} |
|||
|
|||
private static Geometry CreateGeometry(Rect rect) |
|||
{ |
|||
var ellipse = new Ellipse(rect.Center.ToSharpDX(), (float)rect.Width / 2, (float)rect.Height / 2); |
|||
return new EllipseGeometry(Direct2D1Platform.Direct2D1Factory, ellipse); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
// 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 SharpDX.Direct2D1; |
|||
|
|||
namespace Avalonia.Direct2D1.Media |
|||
{ |
|||
/// <summary>
|
|||
/// A Direct2D implementation of a <see cref="Avalonia.Media.LineGeometry"/>.
|
|||
/// </summary>
|
|||
internal class LineGeometryImpl : StreamGeometryImpl |
|||
{ |
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="StreamGeometryImpl"/> class.
|
|||
/// </summary>
|
|||
public LineGeometryImpl(Point p1, Point p2) |
|||
{ |
|||
using (var sink = ((PathGeometry)Geometry).Open()) |
|||
{ |
|||
sink.BeginFigure(p1.ToSharpDX(), FigureBegin.Hollow); |
|||
sink.AddLine(p2.ToSharpDX()); |
|||
sink.EndFigure(FigureEnd.Open); |
|||
sink.Close(); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
// 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 SharpDX.Direct2D1; |
|||
|
|||
namespace Avalonia.Direct2D1.Media |
|||
{ |
|||
/// <summary>
|
|||
/// A Direct2D implementation of a <see cref="Avalonia.Media.RectangleGeometry"/>.
|
|||
/// </summary>
|
|||
internal class RectangleGeometryImpl : GeometryImpl |
|||
{ |
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="StreamGeometryImpl"/> class.
|
|||
/// </summary>
|
|||
public RectangleGeometryImpl(Rect rect) |
|||
: base(CreateGeometry(rect)) |
|||
{ |
|||
} |
|||
|
|||
private static Geometry CreateGeometry(Rect rect) |
|||
{ |
|||
return new RectangleGeometry(Direct2D1Platform.Direct2D1Factory, rect.ToDirect2D()); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue