From 4abf6fd81a21972af697305f38106c9ada9f039d Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 27 Jun 2011 02:10:22 +0200 Subject: vcalendar: White background, but only if necessary --- bin/vcalendar | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/bin/vcalendar b/bin/vcalendar index 502d900..73995f7 100755 --- a/bin/vcalendar +++ b/bin/vcalendar @@ -13,9 +13,11 @@ getopts('a:cfgC:', \%opts); my $alpha = $opts{'a'} // 0; -my $im = GD::Image->new(200, 40); +my $im = GD::Image->new(200, 80); $im->saveAlpha(1); +my $white = $im->colorAllocateAlpha(255, 255, 255, $alpha); +my $gray = $im->colorAllocateAlpha(127, 127, 127, $alpha); my $fg = $im->colorAllocateAlpha( 0, 0, 0, $alpha); my $bg = $im->colorAllocateAlpha( 0, 0, 0, 127); @@ -29,7 +31,19 @@ if ($opts{'c'}) { say join("\n", @lines); } elsif ($opts{'g'}) { - $im->filledRectangle(0, 0, 200, 40, $bg); + $im->filledRectangle(0, 0, 200, 80, $bg); + + my $used_height = @lines * 10; + + if ($used_height > 72) { + $used_height = 72; + } + + if ($used_height) { + $used_height += 8; + $im->filledRectangle(0, 0, 200, $used_height, $white); + $im->rectangle(0, 0, 200, $used_height, $gray); + } for my $i (0 .. $#lines) { $lines[$i] =~ s{\t}{}; -- cgit v1.2.3