using Cairo; ... Cairo.Context cr = new Cairo.Context(surface); cr.Rectangle(x, y, width, height); cr.Stroke();
using Cairo; ... Cairo.Rectangle rect = new Cairo.Rectangle(x, y, width, height); cr.Rectangle(rect); cr.SetSourceColor(new Cairo.Color(red, green, blue)); cr.Fill();In this example, we create a new Cairo Rectangle object and then use it to draw the rectangle on the context. We then set the source color to a solid color using the SetSourceColor method, and then fill the rectangle with this color using the Fill method. These examples use the Cairo graphics library, which is typically part of the Mono project on Linux and macOS, and is also available for Windows as part of the GTK# project.