Code

C#

Paint & Colors

BeginnerSKPaint is the brush — it controls colour, style, stroke width, anti-aliasing, alpha, and effects. SKPaint API

FillStrokeStroke & Fill50% alpha (rgba)Dash effect
using SkiaSharp;

SKCanvas canvas = /* ... */;

// Fill-only paint
using var fill = new SKPaint
{
    Style        = SKPaintStyle.Fill,
    Color        = new SKColor(79, 70, 229),
    IsAntialias  = true,
};
canvas.DrawCircle(70, 70, 50, fill);

// Stroke-only paint
using var stroke = new SKPaint
{
    Style        = SKPaintStyle.Stroke,
    Color        = new SKColor(225, 29, 72),
    StrokeWidth  = 4,
    IsAntialias  = true,
};
canvas.DrawCircle(200, 70, 50, stroke);

// StrokeAndFill
using var both = new SKPaint
{
    Style        = SKPaintStyle.StrokeAndFill,
    Color        = new SKColor(245, 158, 11),
    StrokeWidth  = 4,
    IsAntialias  = true,
};
canvas.DrawCircle(330, 70, 50, both);

// 50 % alpha — use the 4-arg SKColor constructor
using var alpha = new SKPaint
{
    Style       = SKPaintStyle.Fill,
    Color       = new SKColor(22, 163, 74, 128), // a=128 → 50%
    IsAntialias = true,
};
canvas.DrawRect(20, 160, 360, 60, alpha);

// Dash effect via SKPathEffect
using var dash = new SKPaint
{
    Style       = SKPaintStyle.Stroke,
    Color       = SKColors.DarkSlateGray,
    StrokeWidth = 2,
    PathEffect  = SKPathEffect.CreateDash(
        new float[] { 10, 5 }, 0),
};
canvas.DrawLine(20, 248, 380, 248, dash);
Key APIs
  • paint.StyleFill, Stroke, or StrokeAndFill
  • paint.ColorSKColor(r, g, b) or SKColor(r, g, b, a)
  • paint.StrokeWidth — width in pixels when stroking
  • paint.IsAntialias — smooth edges (always set to true)
  • SKPathEffect.CreateDash(intervals, phase) — dashed / dotted lines
  • paint.StrokeCapButt, Round, or Square
  • paint.StrokeJoinMiter, Round, or Bevel
Try in SkiaSharp Fiddle