$cr->move_to( $feature->{ 'x1' }, $feature->{ 'y1' } );
$cr->line_to( $feature->{ 'x2' }, $feature->{ 'y2' } );
}
+ elsif ( $feature->{ 'type' } eq 'grid' )
+ {
+ $cr->set_line_width( $feature->{ 'line_width' } );
+ $cr->move_to( $feature->{ 'x1' }, $feature->{ 'y1' } );
+ $cr->line_to( $feature->{ 'x2' }, $feature->{ 'y2' } );
+ }
elsif ( $feature->{ 'type' } eq 'wiggle' )
{
$cr->set_line_width( $feature->{ 'line_width' } );
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+sub track_grid
+{
+ # Martin A. Hansen, March 2010.
+
+ # Create a grid of vertical lines for the browser image.
+
+ my ( $cookie, # browser cookie
+ ) = @_;
+
+ # Returns a list.
+
+ my ( @grid, $i );
+
+ for ( $i = 0; $i < $cookie->{ 'IMG_WIDTH' }; $i += 20 )
+ {
+ push @grid, {
+ type => 'grid',
+ line_width => 0.1,
+ color => [ 0, 0, 0 ],
+ x1 => $i,
+ y1 => 0,
+ x2 => $i,
+ y2 => $cookie->{ 'TRACK_OFFSET' },
+ };
+ }
+
+ return wantarray ? @grid : \@grid;
+}
+
+
sub track_ruler
{
# Martin A. Hansen, November 2009.
$cookie->{ 'MOVE_RIGHT3' } = $cgi->param( 'move_right3' );
$cookie->{ 'IMG_WIDTH' } = 1200; # Width of browser image in pixels
- $cookie->{ 'IMG_HEIGHT' } = 800; # Height of browser image in pixels
+ $cookie->{ 'IMG_HEIGHT' } = 800; # Height of browser image in pixels # TODO: Redundant?
$cookie->{ 'WIGGLE_HEIGHT' } = 75; # Height of Wiggle tracks in pixels
$cookie->{ 'TRACK_OFFSET' } = 20;
$cookie->{ 'TRACK_SPACE' } = 20;
push @tracks, [ Maasha::BGB::Track::track_feature( $track_list[ $i ], $cookie ) ];
}
+ unshift @tracks, [ Maasha::BGB::Track::track_grid( $cookie ) ];
+
$surface = Cairo::ImageSurface->create( 'argb32', $cookie->{ 'IMG_WIDTH' }, $cookie->{ 'TRACK_OFFSET' } );
$cr = Cairo::Context->create( $surface );
{
foreach $elem ( @{ $track } )
{
- next if $elem->{ 'type' } =~ /text|wiggle/;
+ next if $elem->{ 'type' } =~ /grid|text|wiggle/;
if ( $elem->{ 'type' } eq 'track_name' )
{