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

Revision 119, 0.8 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.gradient;
2
3 private
4 {
5     import std.math;
6     import cairooo.all;
7     import snippets.common;
8 }
9
10 void snippet_gradient(Context cr, int width, int height)
11 {
12     {
13         auto Gradient pat = LinearGradient.create(0.0, 0.0, 0.0, 1.0);
14         pat.addColorStopRGBA(1, 0, 0, 0, 1);
15         pat.addColorStopRGBA(0, 1, 1, 1, 1);
16         cr.rectangle(0, 0, 1, 1);
17         cr.setSource(pat);
18         cr.fill();
19     }
20     {
21         auto Gradient pat = RadialGradient.create(0.45, 0.4, 0.1,
22                                                   0.4,  0.4, 0.5);
23         pat.addColorStopRGBA(0, 1, 1, 1, 1);
24         pat.addColorStopRGBA(1, 0, 0, 0, 1);
25         cr.setSource(pat);
26         cr.arc(0.5, 0.5, 0.3, 0, 2*PI);
27         cr.fill();
28     }
29 }
30
31 static this()
32 {
33     snippets_hash["gradient"] = &snippet_gradient;
34 }
Note: See TracBrowser for help on using the browser.