7
Circos::PNG - PNG routines for PNG in Circos
11
This module is not meant to be used directly.
15
Circos is an application for the generation of publication-quality,
16
circularly composited renditions of genomic data and related
19
Circos is particularly suited for visualizing alignments, conservation
20
and intra and inter-chromosomal relationships. However, Circos can be
21
used to plot any kind of 2D data in a circular layout - its use is not
22
limited to genomics. Circos' use of lines to relate position pairs
23
(ribbons add a thickness parameter to each end) is effective to
24
display relationships between objects or positions on one or more
27
All documentation is in the form of tutorials at L<http://www.circos.ca>.
31
# -------------------------------------------------------------------
39
use Carp qw( carp confess croak );
42
use Params::Validate qw(:all);
44
use lib "$FindBin::RealBin";
45
use lib "$FindBin::RealBin/../lib";
46
use lib "$FindBin::RealBin/lib";
48
use Circos::Configuration;
50
use Circos::Constants;
53
use Circos::Image qw(!draw_line);
58
our $default_color = "black";
60
for my $f ( qw ( ) ) {
64
################################################################
69
if( fetch_conf("debug_validate") ) {
70
%params = validate(@_,{
71
point => { type => ARRAYREF },
74
angle_start => { default => 0 },
75
angle_end => { default => 360 },
77
stroke_thickness => 0,
82
$params{angle_start} ||= 0;
83
$params{angle_end} ||= 360;
86
$params{height} ||= $params{width};
88
if(@{$params{point}} != 2) {
89
fatal_error("argument","list_size",current_function(),current_package(),2,int(@{$params{point}}));
92
printdebug_group("png","arc",@{$params{point}},@params{qw(width height angle_start angle_end)});
95
if(my $color = $params{color}) {
96
my $color_obj = aa_color($color,$IM,$COLORS);
97
$IM->filledArc(@{$params{point}},@params{qw(width height angle_start angle_end)},$color_obj);
101
stroke($params{stroke_thickness},$params{stroke_color},"arc",@{$params{point}},@params{qw(width height angle_start angle_end)});
106
if( fetch_conf("debug_validate") ) {
107
%params = validate(@_,{
109
color => fetch_conf("default_color") || $default_color,
116
$params{color} ||= fetch_conf("default_color") || $default_color;
119
printdebug_group("png","polygon",map {@$_} $params{polygon}->vertices);
121
if($params{pattern}) {
122
my ($color_idx,$tile);
123
if ($params{fill_color} ) {
124
$tile = Circos::fetch_colored_fill_pattern($params{pattern},$params{fill_color});
125
} elsif ($params{pattern}) {
126
$tile = Circos::fetch_fill_pattern($params{pattern});
130
$IM->filledPolygon($params{polygon},gdTiled);
132
} elsif ($params{fill_color} && ref $params{polygon} eq "GD::Polygon") {
133
my $color_obj = aa_color( $params{fill_color}, $IM, $COLORS );
134
$IM->filledPolygon($params{polygon},$color_obj);
137
stroke($params{thickness},$params{color},"polydraw",$params{polygon});
142
if( fetch_conf("debug_validate") ) {
143
%params = validate(@_,{
144
points => { type => ARRAYREF },
145
color => { default => fetch_conf("default_color") || $default_color },
146
thickness => { default => 1 },
150
$params{color} ||= fetch_conf("default_color") || $default_color;
151
$params{thickness} ||= 1;
154
if(@{$params{points}} != 4) {
155
fatal_error("argument","list_size",current_function(),current_package(),4,int(@{$params{points}}));
158
printdebug_group("png","line",@{$params{points}},$params{color},$params{thickness});
160
stroke($params{thickness},$params{color},"line",@{$params{points}});
163
# -------------------------------------------------------------------
166
if( fetch_conf("debug_validate") ) {
167
%params = validate(@_,{
168
points => { type => ARRAYREF },
169
color => { default => fetch_conf("default_color") || $default_color },
170
thickness => { default => 1 },
174
$params{color} ||= fetch_conf("default_color") || $default_color;
175
$params{thickness} ||= 1;
178
if ( $params{thickness} > 100 ) {
179
fatal_error("links","too_thick",$params{thickness});
180
} elsif ( $params{thickness} < 1 ) {
181
fatal_error("links","too_thin",$params{thickness});
184
# In the current implementation of gd (2.0.35) antialiasing is
185
# incompatible with thick lines and transparency. Thus, antialiased lines
186
# are available only when thickness=1 and the color has no alpha channel.
188
printdebug_group("link","thickness",$params{thickness},"color",$params{color});
190
my $bezier_poly_line = GD::Polyline->new();
191
for my $point ( @{$params{points}} ) {
192
$bezier_poly_line->addPt(@$point);
195
stroke($params{thickness},$params{color},"polydraw",$bezier_poly_line);
198
# applies a stroke to a GD object drawn by function $fn
199
# added on island of Capri :)
201
my ($st,$sc,$fn,@args) = @_;
204
$sc ||= fetch_conf("default_color") || $default_color;
205
if(fetch_conf("anti_aliasing") && $st == 1 && rgb_color_opacity($sc) == 1) {
206
$IM->setAntiAliased(fetch_color($sc));
207
$color_obj = gdAntiAliased;
209
$IM->setThickness($st) if $st > 1;
210
$color_obj = fetch_color($sc);
212
$IM->$fn(@args,$color_obj);
213
$IM->setThickness(1) if $st > 1;