summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-06-27 02:10:22 +0200
committerDaniel Friesel <derf@finalrewind.org>2011-06-27 02:10:22 +0200
commit4abf6fd81a21972af697305f38106c9ada9f039d (patch)
treed7a26e0fa4dc27cb17dc3b202cedce9c81d50216
parent7669f50c0650196f855d724849e3678355a3f91d (diff)
vcalendar: White background, but only if necessary
-rwxr-xr-xbin/vcalendar18
1 files 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}{};