| 1 | package Bio::Graphics::Glyph::christmas_arrow; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use base qw(Bio::Graphics::Glyph::generic); | ||
| 5 | |||
| 6 | use Math::Trig; | ||
| 7 | |||
| 8 | sub my_description { | ||
| 9 | return <<END; | ||
| 10 | This glyph draws an arrow which has a circle ("christmas ball") | ||
| 11 | dangling at one end. | ||
| 12 | END | ||
| 13 | } | ||
| 14 | sub my_options { | ||
| 15 | return { | ||
| 16 | radius => ['integer',4, 'Radius of the circle glyph.'], | ||
| 17 | length => ['integer',20,'Length of the arrow.'], | ||
| 18 | } | ||
| 19 | } | ||
| 20 | |||
| 21 | sub default_radius | ||
| 22 | { | ||
| 23 | return 4; | ||
| 24 | } | ||
| 25 | |||
| 26 | sub default_length | ||
| 27 | { | ||
| 28 | return 20; | ||
| 29 | } | ||
| 30 | |||
| 31 | sub draw_component { | ||
| 32 | my $self = shift; | ||
| 33 | my $gd = shift; | ||
| 34 | my ($x1,$y1,$x2,$y2) = $self->calculate_boundaries(@_); | ||
| 35 | |||
| 36 | my $fg = $self->fgcolor; | ||
| 37 | |||
| 38 | my $radius = defined $self->option('radius') ? $self->option('radius') : $self->default_radius (); | ||
| 39 | |||
| 40 | $gd->filledEllipse($x1+$radius, $y2-$radius, 2*$radius, 2*$radius, $fg); | ||
| 41 | |||
| 42 | my $length = defined $self->option('length') ? $self->option('length') : $self->default_length(); | ||
| 43 | |||
| 44 | my $angle = deg2rad(30); | ||
| 45 | my $dx = 6; | ||
| 46 | my $dy = 4; | ||
| 47 | my $midX = $x2-$dx; | ||
| 48 | my $midY = $y1+$dy; | ||
| 49 | |||
| 50 | $gd->line($x1+$radius, $y2-$radius, $x1+$radius, $y1+$dy, $fg); | ||
| 51 | |||
| 52 | return if ($x2-$x1 <= $radius); | ||
| 53 | |||
| 54 | $x2 = $x1+$radius+$length; | ||
| 55 | $gd->line($x1+$radius, $midY, $x2, $midY, $fg); | ||
| 56 | $gd->line($x2, $midY, $x2-$dx, $y1, $fg); | ||
| 57 | $gd->line($x2, $midY, $x2-$dx, $y1+2*$dy, $fg); | ||
| 58 | |||
| 59 | } | ||
| 60 | |||
| 61 | |||
| 62 | 1; | ||
| 63 | |||
| 64 | __END__ |