File: ns-Cairo.xml

package info (click to toggle)
monodoc 1.9-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 98,436 kB
  • ctags: 5,261
  • sloc: xml: 1,506,218; cs: 40,827; sh: 3,647; perl: 554; makefile: 476
file content (80 lines) | stat: -rw-r--r-- 2,439 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<Namespace Name="Cairo">
  <Docs>
    <summary>A binding to the 2D Cairo Graphics rendering API.</summary>
    <remarks>
      <para>
         The Mono.Cairo namespace is a binding to the
	 http://CairoGraphics.org API.
      </para>
      <para>
         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.
      </para>
      <para>
         If you are planning on using the 1.2 API, you should first
	 check using the <see cref="M: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.
      </para>
      <para>
	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:
      </para>
      <example>
	<code lang="C#">
//
// 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");
		}
	}
}
	</code>
      </example>
      <para>
	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.
      </para>
    </remarks>
  </Docs>
</Namespace>