1 package Maasha::KISS::Draw;
3 # Copyright (C) 2009 Martin A. Hansen.
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 # http://www.gnu.org/copyleft/gpl.html
22 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
25 # Routines for creating KISS graphics.
28 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
36 use vars qw( @ISA @EXPORT );
38 @ISA = qw( Exporter );
41 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
46 # Martin A. Hansen, October 2005.
48 # inititalizes SVG object, which is returned.
50 my ( $height, # Height in pixels
51 $width, # Width in pixels
68 # Martin A. Hansen, October 2009.
70 # Adds a top level layer frame of given
71 # height and width to an SVG object.
73 my ( $height, # Height in pixels
74 $width, # Width in pixels
109 sub svg_track_feature
111 # Martin A. Hansen, October 2009.
113 # Given a list of features add these to
116 my ( $height, # Height in pixels
117 $width, # Width in pixels
119 $features, # List of features
120 $track_id, # Unique track id
121 $color, # Color of features
126 my ( $track, $i, $id, $x, $y, $w, $h );
128 $track = $svg->group(
136 for ( $i = 0; $i < @{ $features }; $i++ )
139 $x = $features->[ $i ]->{ 'x' };
140 $y = $features->[ $i ]->{ 'y' };
141 $h = $features->[ $i ]->{ 'height' };
142 $w = $features->[ $i ]->{ 'width' };
144 # $track->rectangle( id => $id, x => $x, y => $y, width => $w, height => $h );
146 $track->line( id => $id, x1 => $x, y1 => $y, x2 => $x + $w, y2 => $y );
151 sub svg_track_histogram
153 # Given a list of features add these to
156 my ( $svg, # SVG object
157 $features, # List of features
158 $track_id, # Unique track id
159 $color, # Color of features
166 $track = $svg->group(
174 for ( $i = 0; $i < @{ $features }; $i++ )
178 x1 => $features->[ $i ]->{ 'x1' },
179 y1 => $features->[ $i ]->{ 'y1' },
180 x2 => $features->[ $i ]->{ 'x2' },
181 y2 => $features->[ $i ]->{ 'y2' },
189 # Martin A. Hansen, October 2009.
191 # Prints XML output from a SVG object.
193 my ( $svg, # SVG object
194 $fh, # file handle - OPTIONAL
201 print $fh $svg->xmlify;
211 @html = "Content-Type: text/html; charset=ISO-8859-1\n\n";
213 push @html, "<pre>\n";
214 push @html, Dumper( $foo );
215 push @html, "</pre>\n";
217 return wantarray ? @html : \@html;
221 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<