sub AlignAll{ foreach my $i (0 .. 3) { my( $x1, $y1, $x2, $y2 ) = $sc[$i]->bbox('rect'); my $location =int(($x1+$x2)/2); ## The location minus half the width of the window ## Over the scaled width of the drawing my $abs = ( $location - 200 ) / ( $initial_width * $scale ); $sc[$i]->xviewMoveto( $abs ); } }