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.
Gradients
Intermediate Apply linear, radial, and sweep gradient shaders via SKShader assigned to SKPaint.Shader. SKShader API
using SkiaSharp;
SKCanvas canvas = /* ... */;
using var paint = new SKPaint { IsAntialias = true };
// ── Linear gradient ───────────────────────────
paint.Shader = SKShader.CreateLinearGradient(
new SKPoint(0, 50),
new SKPoint(400, 50),
new[] {
new SKColor(79, 70, 229), // indigo
new SKColor(219, 39, 119), // pink
},
null,
SKShaderTileMode.Clamp);
canvas.DrawRect(20, 20, 360, 70, paint);
paint.Shader?.Dispose();
// ── Radial gradient ───────────────────────────
paint.Shader = SKShader.CreateRadialGradient(
new SKPoint(120, 200),
75,
new[] {
SKColors.LightYellow,
new SKColor(245, 158, 11), // amber
SKColors.OrangeRed,
},
new[] { 0f, 0.5f, 1f },
SKShaderTileMode.Clamp);
canvas.DrawCircle(120, 200, 75, paint);
paint.Shader?.Dispose();
// ── Sweep gradient ────────────────────────────
paint.Shader = SKShader.CreateSweepGradient(
new SKPoint(300, 200),
new[] {
SKColors.Cyan,
SKColors.Magenta,
SKColors.Yellow,
SKColors.Cyan,
},
null);
canvas.DrawCircle(300, 200, 70, paint);
paint.Shader?.Dispose();Key APIs
SKShader.CreateLinearGradient(start, end, colors, colorPos, tileMode)SKShader.CreateRadialGradient(center, radius, colors, colorPos, tileMode)SKShader.CreateSweepGradient(center, colors, colorPos)— angular / conicSKShaderTileMode.Clamp— edge color outside bounds; alsoRepeat,Mirrorpaint.Shader?.Dispose()— always dispose the shader object after use- Combine gradients with
SKShader.CreateComposefor layered effects