Ejemplo n.º 1
0
function create_common_image($title, $width, $height, $data, $chart_type = 'line')
{
    global $pchart_path;
    /* Create the pChart object */
    $myPicture = new pImage($width, $height, $data);
    /* Draw the background */
    $Settings = array("R" => 255, "G" => 255, "B" => 255, "Dash" => 1, "DashR" => 185, "DashG" => 225, "DashB" => 255);
    $myPicture->drawFilledRectangle(0, 0, $width, $height, $Settings);
    /* Overlay with a gradient */
    $Settings = array("StartR" => 206, "StartG" => 235, "StartB" => 235, "EndR" => 71, "EndG" => 150, "EndB" => 205, "Alpha" => 50);
    $myPicture->drawGradientArea(0, 0, $width, $height, DIRECTION_VERTICAL, $Settings);
    $myPicture->drawGradientArea(0, 0, $width, 20, DIRECTION_VERTICAL, array("StartR" => 0, "StartG" => 0, "StartB" => 0, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 80));
    /* Add a border to the picture */
    $myPicture->drawRectangle(0, 0, $width - 1, $height - 1, array("R" => 0, "G" => 0, "B" => 0));
    /* Write the picture title */
    $myPicture->setFontProperties(array("FontName" => $pchart_path . "/fonts/arialbd.ttf", "FontSize" => 9));
    $myPicture->drawText(24, 12, win2uni($title), array("R" => 255, "G" => 255, "B" => 255, "Align" => TEXT_ALIGN_MIDDLELEFT));
    $myPicture->drawFromPNG(4, 4, "includes/design/images/chart_pie.png");
    if ($chart_type == 'line') {
        $myPicture->setFontProperties(array("FontName" => $pchart_path . "/fonts/arial.ttf", "FontSize" => 8));
        /* Draw the scale and the 1st chart */
        $myPicture->setGraphArea(60, 64, 450 + 200, 190);
        $myPicture->drawFilledRectangle(60, 50, 450 + 200, 190, array("R" => 255, "G" => 255, "B" => 255, "Surrounding" => -255, "Alpha" => 60));
        $myPicture->drawScale(array("Mode" => SCALE_MODE_START0, "DrawSubTicks" => FALSE, "GridR" => 151, "GridG" => 197, "GridB" => 254, "GridAlpha" => 30));
        $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
    }
    $myPicture->setFontProperties(array("FontName" => $pchart_path . "/fonts/pf_arma_five.ttf", "FontSize" => 6));
    return $myPicture;
}
function drawCaption($string, $size, $angle)
{
    $font = "font/tahomab.ttf";
    $bbox = imagettfbbox($size, $angle, $font, win2uni($string));
    // определяем размер бокса под фамилию
    $width = $bbox[2] - $bbox[0] + 5;
    // ширина бокса
    $height = $bbox[1] - $bbox[7] + 5;
    // высота бокса
    $box = imagecreatetruecolor($width, $height);
    // создаем контейнер под всё
    $black = imagecolorallocate($box, 0, 0, 0);
    $transparent = imagecolorallocatealpha($box, 0, 0, 0, 127);
    // устанавливаем прозрачный цвет
    imagefill($box, 0, 0, $transparent);
    // заполняем прозрачностью
    imageSaveAlpha($box, true);
    // созраняем
    imageAlphaBlending($box, false);
    // копировать сюда будем вместе с настройками
    imagettftext($box, $size, $angle, 0, $height, $black, $font, $string);
    // накладываем имя-фамилию
    return $box;
}
Ejemplo n.º 3
0
 public function ttftext($text, $color, $font, $size, $x, $y, $angle = 0)
 {
     if (!is_file($font) or !is_readable($font)) {
         user_error('Can\'t open font ' . $font, E_USER_WARNING);
         return;
     }
     return imagettftext($this->res, $size * $this->scale, $angle, $this->offsetX + $x * $this->scale, $this->offsetY + $y * $this->scale, $this->hex2color($color), $font, win2uni($text));
 }
Ejemplo n.º 4
0
        $nam = $staName[$n];
        $texu2 = "{$nam}";
        $bbo2 = ImageTTFBBox(9, 0, $mainFont, $texu2);
        ImageTTFText($img, 9, 0, ImageSX($img) - $bbo2[2] - 144, 3 + $n * 11, $secondaryTextColor, $mainFont, win2uni($texu2));
    }
    for ($i = 1; $i <= 6; $i++) {
        $v = $stat[$i];
        $text = "{$v}";
        $bbox = ImageTTFBBox(9, 0, $mainFont, $text);
        ImageTTFText($img, 9, 0, ImageSX($img) - $bbox[2] - 68, 3 + $i * 11, $secondaryTextColor, $mainFont, win2uni($text));
    }
    for ($i = 1; $i <= 6; $i++) {
        $name = $statName[$i];
        $text2 = "{$name}";
        $bbox2 = ImageTTFBBox(9, 0, $mainFont, $text2);
        ImageTTFText($img, 9, 0, ImageSX($img) - 60, 3 + $i * 11, $secondaryTextColor, $mainFont, win2uni($text2));
    }
    $filename = $char_name;
    $ext = "png";
    header("Content-disposition: inline; filename={$filename}.{$ext}");
    header("content-type: image/{$ext}");
    header("cache-control: max-age=86400");
    ImagePNG($img);
} else {
    ?>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<FORM ACTION="index.php" METHOD="GET">
<INPUT name="name" TYPE="text" VALUE="Введите Ваш ник...">
<INPUT TYPE="submit" VALUE="Получить код*">
</FORM>
* - код скопируете из адресной строки браузера! Для получения подписи на форуме необходимо вставить полученную ссылку между [IMG] и [/IMG]
    ImageRectangle($img, $offset_2, 5 * $offset_2 + 2, ImageSX($img) - 18 * $offset_2, ImageSY($img) - $offset_2, $bg_colorAlpha);
    // контур внутреннего блока
    ImageFilledRectangle($img, 33 * $offset_1, $offset_1, ImageSX($img) - $offset_1, ImageSY($img) - $offset_1, $bg_alfa);
    // положение внутренненго блока
    ImageRectangle($img, 33 * $offset_1, $offset_1, ImageSX($img) - $offset_1, ImageSY($img) - $offset_1, $bg_colorAlpha);
    // контур внутреннего блока
    ImageRectangle($img, 0, 0, ImageSX($img), ImageSY($img), $bg_color);
    // окантовка всей картинки
    /////////////////////////////////////
    $text_color_1 = $text_color['in_block'];
    // цвет всех надписей в блоках - пойже будет разбит на несколько цветов
    // отвечает за цвет текста
    list($text_r, $text_g, $text_b) = getHexColors($text_color_1);
    list($s_text_r, $s_text_g, $s_text_b) = getHexColors($text_color_2);
    $textcolor = ImageColorAllocate($img, $text_r, $text_g, $text_b);
    $secondaryTextColor = ImageColorAllocate($img, $s_text_r, $s_text_g, $s_text_b);
    /* пихаем текст */
    ImageTTFText($img, 12, 0, 9, 22, $secondaryTextColor, $mainFont, $server['name']);
    ImageTTFText($img, 8, 0, 9, 40, $textcolor, $mainFont, win2uni("Альянс: " . $count[1] . " (" . $online[1] . " онлайн)"));
    ImageTTFText($img, 8, 0, 9, 54, $textcolor, $mainFont, win2uni("Орда: " . $count[2] . " (" . $online[2] . " онлайн)"));
    ImageTTFText($img, 8, 0, 9, 68, $textcolor, $mainFont, win2uni("Всего: " . $count[0] . " (" . $online[0] . " онлайн)"));
    ImageTTFText($img, 8, 0, 190, 18, $textcolor, $mainFont, win2uni("Рейты"));
    ImageTTFText($img, 8, 0, 170, 30, $textcolor, $mainFont, win2uni("Квесты: " . $rates['quest']));
    ImageTTFText($img, 8, 0, 170, 42, $textcolor, $mainFont, win2uni("Хонор: " . $rates['honor']));
    ImageTTFText($img, 8, 0, 170, 54, $textcolor, $mainFont, win2uni("Мобы: " . $rates['npc']));
    ImageTTFText($img, 8, 0, 170, 66, $textcolor, $mainFont, win2uni("Дроп: " . $rates['drop']));
    header("Content-disposition: inline; filename=\"status.png\"");
    header("content-type: image/png");
    header("cache-control: max-age=86400");
    ImagePNG($img);
}