use Ham::WorldMap; # replace _moveterm with __moveterm for huge speed gain { no strict 'refs'; *{"Ham::WorldMap" . '::' . "_moveterm"} = \&__moveterm } # __moveterm(wtab, noon, width, height) - update illuminated portion of the globe. # Speed fix from: https://www.perlmonks.org/index.pl?node_id=11148856 sub __moveterm { my ($wtab, $noon, $width, $height) = @_; my $illumMap = Imager->new(ysize => $height, xsize => $width); $illumMap = $illumMap->convert(preset => 'addalpha'); my $day_p = pack 'C4', 255, 255, 255, 10; for (my $i = 0; $i < $height; $i++) { if ($wtab->[$i] >= 0) { my $nl = (($noon - ($wtab->[$i] / 2)) + $width) % $width; my $nh = ($nl + $wtab->[$i]) - 1; my $oh = ($nh - $nl) + 1; if (($nl + $oh) > $width) { $illumMap->setscanline(x => $nl, y => $i, pixels => $day_p x ($width - $nl)); $illumMap->setscanline(x => 0, y => $i, pixels => $day_p x ($nl + $oh - $width + 1)); } else { $illumMap->setscanline(x => $nl, y => $i, pixels => $day_p x ($oh + 1)); } } } return $illumMap; }