summaryrefslogtreecommitdiff
path: root/bin/vdf
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-01-09 12:15:20 +0100
committerDaniel Friesel <derf@finalrewind.org>2011-01-09 12:15:20 +0100
commitd638780a2748c1815c488c50927e128278d683c4 (patch)
treeb42bcf727481c2512c25948ad29a469c162b0dfb /bin/vdf
parent631d723fed7dfdcab1e7bd731a143c2bed453e6d (diff)
vdf: Prettier bars
Diffstat (limited to 'bin/vdf')
-rwxr-xr-xbin/vdf35
1 files changed, 29 insertions, 6 deletions
diff --git a/bin/vdf b/bin/vdf
index 9489ecd..871a4a9 100755
--- a/bin/vdf
+++ b/bin/vdf
@@ -43,17 +43,40 @@ sub bar_console {
sub bar_png {
my ($percent, $w, $h) = @_;
my $bar = GD::Image->new($w, $h);
+ my $l_int = 6;
- my $black = $bar->colorAllocateAlpha( 0, 0, 0, $alpha);
- my $gray = $bar->colorAllocateAlpha(127, 127, 127, $alpha);
- my $lgray = $bar->colorAllocateAlpha(191, 191, 191, $alpha);
- my $white = $bar->colorAllocateAlpha(255, 255, 255, $alpha);
+ my ($w_o, $w_w) = ($w * 0.8, $w * 0.9);
+
+ my $black = $bar->colorAllocateAlpha( 0, 0, 0, $alpha);
+ my $gray = $bar->colorAllocateAlpha(127, 127, 127, $alpha);
+ my $lgray = $bar->colorAllocateAlpha(191, 191, 191, $alpha);
+ my $ok_b = $bar->colorAllocateAlpha(220, 240, 220, $alpha);
+ my $ok_f = $bar->colorAllocateAlpha( 59, 191, 50, $alpha);
+ my $wa_b = $bar->colorAllocateAlpha(240, 240, 220, $alpha);
+ my $wa_f = $bar->colorAllocateAlpha(191, 191, 50, $alpha);
+ my $cr_b = $bar->colorAllocateAlpha(240, 220, 220, $alpha);
+ my $cr_f = $bar->colorAllocateAlpha(191, 0, 0, $alpha);
+ my $white = $bar->colorAllocateAlpha(255, 255, 255, $alpha);
my $vwidth = sprintf("%d", ($w- 2) * $percent / 100);
$bar->rectangle(0, 0, $w - 1, $h - 1, $gray);
- $bar->filledRectangle(1, 1, $w - 2, $h - 2, $white);
- $bar->filledRectangle(1, 1, $vwidth, $h - 2, $lgray);
+ $bar->filledRectangle(1, 1, $w - 2, $h - 2, $cr_b);
+ $bar->filledRectangle(1, 1, $w_w - 1, $h - 2, $wa_b);
+ $bar->filledRectangle(1, 1, $w_o - 1, $h - 2, $ok_b);
+ $bar->filledRectangle(1, 1, $vwidth , $h - 2, $ok_f);
+
+ if ($vwidth > $w_o) {
+ $bar->filledRectangle($w_o, 1, $vwidth, $h - 2, $wa_f);
+ }
+
+ if ($vwidth > $w_w) {
+ $bar->filledRectangle($w_w, 1, $vwidth, $h - 2, $cr_f);
+ }
+
+ for my $i (1 .. $w / $l_int) {
+ $bar->line($i * $l_int, 1, $i * $l_int, $h - 2, $white);
+ }
return $bar;
}