CairoSharp

From Wiki Maui Linux NET
Jump to navigation Jump to search
CairoSharp
Developer(s) GNOME Project, Xamarin, and community contributors
Initial release

2002

Latest version
Programming language C#
Operating system Cross-platform
Platform .NET, Mono
Type Graphics library bindings
License GNU Lesser General Public License
Website GitHub repository


CairoSharp is a set of C# bindings for the Cairo 2D graphics library. It is part of the GtkSharp project and provides managed access to Cairo’s advanced vector-based rendering features within the .NET and Mono environments.

Overview of Cairo

Cairo is a cross-platform, open-source 2D graphics library designed to produce consistent output across multiple backends, including X11, Win32, Quartz, image buffers, and PDF/SVG surfaces. It supports anti-aliased rendering, vector graphics, and transformations while maintaining device-independent output.

Core features of Cairo include:

  • Vector-based 2D drawing with sub-pixel precision
  • Support for multiple backends (image, PDF, SVG, OpenGL, etc.)
  • Path-based drawing model similar to PostScript
  • Advanced text rendering through Pango integration
  • Transparency, compositing, and clipping

CairoSharp

CairoSharp provides a managed C# interface to the Cairo library, allowing developers to create and manipulate graphics surfaces, contexts, and paths from within .NET code.

Using CairoSharp, developers can:

  • Draw shapes, lines, and curves with high-quality anti-aliasing
  • Render text and images with compositing and alpha blending
  • Generate scalable vector graphics and PDF/SVG output
  • Integrate custom drawing into GdkSharp or GtkSharp applications

CairoSharp follows the same object model and function naming as the native Cairo API, while exposing a more idiomatic C# interface for ease of use.

Relationship to other GtkSharp components

CairoSharp is often used together with:

  • GdkSharp – Provides drawing surfaces (Gdk.Window, Gdk.Pixbuf) that CairoSharp can render onto.
  • PangoSharp – Handles text layout and rendering using Cairo as the drawing backend.
  • GtkSharp – Integrates Cairo rendering for custom widgets and canvas-like controls.
  • GLibSharp – Supplies the base data types and signal handling mechanisms for the bindings.

Version compatibility

CairoSharp bindings are compatible with Cairo versions used by GTK:

  • **CairoSharp 2.x** – Used with GTK 2 bindings
  • **CairoSharp 3.x** – Updated for GTK 3 and modern .NET
  • **CairoSharp 4.x** – In development for GTK 4 and .NET 6+

See also