]> git.etc.gen.nz Git - picture-display.git/blob - picture.pl
aee5a09d107b95eaecaa0c639e1916044bc65a71
[picture-display.git] / picture.pl
1 #!/usr/bin/perl -w
2
3 use strict;
4 use FindBin;
5 use Module::Pluggable search_path => ['Display::Plugins'];
6 use Clutter qw( :init );
7 use Getopt::Long;
8
9 use lib "$FindBin::Bin/lib";
10
11 my $full_screen = 1;
12
13 GetOptions(
14   'full|f!' => \$full_screen,
15 );
16
17 my $stage = Clutter::Stage->get_default();
18 $stage->set_color(Clutter::Color->parse('Black'));
19 $stage->signal_connect('key-press-event' => sub { Clutter->main_quit() });
20
21 if ($full_screen) {
22   $stage->fullscreen;
23 } else {
24   $stage->set_size(800, 600);
25 }
26
27 my @modules = loadModules();
28
29 $stage->show_all();
30
31 Clutter->main();
32
33 sub update_screen {
34   for my $module (@modules) {
35     $module->display();
36   }
37 }
38
39 sub loadModules {
40   my @modules;
41
42   for my $module (plugins()) {
43   warn "Considering $module\n";
44     eval "use $module";
45     if ($@) {
46       die "Failed to load plugin: $module ($@)\n";
47     }
48
49     push @modules, $module->new($stage);
50   }
51
52   return @modules;
53
54
55 sub linear {
56   my $alpha    = shift;
57   my $timeline = $alpha->get_timeline();
58
59   return int($timeline->get_progress() * Clutter::Alpha->MAX_ALPHA);
60 }
61
62 sub smoothstep_dec {
63   return Clutter::Alpha->smoothstep_dec($_[0]);
64 }
65 sub smoothstep_inc {
66   return Clutter::Alpha->smoothstep_inc($_[0]);
67 }
68