Code
C#
Basic Shapes
DrawRect, DrawCircle, DrawOval, DrawLine — the core SkiaSharp drawing primitives.
Paint & Colors
SKPaint styles, stroke width, anti-alias, alpha, and dash effects.
Paths
SKPath — LineTo, CubicTo, ArcTo, star polygons, and filled shapes.
Text Rendering
DrawText with SKFont — bold/italic typefaces, stroke text, and MeasureText.
Gradients
Linear, radial, and sweep gradient shaders via SKShader.
Image Filters
Gaussian blur, drop shadow, and colour-matrix filters with SKImageFilter.
Transforms
Translate, RotateDegrees, Scale, Skew — and the Save/Restore stack.
Fiddle
Write and run SkiaSharp C# code live in the official interactive fiddle.
Paint & Colors
BeginnerSKPaint is the brush — it controls colour, style, stroke width, anti-aliasing, alpha, and effects. SKPaint API
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.Style—Fill,Stroke, orStrokeAndFillpaint.Color—SKColor(r, g, b)orSKColor(r, g, b, a)paint.StrokeWidth— width in pixels when strokingpaint.IsAntialias— smooth edges (always set totrue)SKPathEffect.CreateDash(intervals, phase)— dashed / dotted linespaint.StrokeCap—Butt,Round, orSquarepaint.StrokeJoin—Miter,Round, orBevel