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

Revision 119, 0.6 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.image;
2
3 private
4 {
5     import std.math;
6     import cairooo.all;
7     import cairooo.png.all;
8     import snippets.common;
9 }
10
11 void snippet_image(Context cr, int width, int height)
12 {
13     auto PNGSurface image = new PNGSurface("data/romedalen.png");
14
15     int w = image.width;
16     int h = image.height;
17
18     cr.translate(0.5, 0.5);
19     cr.rotate(45*PI/180);
20     cr.scale(1.0/w, 1.0/h);
21     cr.translate(-0.5*w, -0.5*h);
22
23     cr.setSource(image, 0, 0);
24     cr.paint();
25 }
26
27 static this()
28 {
29     snippets_hash["image"] = &snippet_image;
30 }
Note: See TracBrowser for help on using the browser.