9 my $area = Gtk2::DrawingArea->new();
17 my $lg = Cairo::RadialGradient->create($x, $y, 0, $x, $y, $rad);
18 $lg->add_color_stop_rgb(0, 0.7, 0, 0.7);
19 $lg->add_color_stop_rgb(1, 0.3, 0, 0.3);
21 $cairo->arc($x, $y, $rad, 0, 2*3.141592);
22 $cairo->set_source($lg);
25 $cairo->arc($x, $y, $rad, 0, 2*3.141592);
26 $cairo->set_source_rgb(1, 1, 1);
27 $cairo->set_line_width($rim);
30 $cairo->set_font_size(0.6*$rad);
31 my $xt = $cairo->text_extents('Brum');
32 $cairo->move_to($x - $xt->{'width'}/2 - $xt->{'x_bearing'},
33 $y - $xt->{'height'}/2 - $xt->{'y_bearing'});
34 $cairo->show_text("Brum");
39 my ($lastw, $lasth, $lastd) = (-1, -1, -1);
40 my ($pixw, $pixh) = (-1, -1);
43 my $win = $area->window;
44 my $wgc = Gtk2::Gdk::GC->new($win);
45 my $alloc = $area->allocation;
46 my $w = $alloc->width;
47 my $h = $alloc->height;
48 my $d = $win->get_depth;
49 # print "Area $w x $h x $d, xx=$xx\n";
51 if (!defined($pixmap) || $lastw != $w || $lasth != $h || $lastd != $d) {
52 ($lastw, $lasth, $lastd) = ($w, $h, $d);
60 print "Resized to ${w}x${h}, pixmap size ${pixw}x${pixh}\n";
63 $wgc->set_rgb_background(0);
64 $wgc->set_rgb_foreground(0);
65 $win->draw_rectangle($wgc, 1, 0, 0, $w, $h);
68 $pixmap = Gtk2::Gdk::Pixmap->new($win, $pixw, $pixh, $d);
69 $cairo = Gtk2::Gdk::Cairo::Context->create($pixmap);
70 $cairo->select_font_face('URW Palladio L', 'normal', 'normal');
71 my $scale = $pixw/1024;
72 $cairo->scale($scale, $scale);
75 $cairo->rectangle(0, 0, 1024, 768);
76 $cairo->set_source_rgb(0, 0, 0);
79 draw_vertex(4/3*$xx, $xx);
81 $win->draw_drawable($wgc, $pixmap, 0, 0, 0, 0, $pixw, $pixh);
91 $area->signal_connect("expose-event" => sub {
93 if (!defined $timer) {
94 $timer = Glib::Timeout->add(100, sub { $stopped || step(); return 1; });
97 $area->set_flags('can-focus');
98 # $area->add_events('key-press-mask');
99 $area->signal_connect('key-press-event' => sub {
101 my $k = Gtk2::Gdk::keyval_name(0, $evt->keyval);
102 print "Pressed key $k\n";
103 if ($k eq "Escape") {
105 } elsif ($k eq "space") {
106 $stopped = !$stopped;
110 my $window = Gtk2::Window->new ('toplevel');
111 $window->signal_connect ("delete-event" => sub { Gtk2->main_quit });
112 $window->set_title("Brum");
113 $window->set_wmclass("anim", "Anim");
114 $window->set_default_size(640, 480);
115 $window->add ($area);
117 #$window->fullscreen;