Skip to content

Commit e11379e

Browse files
committed
Implement skia border radius
1 parent f89f838 commit e11379e

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

Source/HtmlRenderer.SkiaSharp/Adapters/GraphicsAdapter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
namespace TheArtOfDev.HtmlRenderer.SkiaSharp.Adapters
2121
{
2222
/// <summary>
23-
/// Adapter for WinForms Graphics for core.
23+
/// Adapter for Skia Graphics for core.
2424
/// </summary>
2525
internal sealed class GraphicsAdapter : RGraphics
2626
{

Source/HtmlRenderer.SkiaSharp/Adapters/GraphicsPathAdapter.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,22 @@
1919
namespace TheArtOfDev.HtmlRenderer.SkiaSharp.Adapters
2020
{
2121
/// <summary>
22-
/// Adapter for WinForms graphics path object for core.
22+
/// Adapter for Skia graphics path object for core.
2323
/// </summary>
2424
internal sealed class GraphicsPathAdapter : RGraphicsPath
2525
{
2626
/// <summary>
27-
/// The actual PdfSharp graphics path instance.
27+
/// The actual SKPath graphics path instance.
2828
/// </summary>
29-
private readonly SKPath _graphicsPath = new SKPath();
29+
private readonly SKPath _graphicsPath = new();
3030

3131
/// <summary>
3232
/// the last point added to the path to begin next segment from
3333
/// </summary>
3434
private RPoint _lastPoint;
3535

3636
/// <summary>
37-
/// The actual PdfSharp graphics path instance.
37+
/// The actual SKPath graphics path instance.
3838
/// </summary>
3939
public SKPath GraphicsPath
4040
{
@@ -44,6 +44,7 @@ public SKPath GraphicsPath
4444
public override void Start(double x, double y)
4545
{
4646
_lastPoint = new RPoint(x, y);
47+
_graphicsPath.MoveTo((float)x, (float)y);
4748
}
4849

4950
public override void LineTo(double x, double y)
@@ -56,12 +57,16 @@ public override void ArcTo(double x, double y, double size, Corner corner)
5657
{
5758
float left = (float)(Math.Min(x, _lastPoint.X) - (corner == Corner.TopRight || corner == Corner.BottomRight ? size : 0));
5859
float top = (float)(Math.Min(y, _lastPoint.Y) - (corner == Corner.BottomLeft || corner == Corner.BottomRight ? size : 0));
59-
_graphicsPath.ArcTo(left, top, (float)size * 2, (float)size * 2, GetStartAngle(corner));
60+
61+
var rect = SKRect.Create(left, top, (float)size * 2, (float)size * 2);
62+
_graphicsPath.ArcTo(rect, GetStartAngle(corner), 90f, false);
6063
_lastPoint = new RPoint(x, y);
6164
}
6265

6366
public override void Dispose()
64-
{ }
67+
{
68+
_graphicsPath.Dispose();
69+
}
6570

6671
/// <summary>
6772
/// Get arc start angle for the given corner.

Source/HtmlRenderer.SkiaSharp/Adapters/SkiaSharpAdapter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ protected override RColor GetColorInt(string colorName)
7575

7676
protected override RPen CreatePen(RColor color)
7777
{
78-
return new PenAdapter(new SKPaint { Color = Utils.Convert(color) });
78+
return new PenAdapter(new SKPaint { Color = Utils.Convert(color), IsStroke = true });
7979
}
8080

8181
protected override RBrush CreateSolidBrush(RColor color)

0 commit comments

Comments
 (0)