forum.webdiplomacy.net

webDip dev coordination forum / public access todo list
It is currently Mon Nov 20, 2017 12:07 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Sun Mar 20, 2011 10:25 pm 
Offline

Joined: Wed Jul 29, 2009 10:22 am
Posts: 841
Please, kestas include this small change in drawmap.php.
Every single variant has it's own color-function in the drawmap-class just to circumvent the bugs with the current one.
Code:
   protected function color(array $color, $image=false)
   {
      if ( ! is_array($image) )
         $image = $this->map;
      
      list($r, $g, $b) = $color;
      
      $colorRes = imagecolorexact($image['image'], $r, $g, $b);
      if ($colorRes == -1)
      {
         $colorRes = imageColorAllocate($image['image'], $r, $g, $b);
         if (!$colorRes)
            $colorRes = imageColorClosest($image['image'], $r, $g, $b);
      }
      
      return $colorRes;
   }


Top
 Profile  
 
PostPosted: Fri Dec 30, 2011 11:06 pm 
Offline
Site Admin

Joined: Sat Jun 28, 2008 6:24 am
Posts: 892
I've added this in sleepcap, but it would be good to have some comment etc in the code just so we know what it's about


Top
 Profile  
 
PostPosted: Sat Dec 31, 2011 6:09 am 
Offline

Joined: Wed Jul 29, 2009 10:22 am
Posts: 841
I thought the code is self-explaining.

Code:
protected function color(array $color, $image=false)
   {
      if ( ! is_array($image) )
         $image = $this->map;
     
      list($r, $g, $b) = $color;
     
      // Try to locate the color in the palette
     $colorRes = imagecolorexact($image['image'], $r, $g, $b);
    
     // if not found
      if ($colorRes == -1)
      {
       // make a new palette-entry for the color
         $colorRes = imageColorAllocate($image['image'], $r, $g, $b);
      
       // if the color-palette is full (255 colors allocated) find a substitude
         if (!$colorRes)
            $colorRes = imageColorClosest($image['image'], $r, $g, $b);
      }
     
      return $colorRes;
   }




Top
 Profile  
 
PostPosted: Sat Dec 31, 2011 7:36 am 
Offline
Site Admin

Joined: Sat Jun 28, 2008 6:24 am
Posts: 892
I added more or less equivalent comments in the one I committed, but for someone who doesn't know about GD or palette based images it'd helpful. Not a big deal anyway, it's subjective


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group