using Cairo; Surface surface = new Win32Surface("output.png"); Context context = new Context(surface); // Set line width and color context.LineWidth = 2; context.SetSourceRGB(1, 0, 0); // Draw line context.MoveTo(10, 10); context.LineTo(100, 100); context.Stroke(); // Clean up context.Dispose(); surface.Dispose();
using Cairo; Surface surface = new Win32Surface("output.png"); Context context = new Context(surface); // Set fill and stroke colors context.SetSourceRGB(0, 0, 1); context.SetSourceRGB(0, 0, 0); // Draw circle context.Arc(50, 50, 30, 0, 2 * Math.PI); context.FillPreserve(); context.Stroke(); // Clean up context.Dispose(); surface.Dispose();This code creates a blue circle with a black border and outputs it to a PNG file. Both of these examples require the CairoSharp package library, which provides the C# bindings for Cairo.