root/trunk/cairo/cairooo_snippets/snippets/clip_image.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.clip_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_clip_image(Context cr, int width, int height)
12 {
13     cr.arc(0.5, 0.5, 0.3, 0, 2*PI);
14     cr.clip();
15     cr.newPath(); // path not consumed by Context.clip()
16
17     // We use 'auto' to ensure that the surface is destroyed when we leave
18     // this scope.
19     auto PNGSurface image = new PNGSurface("data/romedalen.png");
20    
21     cr.scale(1.0/image.width, 1.0/image.height);
22
23     cr.setSource(image, 0, 0);
24     cr.paint();
25 }
26
27 static this()
28 {
29     snippets_hash["clip_image"] = &snippet_clip_image;
30 }
Note: See TracBrowser for help on using the browser.