Exemple #1
0
 /**
  * Process entry
  */
 public function process($sex, $jobid, $clothes_color, $hair, $hair_color, $doridori, $head_top, $head_mid, $head_bottom, $weapon, $shield, $robe, $option, $direction, $action, $animation)
 {
     header('Content-type:image/png');
     header('Cache-Control: max-age=30000, public');
     // Load Class and set parameters
     // intval() is needed because parameters are received as
     // string but compared with "===" to int (which result to false:  "5" === 5 -> false).
     $chargen = new CharacterRender();
     $chargen->action = intval($action);
     $chargen->direction = intval($direction);
     $chargen->body_animation = intval($animation);
     $chargen->sex = $sex;
     $chargen->class = intval($jobid);
     $chargen->clothes_color = intval($clothes_color);
     $chargen->hair = intval($hair);
     $chargen->hair_color = intval($hair_color);
     $chargen->doridori = intval($doridori);
     $chargen->head_top = intval($head_top);
     $chargen->head_mid = intval($head_mid);
     $chargen->head_bottom = intval($head_bottom);
     $chargen->weapon = intval($weapon);
     $chargen->shield = intval($shield);
     $chargen->robe = intval($robe);
     $chargen->option = intval($option);
     // Generate Image
     $img = $chargen->render();
     imagepng($img);
 }
Exemple #2
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);
 }
Exemple #3
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);
 }
Exemple #4
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);
 }
Exemple #5
0
<?php

$chargen = new CharacterRender();
$chargen->action = CharacterRender::ACTION_READYFIGHT;
$chargen->direction = CharacterRender::DIRECTION_SOUTHEAST;
$chargen->body_animation = 0;
$chargen->doridori = 0;
// Custom data:
$chargen->sex = "M";
$chargen->class = 4002;
$chargen->clothes_color = 0;
$chargen->hair = 5;
$chargen->hair_color = 12;
// ... head_top, head_mid, head_bottom, robe, weapon, shield, ...
// Generate Image
$img = $chargen->render();
imagepng($img);