Mono Class Library: Namespaces

Cairo Namespace

A binding to the 2D Cairo Graphics rendering API. [Edit]

Remarks

The Mono.Cairo namespace is a binding to the http://CairoGraphics.org API.

Before Mono 1.2.5, this API only exposed the Cairo 1.0 API, starting with Mono 1.2.5, this release exposes both the Cairo 1.0 and 1.2 APIs regardless of the underlying Cairo implementation available on the underlying system.

If you are planning on using the 1.2 API, you should first check using the Cairo.CairoAPI.Version whether you are running on a system that supports the 1.2 API before making any 1.2 calls or make it a requirement that the system must have a 1.2 Cairo installed. Cairo 1.2 APIs have been flagged in the documentation.

Cairo draws into surfaces, there are many to choose from (in-memory image buffers, PDF surfaces, Postscript surfaces, hardware accelerated surfaces, Xlib surfaces and a handful more). Drawing operations are performed on the Cairo surfaces, for example:

C# Example
//
// To compile use: mcs test.cs -r:Mono.Cairo
//
// This generates a file test.png that contains the text
// "Hello, World" rendered with a serif font in blue, on a
// transparent background.
//
using Cairo;

class X {
	static void Main ()
	{
		//
		// Creates an Image-based surface with with data stored in
		// ARGB32 format.  
		//
		ImageSurface surface = new ImageSurface (Format.ARGB32, 240, 80);

		//
		// Create a context, "using" is used here to ensure that the
		// context is Disposed once we are done
		//
		using (Context ctx = new Cairo.Context (surface)){

			// Select a font to draw with
			ctx.SelectFontFace ("serif", FontSlant.Normal, FontWeight.Bold);
			ctx.SetFontSize (32.0);
			
			// Select a color (blue)
			ctx.SetSourceRGB (0, 0, 1);
			
			// Draw
			ctx.MoveTo (10, 50);
			ctx.ShowText ("Hello, World");
			
			surface.WriteToPng ("test.png");
		}
	}
}
	

To compile code that uses Mono.Cairo all you have to do is reference the Mono.Cairo assembly by passing the -r:Mono.Cairo command line option to the compiler or referencing the assembly from MonoDevelop. The code is contained in the "Cairo" namespace.

[Edit]

Classes

TypeReason
CairoAPIDocumentation for this section has not yet been entered.
ContextThis is the main object when drawing with Cairo.
DirectFBSurfaceDocumentation for this section has not yet been entered.
FontFaceDocumentation for this section has not yet been entered.
FontOptionsHow a font should be rendered
GlitzSurfaceGlitz OpenGL surface support
GradientBase class for gradients.
GraphicsObsolete version of Cairo.Context, use it instead.
ImageSurfaceAn in-memory image surface
LinearGradientExtends Cairo.Gradient by providing a linear gradient along the line defined by (x0, y0) and (x1, y1).
MatrixDefines the Matrix object for transformations and translations.
NativeMethodsDocumentation for this section has not yet been entered.
PathDocumentation for this section has not yet been entered.
PatternPatterns allow you to tile or extend images and objects and allow you to draw things like gradients.
PdfSurfaceDocumentation for this section has not yet been entered.
PSSurfaceDocumentation for this section has not yet been entered.
RadialGradientExtends Cairo.Gradient to create a new radial gradient between the two circles defined by (cx0, cxy0, radius0) and (cx1, cy1, radius1).
ScaledFontDocumentation for this section has not yet been entered.
SolidPatternExtends Pattern to create a solid pattern consisting of a solid color and an optional alpha value.
SurfaceBase class for surfaces
SurfacePatternDocumentation for this section has not yet been entered.
SvgSurfaceDocumentation for this section has not yet been entered.
Win32SurfaceMicrosoft Windows surface support
XcbSurfaceDocumentation for this section has not yet been entered.
XlibSurfaceX Window System rendering using XLib

Structs

TypeReason
ColorColor objects holding red, green, blue, and alpha values.
DistanceDefines a distance between two points.
FontExtentsStores metric information for a font. Values are given in the current user-space coordinate system.
GlyphThis structure holds information about a single glyph when drawing or measuring text.
PointClass defining a point representd by two int values.
PointDClass defining a point represented by two double values for the x and y coordinates.
RectangleA representation of a Rectangle.
TextExtentsStores the extents of a single glyph or a string of glyphs in user-space coordinates.

Enumerations

TypeReason
AntialiasSpecifies the type of antialiasing to do when rendering text or shapes.
ContentUsed to describe the content that a surface will contain, whether color information, alpha information (translucence vs. opacity), or both.
ExtendDefines Pattern Extend types.
FillRuleDefines a FillRule.
FilterDefines Filter types on Graphics and Pattern objects.
FontSlantDefines the possible slants on fonts.
FontTypeDescribes the type of a given font face or scaled font.
FontWeightDefines the wieght of the font (normal, bold).
FormatUsed to identify the memory format of image data.
HintMetricsSpecifies whether to hint font metrics.
HintStyleSpecifies the type of hinting to do on font outlines.
LineCapDefines the various line ending styles.
LineJoinDocumentation for this section has not yet been entered.
OperatorDocumentation for this section has not yet been entered.
PatternTypeDescribes the type of a given pattern.
StatusReports the internal status of the Cairo system. When an error occurs, all further calls to acquire the status will report the error.
SubpixelOrderThe subpixel order specifies the order of color elements within each pixel on the display device when rendering with an antialiasing mode of Cairo.Antialias.Subpixel.
SurfaceTypeDescribes the type of a given surface.
SvgVersionDescribes the version number of the SVG specification that a generated SVG file will conform to.