| 1 | # $Id: $ $Revision: $ $Source: $ $Date: $ | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | package WWW::CloudCreator; | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use POSIX qw(ceil floor); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 2 | our $VERSION = '1.1'; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 13 | 0 | my ($class, %args) = @_; | |||||||||||||||||||||||||||
| 14 | 0 | my $self = bless{ | |||||||||||||||||||||||||||
| 15 | 'counts' => {}, | ||||||||||||||||||||||||||||
| 16 | 'smallest' => 8, | ||||||||||||||||||||||||||||
| 17 | 'largest' => 16, | ||||||||||||||||||||||||||||
| 18 | 'cold' => '000', | ||||||||||||||||||||||||||||
| 19 | 'hot' => 'E00', | ||||||||||||||||||||||||||||
| 20 | %args, | ||||||||||||||||||||||||||||
| 21 | }, $class; | ||||||||||||||||||||||||||||
| 22 | 0 | return $self; | |||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 0 | ▶ | sub add { | ||||||||||||||||||||||||||
|
Subroutine
add: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 26 | 0 | my ( $self, $tag, $count ) = @_; | |||||||||||||||||||||||||||
| 27 | 0 | ▶ | if (! $tag || ! $count) { return 0; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$tag and $count
MC/DC0%0/2
$tag and $count
$tag
$count
Truth table0%0/3
A and B
A= $tagB= $count
| |||||||||||||||||||||||||||||
| 28 | 0 | $self->{counts}->{$tag} = $count; | |||||||||||||||||||||||||||
| 29 | 0 | return 1; | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 0 | ▶ | sub gencloud { | ||||||||||||||||||||||||||
|
Subroutine
gencloud: not called CC=16 SCAR=56.1
Pod
documented
| |||||||||||||||||||||||||||||
| 33 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 34 | 0 | ▶ | my $smallest = $self->{'smallest'} || 8; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'smallest'} || 8
MC/DC0%0/1
$self->{'smallest'} || 8
$self->{'smallest'}
Truth table0%0/2
A
A= $self->{'smallest'}
| |||||||||||||||||||||||||||||
| 35 | 0 | ▶ | my $largest = $self->{'largest'} || 16; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'largest'} || 16
MC/DC0%0/1
$self->{'largest'} || 16
$self->{'largest'}
Truth table0%0/2
A
A= $self->{'largest'}
| |||||||||||||||||||||||||||||
| 36 | 0 | ▶ | my $cold = $self->{'cold'} || '000'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'cold'} || '000'
MC/DC0%0/1
$self->{'cold'} || '000'
$self->{'cold'}
Truth table0%0/2
A
A= $self->{'cold'}
| |||||||||||||||||||||||||||||
| 37 | 0 | ▶ | my $hot = $self->{'hot'} || '000'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'hot'} || '000'
MC/DC0%0/1
$self->{'hot'} || '000'
$self->{'hot'}
Truth table0%0/2
A
A= $self->{'hot'}
| |||||||||||||||||||||||||||||
| 38 | 0 | my $counts = $self->{'counts'}; | |||||||||||||||||||||||||||
| 39 | 0 | my @tags = sort { $counts->{$b} <=> $counts->{$a} } keys %{$counts}; | |||||||||||||||||||||||||||
| 40 | 0 | my $ntags = scalar @tags; | |||||||||||||||||||||||||||
| 41 | 0 | ▶ | if ($ntags == 0) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 42 | 0 | return q{}; | |||||||||||||||||||||||||||
| 43 | } elsif ($ntags == 1) { | ||||||||||||||||||||||||||||
| 44 | 0 | my $tag = $tags[0]; | |||||||||||||||||||||||||||
| 45 | 0 | return [ $tag, 1, 'font-size:' . $smallest . q{;} ]; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | 0 | my $min = $counts->{$tags[-1]}; | |||||||||||||||||||||||||||
| 48 | 0 | my $max = $counts->{$tags[0]}; | |||||||||||||||||||||||||||
| 49 | 0 | my $spread = $max - $min; | |||||||||||||||||||||||||||
| 50 | 0 | my ($fontspread, $fontstep); | |||||||||||||||||||||||||||
| 51 | 0 | ▶ | if ($largest != $smallest) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | 0 | $fontspread = $largest - $smallest; | |||||||||||||||||||||||||||
| 53 | 0 | ▶ | if ($spread > 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | 0 | $fontstep = $fontspread / $spread; | |||||||||||||||||||||||||||
| 55 | } else { | ||||||||||||||||||||||||||||
| 56 | 0 | $fontstep = 0; | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | 0 | my (@hotarray, @coldarray, @coldval, @hotval, @colorspread, @colorstep); | |||||||||||||||||||||||||||
| 60 | 0 | ▶ | if ($hot ne $cold) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | 0 | @hotarray = map { hex $_ } (split //xm, $hot); | |||||||||||||||||||||||||||
| 62 | 0 | @coldarray = map { hex $_ } (split //xm, $cold); | |||||||||||||||||||||||||||
| 63 | 0 | for my $i (0 .. 2) { | |||||||||||||||||||||||||||
| 64 | 0 | push @coldval, hexdec($coldarray[$i]); | |||||||||||||||||||||||||||
| 65 | 0 | push @hotval, hexdec($hotarray[$i]); | |||||||||||||||||||||||||||
| 66 | 0 | push @colorspread, ( hexdec($hotarray[$i]) - hexdec($coldarray[$i]) ); | |||||||||||||||||||||||||||
| 67 | 0 | ▶ | if ($spread > 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | 0 | push @colorstep, ( hexdec($hotarray[$i]) - hexdec($coldarray[$i]) ) / $spread; | |||||||||||||||||||||||||||
| 69 | } else { | ||||||||||||||||||||||||||||
| 70 | 0 | push @colorstep, '0'; | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | 0 | my (@out); | |||||||||||||||||||||||||||
| 75 | 0 | foreach my $tag ( sort @tags ) { | |||||||||||||||||||||||||||
| 76 | 0 | my $fraction = $counts->{$tag} - $min; | |||||||||||||||||||||||||||
| 77 | 0 | my $fontsize = $smallest + ( $fontstep * $fraction); | |||||||||||||||||||||||||||
| 78 | 0 | my (@style, $color); | |||||||||||||||||||||||||||
| 79 | 0 | ▶ | if ($hot ne $cold) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 80 | 0 | for my $i ( 0 .. 2 ) { | |||||||||||||||||||||||||||
| 81 | 0 | my $ihex = $coldarray[$i] + ($colorstep[$i] * $fraction); | |||||||||||||||||||||||||||
| 82 | 0 | my $decihex = dechex( $ihex ); | |||||||||||||||||||||||||||
| 83 | 0 | $color .= $decihex; | |||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | 0 | } else { $color = $cold; } | |||||||||||||||||||||||||||
| 86 | 0 | push @style, 'color: #' . $color . q{;}; | |||||||||||||||||||||||||||
| 87 | 0 | ▶ | if ($largest != $smallest) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 88 | 0 | push @style, 'font-size: ' . round($fontsize) . 'pt;'; | |||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | 0 | push @out, [ $tag, $counts->{$tag}, join q{}, @style]; | |||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | 0 | return @out; | |||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 0 | ▶ | sub round { return int $_[0] + .5 * ($_[0] <=> 0); } | ||||||||||||||||||||||||||
|
Subroutine
round: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 0 | ▶ | sub dechex { return sprintf '%x', $_[0]; } | ||||||||||||||||||||||||||
|
Subroutine
dechex: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 0 | ▶ | sub hexdec { return hex $_[0]; } | ||||||||||||||||||||||||||
|
Subroutine
hexdec: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 2 | 1; | |||||||||||||||||||||||||||
| 102 | __END__ | ||||||||||||||||||||||||||||