root/trunk/cairo/cairooo_snippets/snippets/text.d

Revision 119, 0.7 kB (checked in by DRK, 6 years ago)

* Added bindings for the Glitz and Xlib backends.
* Checked in cairooo: an OO layer on top of the cairo binding.
* Added snippets directory for cairooo
* Added basic tutorial on how to use cairooo
* Added a simple demo program.
* Added scripts for building import libraries.
* Fixed several bugs.
* Drank WAAY too much coffee.

Line 
1 module snippets.text;
2
3 private
4 {
5     import std.math;
6     import cairooo.all;
7     import snippets.common;
8 }
9
10 void snippet_text(Context cr, int width, int height)
11 {
12     cr.selectFontFace("Sans", FontSlant.Normal, FontWeight.Bold);
13     cr.setFontSize(0.35);
14
15     cr.moveTo(0.04, 0.53);
16     cr.showText("Hello");
17
18     cr.moveTo(0.27, 0.65);
19     cr.textPath("void");
20     cr.setSourceRGB(0.5, 0.5, 1);
21     cr.fillPreserve();
22     cr.setSourceRGB(0, 0, 0);
23     cr.lineWidth = 0.01;
24     cr.stroke();
25
26     // draw helping lines
27     cr.setSourceRGBA(1, 0.2, 0.2, 0.6);
28     cr.arc(0.04, 0.53, 0.02, 0, 2*PI);
29     cr.arc(0.27, 0.65, 0.02, 0, 2*PI);
30     cr.fill();
31 }
32
33 static this()
34 {
35     snippets_hash["text"] = &snippet_text;
36 }
Note: See TracBrowser for help on using the browser.