SkiaSharp
SkiaSharp is a cross‑platform 2D graphics API for .NET based on the Skia graphics library. It provides a powerful, hardware‑accelerated rendering engine that integrates seamlessly with game loops, UI frameworks, and custom drawing pipelines.
Introduction
Setup
Drawing Basics
Code Samples
Key features:
- High‑performance raster and GPU rendering
- Full support for paths, shaders, masks, text layout, and image filters
- Works on Windows, macOS, Linux, Android, iOS, and WebAssembly
- Open source under the MIT license
Install the NuGet package:
dotnet add package SkiaSharp
For GPU acceleration on Windows, add:
dotnet add package SkiaSharp.NativeAssets.Win32
Initialize in your game loop:
using SkiaSharp;
public class GameRenderer
{
private SKSurface _surface;
private SKCanvas Canvas => _surface.Canvas;
public void Initialize(int width, int height)
{
var info = new SKImageInfo(width, height, SKColorType.Rgba8888);
_surface = SKSurface.Create(info);
}
public SKBitmap GetBitmap() => SKBitmap.FromImage(_surface.Snapshot());
}
Basic drawing example:
public void DrawScene(SKCanvas canvas)
{
canvas.Clear(SKColors.CornflowerBlue);
using var paint = new SKPaint
{
Color = SKColors.OrangeRed,
IsAntialias = true,
StrokeWidth = 4,
Style = SKPaintStyle.Stroke
};
// Draw a circle
canvas.DrawCircle(200, 150, 100, paint);
// Draw text
paint.Style = SKPaintStyle.Fill;
paint.TextSize = 48;
canvas.DrawText("Hello SkiaSharp!", 100, 300, paint);
}
Interactive demo (run in a WebAssembly build):