1
package Bio::Graphics::Glyph::triangle;
2
# DAS-compatible package to use for drawing a triangle
5
use base qw(Bio::Graphics::Glyph::generic);
9
my $left = $self->SUPER::pad_left;
10
return $left unless $self->option('point');
11
my $extra = $self->option('height')/3;
12
return $extra > $left ? $extra : $left;
17
my $right = $self->SUPER::pad_right;
18
return $right unless $self->option('point');
19
my $extra = $self->option('height')/3;
20
return $extra > $right ? $extra : $right;
26
my $fg = $self->fgcolor;
27
my $orient = $self->option('orient') || 'S';
29
# find the center and vertices
30
my ($x1,$y1,$x2,$y2) = $self->calculate_boundaries(@_);
31
my $xmid = ($x1+$x2)/2;
32
my $ymid = ($y1+$y2)/2;
34
my ($vx1,$vy1,$vx2,$vy2,$vx3,$vy3);
37
my ($p,$q) = ($self->option('height'),($x2-$x1)/2);
38
if ($self->option('point')){
40
$x1 = $xmid - $q; $x2 = $xmid + $q;
41
$y1 = $ymid - $q; $y2 = $ymid + $q;
44
if ($orient eq 'S'){$vx1=$x1;$vy1=$y1;$vx2=$x2;$vy2=$y1;$vx3=$xmid;$vy3=$y2;}
45
elsif($orient eq 'N'){$vx1=$x1;$vy1=$y2;$vx2=$x2;$vy2=$y2;$vx3=$xmid;$vy3=$y1;}
46
elsif($orient eq 'W'){$vx1=$x2;$vy1=$y1;$vx2=$x2;$vy2=$y2;$vx3=$x2-$q*2;$vy3=$ymid;}
47
elsif($orient eq 'E'){$vx1=$x1;$vy1=$y1;$vx2=$x1;$vy2=$y2;$vx3=$x1+$q*2;$vy3=$ymid;}
49
# now draw the triangle
50
my $poly_pkg = $self->polygon_package;
51
my $poly = $poly_pkg->new();
52
$poly->addPt($vx1,$vy1);
53
$poly->addPt($vx2,$vy2);
54
$poly->addPt($vx3,$vy3);
56
if (my $c = $self->bgcolor){
57
$gd->filledPolygon($poly,$c);
59
$gd->polygon($poly,$fg);
68
Bio::Graphics::Glyph::triangle - The "triangle" glyph
72
See L<Bio::Graphics::Panel> and L<Bio::Graphics::Glyph>.
76
This glyph draws an equilateral triangle when -point is defined.
77
It draws an isoceles triangle otherwise. It is possible to draw
78
the triangle with the base on the N, S, E, or W side.
82
In addition to the common options, the following glyph-specific
83
options are recognized:
85
Option Description Default
86
------ ----------- -------
88
-point If true, the triangle 0
89
will drawn at the center
90
of the range, and not scaled
93
-orient On which side shall the S
102
L<Bio::Graphics::Panel>,
103
L<Bio::Graphics::Glyph>,
104
L<Bio::Graphics::Glyph::arrow>,
105
L<Bio::Graphics::Glyph::cds>,
106
L<Bio::Graphics::Glyph::crossbox>,
107
L<Bio::Graphics::Glyph::diamond>,
108
L<Bio::Graphics::Glyph::dna>,
109
L<Bio::Graphics::Glyph::dot>,
110
L<Bio::Graphics::Glyph::ellipse>,
111
L<Bio::Graphics::Glyph::extending_arrow>,
112
L<Bio::Graphics::Glyph::generic>,
113
L<Bio::Graphics::Glyph::graded_segments>,
114
L<Bio::Graphics::Glyph::heterogeneous_segments>,
115
L<Bio::Graphics::Glyph::line>,
116
L<Bio::Graphics::Glyph::pinsertion>,
117
L<Bio::Graphics::Glyph::primers>,
118
L<Bio::Graphics::Glyph::rndrect>,
119
L<Bio::Graphics::Glyph::segments>,
120
L<Bio::Graphics::Glyph::ruler_arrow>,
121
L<Bio::Graphics::Glyph::toomany>,
122
L<Bio::Graphics::Glyph::transcript>,
123
L<Bio::Graphics::Glyph::transcript2>,
124
L<Bio::Graphics::Glyph::translation>,
125
L<Bio::Graphics::Glyph::triangle>,
134
Allen Day E<lt>day@cshl.orgE<gt>.
136
Copyright (c) 2001 Cold Spring Harbor Laboratory
138
This library is free software; you can redistribute it and/or modify
139
it under the same terms as Perl itself. See DISCLAIMER.txt for
140
disclaimers of warranty.