Mono Class Library: NamespacesCairo Namespace |
A binding to the 2D Cairo Graphics rendering API. [Edit]
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]
Type Reason CairoAPI Documentation for this section has not yet been entered. Context This is the main object when drawing with Cairo. DirectFBSurface Documentation for this section has not yet been entered. FontFace Documentation for this section has not yet been entered. FontOptions How a font should be rendered GlitzSurface Glitz OpenGL surface support Gradient Base class for gradients. Graphics Obsolete version of Cairo.Context, use it instead. 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). Matrix Defines the Matrix object for transformations and translations. NativeMethods Documentation for this section has not yet been entered. Path Documentation for this section has not yet been entered. Pattern Patterns allow you to tile or extend images and objects and allow you to draw things like gradients. PdfSurface Documentation for this section has not yet been entered. PSSurface Documentation for this section has not yet been entered. RadialGradient Extends Cairo.Gradient to create a new radial gradient between the two circles defined by (cx0, cxy0, radius0) and (cx1, cy1, radius1). 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. Surface Base class for surfaces SurfacePattern Documentation for this section has not yet been entered. SvgSurface Documentation for this section has not yet been entered. Win32Surface Microsoft Windows surface support XcbSurface Documentation for this section has not yet been entered. XlibSurface X Window System rendering using XLib
Type Reason Color Color objects holding red, green, blue, and alpha values. Distance Defines a distance between two points. FontExtents Stores metric information for a font. Values are given in the current user-space coordinate system. Glyph This structure holds information about a single glyph when drawing or measuring text. 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. Rectangle A representation of a Rectangle. TextExtents Stores the extents of a single glyph or a string of glyphs in user-space coordinates.
Type Reason Antialias Specifies the type of antialiasing to do when rendering text or shapes. Content Used to describe the content that a surface will contain, whether color information, alpha information (translucence vs. opacity), or both. Extend Defines Pattern Extend types. FillRule Defines a FillRule. Filter Defines Filter types on Graphics and Pattern objects. FontSlant Defines the possible slants on fonts. FontType Describes the type of a given font face or scaled font. FontWeight Defines the wieght of the font (normal, bold). Format Used to identify the memory format of image data. HintMetrics Specifies whether to hint font metrics. HintStyle Specifies the type of hinting to do on font outlines. LineCap Defines the various line ending styles. LineJoin Documentation for this section has not yet been entered. Operator Documentation for this section has not yet been entered. PatternType Describes the type of a given pattern. 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. SurfaceType Describes the type of a given surface. SvgVersion Describes the version number of the SVG specification that a generated SVG file will conform to.