Ejemplo n.º 1
0
 /**
  * Render avatar
  */
 private function render($data)
 {
     // Load Class and set parameters
     $chargen = new CharacterRender();
     $chargen->action = CharacterRender::ACTION_IDLE;
     $chargen->direction = CharacterRender::DIRECTION_SOUTH;
     $chargen->body_animation = 0;
     $chargen->doridori = 0;
     $chargen->loadFromSqlData($data);
     // Load images
     $player = $chargen->render();
     $border = imagecreatefrompng(Cache::$path . "avatar/data/border.png");
     $background = imagecreatefromjpeg(Cache::$path . "avatar/data/background01.jpg");
     $output = imagecreatetruecolor(128, 128);
     // Build image
     imagecopy($output, $background, 7, 7, 0, 0, 114, 114);
     imagecopy($output, $player, 7, 7, 35 + 7, 65 + 7, imagesx($player) - 14, imagesx($player) - 14);
     imagecopy($output, $border, 0, 0, 0, 0, 128, 128);
     // Add emblem
     if (!empty($data['emblem_data'])) {
         $binary = @gzuncompress(pack('H*', $data['emblem_data']));
         if ($binary && ($emblem = imagecreatefrombmpstring($binary))) {
             imagecopy($output, $emblem, 128 - 10 - 24, 128 - 10 - 24, 0, 0, 24, 24);
         }
     }
     // Set color for text
     $name_color = imagecolorallocate($output, 122, 122, 122);
     $lvl_color = imagecolorallocate($output, 185, 109, 179);
     $status_color = $data['online'] ? imagecolorallocate($output, 59, 129, 44) : imagecolorallocate($output, 188, 98, 98);
     // Draw text
     imagestring($output, 1, 12, 12, strtoupper($data['name']), $name_color);
     imagestring($output, 1, 12, 25, $data['base_level'] . "/" . $data['job_level'], $lvl_color);
     imagestring($output, 1, 81, 12, $data['online'] ? "ONLINE" : "OFFLINE", $status_color);
     imagepng($output);
 }
Ejemplo n.º 2
0
 /**
  * Render avatar
  */
 private function render($data, $action, $animation)
 {
     // Load Class and set parameters
     $chargen = new CharacterRender();
     $chargen->action = $action == -1 ? CharacterRender::ACTION_READYFIGHT : intval($action);
     $chargen->direction = $animation == -1 ? CharacterRender::DIRECTION_SOUTHEAST : intval($animation);
     $chargen->body_animation = 4;
     $chargen->doridori = 0;
     // Generate Image
     $chargen->loadFromSqlData($data);
     $img = $chargen->render();
     imagepng($img);
 }
Ejemplo n.º 3
0
 /**
  * Render avatar
  */
 private function render($data)
 {
     // Load Class and set parameters
     $chargen = new CharacterRender();
     $chargen->action = CharacterRender::ACTION_SIT;
     $chargen->direction = CharacterRender::DIRECTION_SOUTHEAST;
     $chargen->body_animation = 0;
     $chargen->doridori = 0;
     $chargen->loadFromSqlData($data);
     // Build background
     $player = $chargen->render();
     $output = imagecreatetruecolor(194, 110);
     $background = imagecreatefromjpeg(Cache::$path . "signature/data/background01.jpg");
     imagecopy($output, $background, 2, 2, 0, 0, 190, 106);
     imagecopy($output, $player, 2, 2, 55, 80, imagesx($player) - 55 - 4, imagesx($player) - 90 - 4);
     // Add emblem
     if (!empty($data['emblem_data'])) {
         $binary = @gzuncompress(pack('H*', $data['emblem_data']));
         if ($binary && ($emblem = imagecreatefrombmpstring($binary))) {
             imagecopy($output, $emblem, 194 - 6 - 24, 6, 0, 0, 24, 24);
         }
     }
     // Set color for text
     $name_color = imagecolorallocate($output, 254, 242, 183);
     $lvl_color = imagecolorallocate($output, 240, 143, 89);
     $status_color = $data['online'] ? imagecolorallocate($output, 125, 196, 126) : imagecolorallocate($output, 190, 83, 83);
     // Text align right func
     function imagestringright(&$img, $size, $x, $y, $str, $color)
     {
         imagestring($img, $size, $x - strlen($str) * imagefontwidth($size), $y, $str, $color);
     }
     // Draw text
     imagestringright($output, 2, 187, 69, $data['name'], $name_color);
     imagestringright($output, 2, 187, 82, $data['base_level'] . "/" . $data['job_level'], $lvl_color);
     imagestringright($output, 2, 187, 93, $data['online'] ? "Online" : "Offline", $status_color);
     // Cache the image
     imagepng($output);
 }