Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Why are rounded corners of SKPaintStyle.Stroke so thick and ugly? (DrawRoundRect)

$
0
0

Here's my code:

    public void DrawCanvas(object sender, SKPaintSurfaceEventArgs psea)
    {
        psea.Surface.Canvas.Clear();
        SKRect canvasRect = SKRect.Create(psea.Info.Size);
        var r = 20;

        var paint = new SKPaint();
        paint.IsAntialias = true;
        //paint.StrokeCap = SKStrokeCap.Round;  // no need on a closed loop

        // fill
        paint.Style = SKPaintStyle.Fill;
        paint.Color = Color.Gray.ToSKColor();
        psea.Surface.Canvas.DrawRoundRect(canvasRect, r, r, paint);

        // border
        paint.Style = SKPaintStyle.Stroke;
        paint.Color = Color.Red.ToSKColor();
        paint.StrokeWidth = 4;
        psea.Surface.Canvas.DrawRoundRect(canvasRect, r, r, paint);
    }

Here's the result:

Why are the corners so cheap looking? Fill will round nice and sharp, but Stroke is blocky.

Should I be going about this a different way? I noticed there is a SKPaintStyle.StrokeAndFill style, but I didn't see a way to set two different colors in SKPaint (for fill vs stroke), so I assume drawing twice like this is the right approach.


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>