function SetColor($name, $hcolor) { if (isset($this->colors[$name])) { ImageColorDeallocate($this->image, $this->colors[$name]); } $this->colors[$name] = $this->hexcolor($hcolor); }
$name = $prof['name']; $v = $prof['value']; $txt = "{$v} {$name}"; $textLeft += 100; ImageTTFText($img, 8, 0, $textLeft, 90, $textcolor, $plainFont, win2uni($txt)); } } $lineWidth = 495 - $new_width - 45 - 45; $midWidth = $lineWidth; $y = 43; ImageLine($img, $new_width + 45, $y, 445, $y, $textcolor); for ($i = 0; $i < 40; $i++) { $c = ImageColorAllocateAlpha($img, $text_r, $text_g, $text_b, floor(87 / 40 * $i) + 40); ImageLine($img, $new_width + 45 + 1 - $i, $y, $new_width + 45 - $i, $y, $c); ImageLine($img, 445 + $i, $y, 446 + $i, $y, $c); ImageColorDeallocate($img, $c); } ImageTTFText($img, 10, 0, $new_width + 5, 59, $textcolor, $mainFont, win2uni($row['race']) . " " . win2uni($row['clevel']) . " ур. - WWW.RPG.SU"); if ($row['clan_id'] > 0) { $clan_name = mysql_result(myquery("SELECT nazv FROM game_clans WHERE clan_id=" . $row['clan_id'] . ""), 0, 0); ImageTTFText($img, 9, 0, $new_width + 5, 72, $textcolor, $mainFont, "<" . $clan_name . "> " . ""); } else { ImageTTFText($img, 9, 0, $new_width + 5, 72, $textcolor, $mainFont, "Средиземье :: Эпоха Сражений" . ""); } ImageTTFText($img, 8, 0, $new_width + 25, 10, $textcolor, $mainFont, $reason); for ($n = 1; $n <= 6; $n++) { $w = $sta[$n]; $texu = "{$w}"; $bbo = ImageTTFBBox(9, 0, $mainFont, $texu); ImageTTFText($img, 9, 0, ImageSX($img) - $bbo[2] - 110, 3 + $n * 11, $secondaryTextColor, $mainFont, win2uni($texu)); }
public function userbar($name) { if ($f = $this->checkCache(strtolower($name), false)) { $this->getCache($f); return; } $this->init($name, 'default'); // -> $data - массив данных global $config; $this->img = ImageCreateTrueColor($this->b_width, $this->b_height); $black = ImageColorAllocate($this->img, 0, 0, 0); ImageFill($this->img, 0, 0, $black); $text_r = 255; $text_g = 210; $text_b = 0; $s_text_r = 255; $s_text_g = 255; $s_text_b = 255; list($text_r, $text_g, $text_b) = $this->getHexColors($this->text_color[0]); list($s_text_r, $s_text_g, $s_text_b) = $this->getHexColors($this->text_color[1]); $textcolor = ImageColorAllocate($this->img, $text_r, $text_g, $text_b); $secondaryTextColor = ImageColorAllocate($this->img, $s_text_r, $s_text_g, $s_text_b); list($base_r, $base_g, $base_b) = $this->getHexColors($this->color[0]); list($dest_r, $dest_g, $dest_b) = $this->getHexColors($this->getFonBase()); for ($i = 0; $i < ImageSY($this->img); $i++) { $r = min($base_r + ($dest_r - $base_r) / ImageSY($this->img) * $i, 255); $g = min($base_g + ($dest_g - $base_g) / ImageSY($this->img) * $i, 255); $b = min($base_b + ($dest_b - $base_b) / ImageSY($this->img) * $i, 255); $c = ImageColorAllocate($this->img, $r, $g, $b); ImageLine($this->img, 0, $i, ImageSX($this->img), $i, $c); ImageColorDeallocate($this->img, $c); } $gender = $this->data['gender']; $race = $this->data['race']; $class = $this->data['class']; $lvl = $this->data['level']; $ramka = ImageCreateFromGIF(ICON_BORDER_PORTRAIT); $realm = ImageCreateFromGIF(ICON_REALM); $gm = ImageCreateFromGIF(ICON_GM); $r_bar = ImageCreateFromGIF(ICON_RIGHT_BAR); $achieve = ImageCreateFromPNG(ICON_ACHIEVE); $guildmaster = ImageCreateFromGIF(ICON_GUILDMASTER); $active = ImageCreateFromGIF("static/icon-active.gif"); //определяем вид иконки рассы на баре в зависимости от уровня персонажа $portrait = $lvl < 60 ? ImageCreateFromGIF("static/portraits/np/{$gender}-{$race}-{$class}.gif") : $lvl < 70 ? ImageCreateFromGIF("static/portraits/60/{$gender}-{$race}-{$class}.gif") : $lvl < 80 ? ImageCreateFromGIF("static/portraits/70/{$gender}-{$race}-{$class}.gif") : ImageCreateFromGIF("static/portraits/80/{$gender}-{$race}-{$class}.gif"); $imgclass = ImageCreateFromGIF(DIR_ICONS_CLASS . $class . ".gif"); $imgrace = ImageCreateFromGIF(DIR_ICONS_RACE . $race . "-" . $gender . ".gif"); if ($this->data['honor_rank']) { $imgpvp = ImageCreateFromPNG(DIR_ICONS_PVPRANK . "PvPRank" . $this->data['honor_rank'] . ".png"); } $imgfraction = $this->data['fraction'] == 1 ? ImageCreateFromPNG(ICON_FRACTION_HORDE) : ImageCreateFromPNG(ICON_FRACTION_ALLIANCE); $imghonor = $this->data['fraction'] == 1 ? ImageCreateFromPNG(ICON_HONOR_HORDE) : ImageCreateFromPNG(ICON_HONOR_ALLIANCE); $offset = 0; $blacka = ImageColorAllocateAlpha($this->img, 0, 0, 0, 100); ImageFilledRectangle($this->img, 0, 0, ImageSX($this->img) - 1, ImageSY($this->img) - 1, $blacka); ImageCopyResampled($this->img, $portrait, 8, 8, 0, 0, 64, 64, ImageSX($portrait), ImageSY($portrait)); ImageCopyResampled($this->img, $ramka, 0, 0, 0, 0, 83, 83, ImageSX($ramka), ImageSY($ramka)); // $ramka ImageCopyResampled($this->img, $r_bar, 83, 4, 0, 0, 28, 76, ImageSX($r_bar), ImageSY($r_bar)); // $r_bar $this->set_expansion(); if ($this->is_gm) { ImageCopyResampled($this->img, $gm, 57, 60, 0, 0, 20, 13, ImageSX($gm), ImageSY($gm)); } else { $diff_x = $this->data['level'] >= 10 ? 61 : 64; ImageTTFText($this->img, 8, 0, $diff_x, 70, $textcolor, $this->font['wow'], $this->data['level']); } //Класс, раса, ранг ПвП ImageCopyResampled($this->img, $imgrace, 85, 12, 0, 0, 18, 18, ImageSX($imgrace), ImageSY($imgrace)); ImageCopyResampled($this->img, $imgclass, 85, 33, 0, 0, 18, 18, ImageSX($imgclass), ImageSY($imgclass)); ImageCopyResampled($this->img, $active, 85, 33, 0, 0, 18, 18, ImageSX($active), ImageSY($active)); if ($this->data['honor_rank'] > 0) { ImageCopyResampled($this->img, $imgpvp, 85, 54, 0, 0, 18, 18, ImageSX($imgpvp), ImageSY($imgpvp)); } else { ImageCopyResampled($this->img, $imgfraction, 84, 54, 0, 1, 19, 19, ImageSX($imgfraction), ImageSY($imgfraction)); } // цвет линии опыта основан на цвете градиента юзербара $xplinecolor = ImageColorAllocate($this->img, $dest_r, $dest_g, $dest_b); $lineWidth = 220; $y0 = 38; $x0 = 111; ImageLine($this->img, $x0, $y0, $x0 + $lineWidth, $y0, $textcolor); if ($lvl < $this->data['maxlvl']) { ImageLine($this->img, $x0, $y0, $x0 + $lineWidth * $this->data['xp'] / $this->data['xp_next'], $y0, $xplinecolor); } $this->fontSize = strlen($this->pl->name) >= 10 ? 18 : 21; $this->font_name = $this->is_cyrillic($this->pl->name) ? $this->font['friztrus'] : $this->font['wow']; if ($this->pl->inGuild()) { ImageTTFText($this->img, 9, 0, 114, 52, $textcolor, $this->font['friztrus'], $this->pl->guildNmae); if ($this->pl->isGuildLeader()) { ImageCopyResampled($this->img, $guildmaster, 115, 16, 0, 0, 18, 18, ImageSX($guildmaster), ImageSY($guildmaster)); ImageTTFText($this->img, $this->fontSize, 0, 136, 35, $textcolor, $this->font_name, $this->pl->name); } else { ImageTTFText($this->img, $this->fontSize, 0, 116, 35, $textcolor, $this->font_name, $this->pl->name); } } else { ImageTTFText($this->img, $this->fontSize, 0, 116, 35, $textcolor, $this->font_name, $this->pl->name); } $this->pl->acctid = $this->pl->getAccountId(); $realm_name = $this->pl->getRealmName($config['realmid'], false); ImageCopyResampled($this->img, $realm, 115, 64, 0, 0, 16, 16, ImageSX($realm), ImageSY($realm)); ImageTTFText($this->img, 9, 0, 133, 77, $textcolor, $this->font['friztrus'], $realm_name); $honor = $this->data['totalHonorPoints']; if ($honor > 0) { // show honor ImageCopyResampled($this->img, $imghonor, 265, -3, 0, 0, 26, 26, ImageSX($imghonor), ImageSY($imghonor)); ImageTTFText($this->img, 8, 0, 287, 13, $textcolor, $this->font['wow'], $honor); } if ($this->data['achievement'] > 0) { // show achievement ImageCopyResampled($this->img, $achieve, 266, 16, 0, 0, 23, 23, ImageSX($achieve), ImageSY($achieve)); ImageTTFText($this->img, 8, 0, 289, 32, $textcolor, $this->font['wow'], $this->data['achievement']); } if (!is_null($this->data['profs'])) { $count = count($this->data['profs']); if ($count > 2) { $count = 2; } $textLeft = 270; for ($i = 0; $i < $count; $i++) { $value = $this->data['profs'][$i]['value']; $skill = $this->data['profs'][$i]['skill']; $imgproff = ImageCreateFromGIF(DIR_ICONS_PROFESSION . $skill . '.gif'); $diff = $value < 10 ? 9 : ($value > 10 && $value < 20 ? 7 : ($value > 20 && $value < 100 ? 4 : 3)); ImageCopyResampled($this->img, $imgproff, $textLeft + 28 * $i, 41, 0, 0, 27, 27, ImageSX($imgproff), ImageSY($imgproff)); ImageTTFText($this->img, 8, 0, $textLeft + 30 * $i + $diff, 75, $textcolor, $this->font['wow'], $value); } } $this->output(strtolower($this->pl->name), false); }
*/ #drawing $im = @ImageCreateTrueColor($width, $height); $im_clr_background = @ImageColorAllocate($im, (int) ($color_background % 0x1000000 / 0x10000), (int) ($color_background % 0x10000 / 0x100), $color_background % 0x100); $im_clr_digits = @ImageColorAllocate($im, (int) ($color_digits % 0x1000000 / 0x10000), (int) ($color_digits % 0x10000 / 0x100), $color_digits % 0x100); $im_clr_question = @ImageColorAllocate($im, (int) ($color_question % 0x1000000 / 0x10000), (int) ($color_question % 0x10000 / 0x100), $color_question % 0x100); ImageFill($im, 0, 0, $im_clr_background); #draw digits [5 + 3 =] for ($i = 0, $count = mb_strlen($text); $i < $count; $i++) { $angle = $angle_max ? rand(360 - $angle_max, 360 + $angle_max) : 0; if ($text[$i] != ' ') { imagettftext($im, $font_size, $angle, $position_x, $position_y, $im_clr_digits, $font, $text[$i]); } $position_x += $text[$i] != ' ' ? $font_size + 1 : $font_size_spaces; } #draw question sign [?] imagettftext($im, $font_size, 0, $position_x, $position_y, $color_question, $font, '?'); #deallocate colors ImageColorDeallocate($im, $im_clr_background); ImageColorDeallocate($im, $im_clr_digits); ImageColorDeallocate($im, $im_clr_question); #show image header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0"); header("Expires: " . date("r")); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT"); header("Pragma: no-cache"); header('Content-Transfer-Encoding: binary'); header('Content-type: ' . image_type_to_mime_type(IMAGETYPE_PNG)); ImagePNG($im); ImageDestroy($im); exit(0);