summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-10-29 12:09:09 +0200
committerDaniel Friesel <derf@finalrewind.org>2011-10-29 12:09:09 +0200
commit0e00371868a2e11f1a827f914e431d24ff9d74c9 (patch)
tree7730f91111b37a7564c495f9b268e628b3f84649
parent7eda6144f679c503a30563157c9bb22f53704828 (diff)
Fix minutes, support any color
-rw-r--r--cgi/index.pl11
-rw-r--r--lib/App/VRR/Fakedisplay.pm2
2 files changed, 10 insertions, 3 deletions
diff --git a/cgi/index.pl b/cgi/index.pl
index 2c64482..63f2442 100644
--- a/cgi/index.pl
+++ b/cgi/index.pl
@@ -54,11 +54,13 @@ sub render_image {
my $dt_now = DateTime->now(time_zone => 'Europe/Berlin');
+ my $color = $self->param('color') // '255,0,0';
+
$self->res->headers->content_type('image/png');
my ($results, $errstr) = get_results_for($city, $stop);
- my $png = App::VRR::Fakedisplay->new(width => 180, height => 50);
+ my $png = App::VRR::Fakedisplay->new(width => 180, height => 50, color => [split(qr{,}, $color)]);
for my $d (@{$results}) {
my $line = $d->line;
@@ -95,7 +97,7 @@ sub render_image {
}
elsif ($duration->in_units('hours') == 0) {
$etr = sprintf(
- ' %2dmin',
+ ' %2d',
$duration->in_units('minutes'),
);
}
@@ -108,6 +110,11 @@ sub render_image {
$png->draw_at(0, $line);
$png->draw_at(25, $destination);
$png->draw_at(145, $etr);
+
+ if ($etr ne 'sofort') {
+ $png->draw_at(161, 'min');
+ }
+
$png->new_line();
}
diff --git a/lib/App/VRR/Fakedisplay.pm b/lib/App/VRR/Fakedisplay.pm
index 782f7ca..b380382 100644
--- a/lib/App/VRR/Fakedisplay.pm
+++ b/lib/App/VRR/Fakedisplay.pm
@@ -26,7 +26,7 @@ sub new {
$self->{image} = GD::Image->new($self->{width} * $self->{scale}, $self->{height} * $self->{scale});
$self->{color}->{bg} = $self->{image}->colorAllocate(0, 0, 0);
- $self->{color}->{fg} = $self->{image}->colorAllocate(255, 0, 0);
+ $self->{color}->{fg} = $self->{image}->colorAllocate(@{$opt{color} // [255, 0, 0]});
$self->{image}->filledRectangle(0, 0, ($self->{width} * $self->{scale}) -1,
($self->{height} * $self->{scale}) - 1, $self->{color}->{bg});