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.
Type | Reason |
---|---|
Antialias | Specifies the type of antialiasing to do when rendering text or shapes. |
CairoAPI | Provides information about the CairoAPI. |
Color | Color objects holding red, green, blue, and alpha values. |
Content | Used to describe the content that a surface will contain, whether color information, alpha information (translucence vs. opacity), or both. |
Context | This is the main object when drawing with Cairo. |
DirectFBSurface | A DirectFBSurface |
Distance | Defines a distance between two points. |
Extend | Defines Pattern Extend types. |
FillRule | Defines a FillRule. |
Filter | Defines Filter types on Graphics and Pattern objects. |
FontExtents | Stores metric information for a font. Values are given in the current user-space coordinate system. |
FontFace | A FontFace represents a font at a particular weight, slant, and other characteristics but no size or transformation. |
FontOptions | The FontOptions Class defines how a font should be rendered |
FontSlant | Defines the possible slants on fonts. |
FontType | Describes the type of a given font face or scaled font. |
FontWeight | Defines the weight of the font (normal, bold). |
Format | Used to identify the memory format of image data. |
GlitzSurface | Glitz OpenGL surface support |
Glyph | This structure holds information about a single glyph when drawing or measuring text. |
Gradient | Base class for gradients. |
Graphics | Obsolete version of Cairo.Context, use it instead. |
HintMetrics | Specifies whether to hint font metrics. |
HintStyle | Specifies the type of hinting to do on font outlines. |
ImageSurface | An in-memory image surface |
LinearGradient | Extends Cairo.Gradient by providing a linear gradient along the line defined by (x0, y0) and (x1, y1). |
LineCap | Defines the various line ending styles. |
LineJoin | Defines the various line join styles |
Matrix | Defines the Matrix object for transformations and translations. |
NativeMethods | Contains references to the native cairo methods |
Operator | Contains the Cairo Operators |
Path | The Cairo Path Class |
Pattern | Patterns allow you to tile or extend images and objects and allow you to draw things like gradients. |
PatternType | Describes the type of a given pattern. |
PdfSurface | The PDF surface is used to render cairo graphics to Adobe PDF files. |
Point | Class defining a point representd by two int values. |
PointD | Class defining a point represented by two double values for the x and y coordinates. |
PSSurface | The PostScript surface is used to render cairo graphics to Adobe PostScript files. |
RadialGradient | Extends Cairo.Gradient to create a new radial gradient between the two circles defined by (cx0, cxy0, radius0) and (cx1, cy1, radius1). |
Rectangle | A representation of a Rectangle. |
ScaledFont | Documentation for this section has not yet been entered. |
SolidPattern | Extends Pattern to create a solid pattern consisting of a solid color and an optional alpha value. |
Status | Reports the internal status of the Cairo system. When an error occurs, all further calls to acquire the status will report the error. |
SubpixelOrder | The 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. |
Surface | Base class for surfaces |
SurfacePattern | Documentation for this section has not yet been entered. |
SurfaceType | Describes the type of a given surface. |
SvgSurface | Documentation for this section has not yet been entered. |
SvgVersion | Describes the version number of the SVG specification that a generated SVG file will conform to. |
TextExtents | Stores the extents of a single glyph or a string of glyphs in user-space coordinates. |
Win32Surface | Microsoft Windows surface support |
XcbSurface | Documentation for this section has not yet been entered. |
XlibSurface | X Window System rendering using XLib |