blib/lib/Bio/Graphics/Glyph/wave.pm untested

filter: Statementstmt 0.0% 0 / 32 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 54 CC 7 SCAR 35.1
CC
7
Cov
0%
draw_component
56.0
default_spread
2.0
default_radius
2.0
CRAP 33.5
1 package Bio::Graphics::Glyph::wave;
2  
3 use strict;
4 use base qw(Bio::Graphics::Glyph::generic);
5  
6 sub default_spread
7 {
8 return 0.3;
9 }
10  
11 sub default_radius
12 {
13 return 5;
14 }
15  
16 sub connector { 'none' }
17  
18 sub draw_component {
19 my $self = shift;
20 my $gd = shift;
21 my ($x1,$y1,$x2,$y2) = $self->calculate_boundaries(@_);
22
23 my $spread = defined $self->option('spread') ? $self->option('spread') : $self->default_spread();
24
25 my $fg = $self->fgcolor;
26  
27 my $height = ($y2-$y1)/2;
28 my $midY = $y1 + $height;
29
30 if ($self->option('circle') == 1)
31 {
32 my $radius = defined $self->option('radius') ? $self->option('radius') : $self->default_radius();
33 $gd->ellipse($x1+$radius,$midY,2*$radius,2*$radius,$fg);
34 $x1 = $x1+2*$radius;
35 }
36
37 if ($self->option('line') == 1)
38 {
39 if ($x1 < $x2)
40 {
41 $gd->line($x1,$midY,$x2,$midY,$fg);
42 }
43 return;
44 }
45
46 my ($oldX, $oldY);
47 foreach my $x ($x1..$x2)
48 {
49 my $y = -$height * sin ($spread * ($x-$x1))+$midY;
50 if ($x>$x1)
51 {
52 $gd->line($oldX,$oldY,$x,$y,$fg);
53 }
54 $oldX=$x;
55 $oldY=$y;
56 }
57 }
58  
59  
60 1;
61  
62 __END__