Design flaw indeed. My app does a few other things and was taking nearly 5 seconds, without the Imager hacks. Your technique brings it down to the 0.8s range. This is astonishing! Feels almost instant, except in that third loop, thank you.
> Can't deny you the pleasure to replace third loop yourself, similarly to 1st and 2nd loops.
I barely grasp the original code, scanline is over my head for the time being, can you help an anonymonk out? This seemed logicalish from the third loop variables but didn't do enough, or did too much, not that I even know why:
> Accidentally, that fragment (3d loop) isn't run with DateTime picked for synopsis, btw.$illumMap->setscanline(x => $nl, y => $i, pixels => $day_p x ($nl + $o +h));
What does that mean? Thanks for your help. It's so much faster 5-6x unbelievable!
Finally, to maximize enjoyment, Ham::Locator transforms latitude and longitude to pixel cooordinates or dots on the Ham::WorldMap:
use Ham::Locator; use Ham::WorldMap; my $lat = 40.712778; my $lon = -74.006111; my $png = 'worldmap.png'; my $map = Ham::WorldMap->new; my $loc = Ham::Locator->new; $loc->set_latlng($lat,$lon); $map->dotAtLocator($loc->latlng2loc, 12, Imager::Color->new(0,255,0)); $map->drawNightRegions(DateTime->now); my ($x, $y) = $map->locatorToXY($loc->latlng2loc); $map->write($png) or die $map->errstr; print qq[Dot drawn at $x,$y on $png\n];
In reply to Re^4: Double the speed of Imager->setpixel
by Anonymous Monk
in thread Double the speed of Imager->setpixel
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |