using Cairo; ... using (var cr = new Cairo.Context (surface)) { cr.SetSourceRGBA (1, 0, 0, 0.5); cr.Rectangle (50, 50, 200, 200); cr.Fill (); }
using Cairo; ... using (var cr = new Cairo.Context (surface)) { cr.SetSourceRGBA (0, 1, 0, 1); cr.MoveTo (100, 100); cr.LineTo (200, 200); cr.LineTo (100, 200); cr.ClosePath (); cr.Fill (); cr.SetSourceRGBA (0, 0, 1, 1); cr.MoveTo (250, 100); cr.LineTo (350, 100); cr.LineTo (300, 200); cr.ClosePath (); cr.Fill (); }In this example, we create a new Cairo context and set the source color to green (RGBA values of 0, 1, 0, and 1) using the SetSourceRGBA function. We then use the MoveTo, LineTo, and ClosePath functions to draw a triangle and fill it with the source color using the Fill function. We then set the source color to blue (RGBA values of 0, 0, 1, and 1) and draw another triangle using the same functions. The package library for using Cairo in C# is called "cairo-sharp".