From 0ccf2cef20eb168451867dd1201ff4e8fd157b55 Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Wed, 16 Oct 2013 03:21:40 +0200 Subject: [PATCH] histogram: Partly painted insides work, too. --- histogram/histogram | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/histogram/histogram b/histogram/histogram index 3ded1cb..501f376 100755 --- a/histogram/histogram +++ b/histogram/histogram @@ -548,16 +548,20 @@ sub bar_string { my $white = $width-int($l); # $front="F".$front; # $end=$end."E"; + my $rev = ''; + my $reset = ''; if(length $front < $black) { # Paint $front reverse $black -= length $front; $width -= length $front; + $front = $rev . $front . $reset; } else { # label overlaps white # TODO reverse the first $black chars + $white = $width - length $front; + $front = $rev . substr($front,0,$black). $reset.substr($front,$black); $black = 0; $l = 0; - $white = $width - length $front; } if(length $end < $white) { # Just append $end @@ -566,9 +570,10 @@ sub bar_string { } else { # label overlaps black # TODO reverse the first length($end)-$white chars + $black = $width - (length($end)-$white); + $end = $rev . substr($end,0,length($end)-$white). $reset.substr($end,length($end)-$white); $white = 0; $l = 0.9; - $black = $width - length $end; } my $middle = ($eight[0] x $black). ($eight[7-(int($l*8))%8]). (" "x$white);