The Big Commit (tm): Remove Cairo.Color and most of Gdk.Color usage from libprolooks
[libprolooks.git] / demos / GaussianBlurDemo.vala
blob4a6662f2021bcdfa9700a536cc0ef49c7a365156
1 /*
2 Copyright 2009 by Hans Baier
3 License: LGPLv2+
4 */
6 using Gtk;
8 namespace Prolooks {
10 public class GaussianBlurDemo : DrawingArea {
12 public GaussianBlurDemo () {
13 // Set favored widget size
14 set_size_request (100, 100);
15 draw.connect(on_draw);
18 /* Widget is asked to draw itself */
19 public bool on_draw (Cairo.Context cr) {
20 Gtk.Allocation allocation;
21 get_allocation(out allocation);
23 SimpleKnobImageSource knob = new SimpleKnobImageSource();
25 double knob_width = knob.get_knob_width ();
26 double knob_height = knob.get_knob_height ();
28 Cairo.ImageSurface surface = new Cairo.ImageSurface (Cairo.Format.ARGB32, (int) knob_width, (int) knob_height);
29 Cairo.Context knobcr = new Cairo.Context (surface);
30 knobcr.set_source_rgba (1, 1, 1, 0.0);
31 knobcr.paint ();
32 knob.paint_knob (knobcr, KnobMode.BIPOLAR, 0, knob.get_line_width(), knob.get_radius(), knob_width / 2, knob_height / 2);
34 cr.set_source_rgb (0, 0, 0);
36 // Gdk.Pixbuf pixbuf = cairo_image_surface_to_pixbuf (surface);
37 // draw_pixbuf_with_shadow (cr, pixbuf, allocation.width/2 - knob_width/2, allocation.height/2 - knob_height/2, knob_width, knob_height, 0, 3);
38 draw_image_surface_with_shadow (cr, surface, allocation.width/2 - knob_width/2, allocation.height/2 - knob_height/2, knob_width, knob_height, 0, 3);
40 return false;
44 static int main (string[] args) {
45 Gtk.init (ref args);
46 var window = new Window (WindowType.TOPLEVEL);
48 var gaussianBlurDemo = new GaussianBlurDemo();
50 window.add (gaussianBlurDemo);
51 window.destroy.connect(Gtk.main_quit);
52 window.show_all ();
53 Gtk.main ();
54 return 0;
56 } // namespace Prolooks