using Cairo; ... using (var surface = new ImageSurface(Format.Argb32, width, height)) using (var context = new Context(surface)) { context.Rectangle(x, y, width, height); context.SetSourceRGBA(red, green, blue, alpha); context.Fill(); }
using Cairo; ... using (var surface = new ImageSurface(Format.Argb32, width, height)) using (var context = new Context(surface)) { context.MoveTo(x1, y1); context.LineTo(x2, y2); context.LineTo(x3, y3); context.SetSourceGradient(new LinearGradient(x1, y1, x2, y2)); context.Fill(); }In this example, a polygon is created using Cairo.MoveTo and Cairo.LineTo. A gradient is then created using Cairo.SetSourceGradient, and the polygon is filled using Cairo.Fill. The package library used for Cairo in C# is the CairoSharp library.