• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP imageTextSize函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中imageTextSize函数的典型用法代码示例。如果您正苦于以下问题:PHP imageTextSize函数的具体用法?PHP imageTextSize怎么用?PHP imageTextSize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了imageTextSize函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: paintGrid

 protected function paintGrid()
 {
     $size = $this->options['grid']['size'];
     if (empty($size)) {
         return;
     }
     $width = $this->canvas->getWidth();
     $height = $this->canvas->getHeight();
     $maxSize = max($width, $height);
     $dims = imageTextSize(8, 0, '00');
     for ($xy = $size; $xy < $maxSize; $xy += $size) {
         if ($xy < $width) {
             $this->canvas->drawLine($xy, 0, $xy, $height, $this->options['grid']['color'], MAP_LINK_DRAWTYPE_DASHED_LINE);
             $this->canvas->drawText(8, 0, $xy + 3, $dims['height'] + 3, $this->options['grid']['color'], $xy);
         }
         if ($xy < $height) {
             $this->canvas->drawLine(0, $xy, $width, $xy, $this->options['grid']['color'], MAP_LINK_DRAWTYPE_DASHED_LINE);
             $this->canvas->drawText(8, 0, 3, $xy + $dims['height'] + 3, $this->options['grid']['color'], $xy);
         }
     }
     $this->canvas->drawText(8, 0, 2, $dims['height'] + 3, 'black', 'Y X:');
 }
开发者ID:itnihao,项目名称:Zabbix_,代码行数:22,代码来源:CMapPainter.php


示例2: drawHeader

 public function drawHeader()
 {
     if (!isset($this->header)) {
         $str = $this->items[0]['hostname'] . ': ' . $this->items[0]['name'];
     } else {
         $str = $this->header;
     }
     $str .= $this->period2str($this->period);
     // calculate largest font size that can fit graph header
     // TODO: font size must be dynamic in other parts of the graph as well, like legend, timeline, etc
     for ($fontsize = 11; $fontsize > 7; $fontsize--) {
         $dims = imageTextSize($fontsize, 0, $str);
         $x = $this->fullSizeX / 2 - $dims['width'] / 2;
         // most important information must be displayed, period can be out of the graph
         if ($x < 2) {
             $x = 2;
         }
         if ($dims['width'] <= $this->fullSizeX) {
             break;
         }
     }
     imageText($this->im, $fontsize, 0, $x, 24, $this->getColor($this->graphtheme['textcolor'], 0), $str);
 }
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:23,代码来源:class.cgraphdraw.php


示例3: imageText

function imageText($image, $fontsize, $angle, $x, $y, $color, $string)
{
    $gdinfo = gd_info();
    if ($gdinfo['FreeType Support'] && function_exists('imagettftext')) {
        if (preg_match(ZBX_PREG_DEF_FONT_STRING, $string) && $angle != 0 || ZBX_FONT_NAME == ZBX_GRAPH_FONT_NAME) {
            $ttf = ZBX_FONTPATH . '/' . ZBX_FONT_NAME . '.ttf';
            imagettftext($image, $fontsize, $angle, $x, $y, $color, $ttf, $string);
        } elseif ($angle == 0) {
            $ttf = ZBX_FONTPATH . '/' . ZBX_GRAPH_FONT_NAME . '.ttf';
            imagettftext($image, $fontsize, $angle, $x, $y, $color, $ttf, $string);
        } else {
            $ttf = ZBX_FONTPATH . '/' . ZBX_GRAPH_FONT_NAME . '.ttf';
            $size = imageTextSize($fontsize, 0, $string);
            $imgg = imagecreatetruecolor($size['width'] + 1, $size['height']);
            $transparentColor = imagecolorallocatealpha($imgg, 200, 200, 200, 127);
            imagefill($imgg, 0, 0, $transparentColor);
            imagettftext($imgg, $fontsize, 0, 0, $size['height'], $color, $ttf, $string);
            $imgg = imagerotate($imgg, $angle, $transparentColor);
            ImageAlphaBlending($imgg, false);
            imageSaveAlpha($imgg, true);
            imagecopy($image, $imgg, $x - $size['height'], $y - $size['width'], 0, 0, $size['height'], $size['width'] + 1);
            imagedestroy($imgg);
        }
    } else {
        $dims = imageTextSize($fontsize, $angle, $string);
        switch ($fontsize) {
            case 5:
                $fontsize = 1;
                break;
            case 6:
                $fontsize = 1;
                break;
            case 7:
                $fontsize = 2;
                break;
            case 8:
                $fontsize = 2;
                break;
            case 9:
                $fontsize = 3;
                break;
            case 10:
                $fontsize = 3;
                break;
            case 11:
                $fontsize = 4;
                break;
            case 12:
                $fontsize = 4;
                break;
            case 13:
                $fontsize = 5;
                break;
            case 14:
                $fontsize = 5;
                break;
            default:
                $fontsize = 2;
                break;
        }
        if ($angle) {
            $x -= $dims['width'];
            $y -= 2;
        } else {
            $y -= $dims['height'] - 2;
        }
        if ($angle > 0) {
            return imagestringup($image, $fontsize, $x, $y, $string, $color);
        }
        return imagestring($image, $fontsize, $x, $y, $string, $color);
    }
    return true;
}
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:73,代码来源:graphs.inc.php


示例4: draw

 public function draw()
 {
     $start_time = microtime(true);
     set_image_header();
     $this->column = uint_in_array($this->type, array(GRAPH_TYPE_COLUMN, GRAPH_TYPE_COLUMN_STACKED));
     $this->fullSizeX = $this->sizeX;
     $this->fullSizeY = $this->sizeY;
     if ($this->sizeX < 300 || $this->sizeY < 200) {
         $this->showLegend(0);
     }
     $this->calcShifts();
     $this->sizeX -= $this->shiftXleft + $this->shiftXright + $this->shiftlegendright + $this->shiftXCaptionLeft + $this->shiftXCaptionRight;
     $this->sizeY -= $this->shiftY + $this->shiftYLegend + $this->shiftYCaptionBottom + $this->shiftYCaptionTop;
     $this->calcSeriesWidth();
     $this->calcMiniMax();
     $this->correctMiniMax();
     if (function_exists('imagecolorexactalpha') && function_exists('imagecreatetruecolor') && @imagecreatetruecolor(1, 1)) {
         $this->im = imagecreatetruecolor($this->fullSizeX, $this->fullSizeY);
     } else {
         $this->im = imagecreate($this->fullSizeX, $this->fullSizeY);
     }
     $this->initColors();
     $this->drawRectangle();
     $this->drawHeader();
     $this->drawGrid();
     $this->drawSideValues();
     $this->drawLogo();
     $this->drawLegend();
     $count = 0;
     if ($this->column) {
         $start = $this->shiftXleft + $this->shiftXCaptionLeft + floor($this->seriesDistance / 2);
     } else {
         $start = $this->sizeY + $this->shiftY + $this->shiftYCaptionTop - floor($this->seriesDistance / 2);
     }
     foreach ($this->series as $key => $series) {
         foreach ($series as $num => $serie) {
             $axis = $serie['axis'];
             $value = $serie['value'];
             $color = $this->getColor($this->seriesColor[$num], $this->opacity);
             if ($this->column) {
                 imagefilledrectangle($this->im, $start, $this->sizeY + $this->shiftY + $this->shiftYCaptionTop - round($this->sizeY / $this->maxValue[$axis] * $value), $start + $this->columnWidth, $this->sizeY + $this->shiftY + $this->shiftYCaptionTop, $color);
                 imagerectangle($this->im, $start, $this->sizeY + $this->shiftY + $this->shiftYCaptionTop - round($this->sizeY / $this->maxValue[$axis] * $value), $start + $this->columnWidth, $this->sizeY + $this->shiftY + $this->shiftYCaptionTop, $this->getColor('Black No Alpha'));
             } else {
                 imagefilledrectangle($this->im, $this->shiftXleft + $this->shiftXCaptionLeft, $start - $this->columnWidth, $this->shiftXleft + $this->shiftXCaptionLeft + round($this->sizeX / $this->maxValue[$axis] * $value), $start, $color);
                 imagerectangle($this->im, $this->shiftXleft + $this->shiftXCaptionLeft, $start - $this->columnWidth, $this->shiftXleft + $this->shiftXCaptionLeft + round($this->sizeX / $this->maxValue[$axis] * $value), $start, $this->getColor('Black No Alpha'));
             }
             $start = $this->column ? $start + $this->columnWidth : $start - $this->columnWidth;
         }
         $count++;
         if ($this->column) {
             $start = $count * ($this->seriesWidth + $this->seriesDistance) + $this->shiftXleft + $this->shiftXCaptionLeft + floor($this->seriesDistance / 2);
         } else {
             $start = $this->sizeY + $this->shiftY + $this->shiftYCaptionTop - $count * ($this->seriesWidth + $this->seriesDistance) - floor($this->seriesDistance / 2);
         }
     }
     $str = sprintf('%0.2f', microtime(true) - $start_time);
     $str = _s('Generated in %s sec', $str);
     $strSize = imageTextSize(6, 0, $str);
     imageText($this->im, 6, 0, $this->fullSizeX - $strSize['width'] - 5, $this->fullSizeY - 5, $this->getColor('Gray'), $str);
     unset($this->items, $this->data);
     imageOut($this->im);
 }
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:62,代码来源:CBarGraphDraw.php


示例5: drawMapLabels

function drawMapLabels(&$im, $map, $mapInfo, $resolveMacros = true)
{
    global $colors;
    if ($map['label_type'] == MAP_LABEL_TYPE_NOTHING && $map['label_format'] == SYSMAP_LABEL_ADVANCED_OFF) {
        return;
    }
    $selements = $map['selements'];
    $allStrings = '';
    $labelLines = array();
    $statusLines = array();
    foreach ($selements as $sid => $selement) {
        if (isset($selement['elementsubtype']) && $selement['elementsubtype'] == SYSMAP_ELEMENT_SUBTYPE_HOST_GROUP_ELEMENTS) {
            unset($selements[$sid]);
        }
    }
    // set label type and custom label text for all selements
    foreach ($selements as $selementId => $selement) {
        $selements[$selementId]['label_type'] = $map['label_type'];
        if ($map['label_format'] == SYSMAP_LABEL_ADVANCED_OFF) {
            continue;
        }
        switch ($selement['elementtype']) {
            case SYSMAP_ELEMENT_TYPE_HOST_GROUP:
                $selements[$selementId]['label_type'] = $map['label_type_hostgroup'];
                if ($map['label_type_hostgroup'] == MAP_LABEL_TYPE_CUSTOM) {
                    $selements[$selementId]['label'] = $map['label_string_hostgroup'];
                }
                break;
            case SYSMAP_ELEMENT_TYPE_HOST:
                $selements[$selementId]['label_type'] = $map['label_type_host'];
                if ($map['label_type_host'] == MAP_LABEL_TYPE_CUSTOM) {
                    $selements[$selementId]['label'] = $map['label_string_host'];
                }
                break;
            case SYSMAP_ELEMENT_TYPE_TRIGGER:
                $selements[$selementId]['label_type'] = $map['label_type_trigger'];
                if ($map['label_type_trigger'] == MAP_LABEL_TYPE_CUSTOM) {
                    $selements[$selementId]['label'] = $map['label_string_trigger'];
                }
                break;
            case SYSMAP_ELEMENT_TYPE_MAP:
                $selements[$selementId]['label_type'] = $map['label_type_map'];
                if ($map['label_type_map'] == MAP_LABEL_TYPE_CUSTOM) {
                    $selements[$selementId]['label'] = $map['label_string_map'];
                }
                break;
            case SYSMAP_ELEMENT_TYPE_IMAGE:
                $selements[$selementId]['label_type'] = $map['label_type_image'];
                if ($map['label_type_image'] == MAP_LABEL_TYPE_CUSTOM) {
                    $selements[$selementId]['label'] = $map['label_string_image'];
                }
                break;
        }
    }
    foreach ($selements as $selementId => $selement) {
        if (!isset($labelLines[$selementId])) {
            $labelLines[$selementId] = array();
        }
        if (!isset($statusLines[$selementId])) {
            $statusLines[$selementId] = array();
        }
        $msg = $resolveMacros ? CMacrosResolverHelper::resolveMapLabelMacrosAll($selement) : $selement['label'];
        $allStrings .= $msg;
        $msgs = explode("\n", $msg);
        foreach ($msgs as $msg) {
            $labelLines[$selementId][] = array('msg' => $msg);
        }
        $elementInfo = $mapInfo[$selementId];
        foreach (array('problem', 'unack', 'maintenance', 'ok', 'status') as $caption) {
            if (!isset($elementInfo['info'][$caption]) || zbx_empty($elementInfo['info'][$caption]['msg'])) {
                continue;
            }
            $statusLines[$selementId][] = array('msg' => $elementInfo['info'][$caption]['msg'], 'color' => $elementInfo['info'][$caption]['color']);
            $allStrings .= $elementInfo['info'][$caption]['msg'];
        }
    }
    $allLabelsSize = imageTextSize(8, 0, str_replace("\r", '', str_replace("\n", '', $allStrings)));
    $labelFontHeight = $allLabelsSize['height'];
    $labelFontBaseline = $allLabelsSize['baseline'];
    $elementsHostIds = array();
    foreach ($selements as $selement) {
        if ($selement['label_type'] != MAP_LABEL_TYPE_IP) {
            continue;
        }
        if ($selement['elementtype'] == SYSMAP_ELEMENT_TYPE_HOST) {
            $elementsHostIds[] = $selement['elementid'];
        }
    }
    if (!empty($elementsHostIds)) {
        $mapHosts = API::Host()->get(array('hostids' => $elementsHostIds, 'output' => array('hostid'), 'selectInterfaces' => API_OUTPUT_EXTEND));
        $mapHosts = zbx_toHash($mapHosts, 'hostid');
    }
    // draw
    foreach ($selements as $selementId => $selement) {
        if (empty($selement) || $selement['label_type'] == MAP_LABEL_TYPE_NOTHING) {
            continue;
        }
        $elementInfo = $mapInfo[$selementId];
        $hl_color = null;
        $st_color = null;
//.........这里部分代码省略.........
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:101,代码来源:maps.inc.php


示例6: drawHeader

 public function drawHeader()
 {
     if (!isset($this->header)) {
         $str = $this->items[0]['host'] . ': ' . $this->items[0]['description'];
     } else {
         $str = $this->header;
     }
     $str .= $this->period2str($this->period);
     $fontnum = 11;
     if ($this->sizeX < 500 && ($this->type == GRAPH_TYPE_NORMAL || $this->type == GRAPH_TYPE_BAR)) {
         $fontnum = 8;
     }
     $dims = imageTextSize($fontnum, 0, $str);
     $x = $this->fullSizeX / 2 - $dims['width'] / 2;
     imagetext($this->im, $fontnum, 0, $x, 24, $this->getColor($this->graphtheme['textcolor'], 0), $str);
 }
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:16,代码来源:class.cgraphdraw.php


示例7: imageText

/**
 * Draws a text on an image. Supports TrueType fonts.
 *
 * @param resource 	$image
 * @param int		$fontsize
 * @param int 		$angle
 * @param int		$x
 * @param int 		$y
 * @param int		$color		a numeric color identifier from imagecolorallocate() or imagecolorallocatealpha()
 * @param string	$string
 */
function imageText($image, $fontsize, $angle, $x, $y, $color, $string)
{
    if (preg_match(ZBX_PREG_DEF_FONT_STRING, $string) && $angle != 0 || ZBX_FONT_NAME == ZBX_GRAPH_FONT_NAME) {
        $ttf = ZBX_FONTPATH . '/' . ZBX_FONT_NAME . '.ttf';
        imagettftext($image, $fontsize, $angle, $x, $y, $color, $ttf, $string);
    } elseif ($angle == 0) {
        $ttf = ZBX_FONTPATH . '/' . ZBX_GRAPH_FONT_NAME . '.ttf';
        imagettftext($image, $fontsize, $angle, $x, $y, $color, $ttf, $string);
    } else {
        $ttf = ZBX_FONTPATH . '/' . ZBX_GRAPH_FONT_NAME . '.ttf';
        $size = imageTextSize($fontsize, 0, $string);
        $imgg = imagecreatetruecolor($size['width'] + 1, $size['height']);
        $transparentColor = imagecolorallocatealpha($imgg, 200, 200, 200, 127);
        imagefill($imgg, 0, 0, $transparentColor);
        imagettftext($imgg, $fontsize, 0, 0, $size['height'], $color, $ttf, $string);
        $imgg = imagerotate($imgg, $angle, $transparentColor);
        imagealphablending($imgg, false);
        imagesavealpha($imgg, true);
        imagecopy($image, $imgg, $x - $size['height'], $y - $size['width'], 0, 0, $size['height'], $size['width'] + 1);
        imagedestroy($imgg);
    }
}
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:33,代码来源:graphs.inc.php


示例8: imagefilledrectangle

    $yt = $sizeY * $true[$i - 1] / 100;
    if ($yt > 0) {
        imagefilledrectangle($im, $x1 + $shiftX, $shiftYup, $x1 + $shiftX + 8, $yt + $shiftYup, imagecolorallocate($im, 235, 120, 120));
        // red
    }
    $yf = $sizeY * $false[$i - 1] / 100;
    if ($yf > 0) {
        imagefilledrectangle($im, $x1 + $shiftX, $yt + $shiftYup, $x1 + $shiftX + 8, $sizeY + $shiftYup, imagecolorallocate($im, 120, 235, 120));
        // green
    }
    if ($yt + $yf > 0) {
        imagerectangle($im, $x1 + $shiftX, $shiftYup, $x1 + $shiftX + 8, $sizeY + $shiftYup, $black);
    }
}
for ($i = 0; $i <= $sizeY; $i += $sizeY / 10) {
    imageText($im, 7, 0, $sizeX + 5 + $shiftX, $sizeY - $i - 4 + $shiftYup + 8, $darkred, $i * ($maxY - $minY) / $sizeY + $minY);
}
imagefilledrectangle($im, $shiftX, $sizeY + $shiftYup + 39, $shiftX + 5, $sizeY + $shiftYup + 44, imagecolorallocate($im, 120, 235, 120));
imagerectangle($im, $shiftX, $sizeY + $shiftYup + 39, $shiftX + 5, $sizeY + $shiftYup + 44, $black);
imageText($im, 8, 0, $shiftX + 9, $sizeY + $shiftYup + 45, $black, _('OK') . ' (%)');
imagefilledrectangle($im, $shiftX, $sizeY + $shiftYup + 54, $shiftX + 5, $sizeY + $shiftYup + 59, imagecolorallocate($im, 235, 120, 120));
imagerectangle($im, $shiftX, $sizeY + $shiftYup + 54, $shiftX + 5, $sizeY + $shiftYup + 59, $black);
imageText($im, 8, 0, $shiftX + 9, $sizeY + $shiftYup + 60, $black, _('Problems') . ' (%)');
imagestringup($im, 1, imagesx($im) - 10, imagesy($im) - 50, ZABBIX_HOMEPAGE, $gray);
$str = sprintf('%0.2f', microtime(true) - $startTime);
$str = _s('Generated in %s sec', $str);
$strSize = imageTextSize(6, 0, $str);
imageText($im, 6, 0, imagesx($im) - $strSize['width'] - 5, imagesy($im) - 5, $gray, $str);
imageOut($im);
imagedestroy($im);
require_once dirname(__FILE__) . '/include/page_footer.php';
开发者ID:unix1986,项目名称:zabbix,代码行数:31,代码来源:chart4.php


示例9: drawMapLabels

function drawMapLabels(&$im, &$map, &$map_info)
{
    global $colors;
    if ($map['label_type'] == MAP_LABEL_TYPE_NOTHING) {
        return;
    }
    $selements = $map['selements'];
    $all_strings = '';
    $label_lines = array();
    $status_lines = array();
    foreach ($selements as $selementid => $selement) {
        if (!isset($label_lines[$selementid])) {
            $label_lines[$selementid] = array();
        }
        if (!isset($status_lines[$selementid])) {
            $status_lines[$selementid] = array();
        }
        $msg = resolveMapLabelMacrosAll($selement);
        $all_strings .= $msg;
        $msgs = explode("\n", $msg);
        foreach ($msgs as $msg) {
            $label_lines[$selementid][] = array('msg' => $msg);
        }
        $el_info = $map_info[$selementid];
        $el_msgs = array('problem', 'unack', 'maintenance', 'unknown', 'ok', 'status');
        foreach ($el_msgs as $key => $caption) {
            if (!isset($el_info['info'][$caption]) || zbx_empty($el_info['info'][$caption]['msg'])) {
                continue;
            }
            $status_lines[$selementid][] = array('msg' => $el_info['info'][$caption]['msg'], 'color' => $el_info['info'][$caption]['color']);
            $all_strings .= $el_info['info'][$caption]['msg'];
        }
    }
    $allLabelsSize = imageTextSize(8, 0, str_replace("\r", '', str_replace("\n", '', $all_strings)));
    $labelFontHeight = $allLabelsSize['height'];
    $labelFontBaseline = $allLabelsSize['baseline'];
    foreach ($selements as $selementid => $selement) {
        if (empty($selement)) {
            continue;
        }
        $el_info = $map_info[$selementid];
        $hl_color = null;
        $st_color = null;
        if (!isset($_REQUEST['noselements']) && $map['highlight'] % 2 == SYSMAP_HIGHLIGH_ON) {
            if ($el_info['icon_type'] == SYSMAP_ELEMENT_ICON_ON) {
                $hl_color = true;
            }
            if ($el_info['icon_type'] == SYSMAP_ELEMENT_ICON_UNKNOWN) {
                $hl_color = true;
            }
            if ($el_info['icon_type'] == SYSMAP_ELEMENT_ICON_MAINTENANCE) {
                $st_color = true;
            }
            if ($el_info['icon_type'] == SYSMAP_ELEMENT_ICON_DISABLED) {
                $st_color = true;
            }
        }
        if (in_array($selement['elementtype'], array(SYSMAP_ELEMENT_TYPE_HOST_GROUP, SYSMAP_ELEMENT_TYPE_MAP)) && !is_null($hl_color)) {
            $st_color = null;
        } else {
            if (!is_null($st_color)) {
                $hl_color = null;
            }
        }
        $label_location = is_null($selement['label_location']) || $selement['label_location'] < 0 ? $map['label_location'] : $selement['label_location'];
        $label = array();
        if ($selement['elementtype'] == SYSMAP_ELEMENT_TYPE_HOST && $map['label_type'] == MAP_LABEL_TYPE_IP) {
            $host = get_host_by_hostid($selement['elementid']);
            $label[] = array('msg' => $host['ip']);
            $label = array_merge($label, $status_lines[$selementid]);
        } else {
            if ($map['label_type'] == MAP_LABEL_TYPE_STATUS) {
                $label = $status_lines[$selementid];
            } else {
                if ($map['label_type'] == MAP_LABEL_TYPE_NAME) {
                    $label[] = array('msg' => $el_info['name']);
                } else {
                    $label = array_merge($label_lines[$selementid], $status_lines[$selementid]);
                }
            }
        }
        if (zbx_empty($label)) {
            continue;
        }
        $w = 0;
        foreach ($label as $str) {
            $dims = imageTextSize(8, 0, $str['msg']);
            $w = max($w, $dims['width']);
        }
        $h = count($label) * $labelFontHeight;
        $x = $selement['x'];
        $y = $selement['y'];
        $img = get_png_by_selement($selement, $el_info);
        $iconX = imagesx($img);
        $iconY = imagesy($img);
        if (!is_null($hl_color)) {
            $icon_hl = 14;
        } else {
            if (!is_null($st_color)) {
                $icon_hl = 6;
//.........这里部分代码省略.........
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:101,代码来源:maps.inc.php


示例10: drawLegend

 protected function drawLegend()
 {
     $shiftY = $this->shiftY + $this->shiftYLegend;
     $max_host_len = 0;
     $max_desc_len = 0;
     for ($i = 0; $i < $this->num; $i++) {
         if (zbx_strlen($this->items[$i]['host']) > $max_host_len) {
             $max_host_len = zbx_strlen($this->items[$i]['host']);
         }
         if (zbx_strlen($this->items[$i]['description']) > $max_desc_len) {
             $max_desc_len = zbx_strlen($this->items[$i]['description']);
         }
     }
     for ($i = 0; $i < $this->num; $i++) {
         $color = $this->getColor($this->items[$i]['color'], 0);
         $data =& $this->data[$this->items[$i]['itemid']][$this->items[$i]['calc_type']];
         switch ($this->items[$i]['calc_fnc']) {
             case CALC_FNC_MIN:
                 $fnc_name = 'min';
                 $datavalue = $data->min;
                 break;
             case CALC_FNC_MAX:
                 $fnc_name = 'max';
                 $datavalue = $data->max;
                 break;
             case CALC_FNC_LST:
                 $fnc_name = 'last';
                 $datavalue = $data->lst;
                 break;
             case CALC_FNC_AVG:
             default:
                 $fnc_name = 'avg';
                 $datavalue = $data->avg;
         }
         $proc = $datavalue * 100 / $this->sum;
         //			convert_units($datavalue,$this->items[$i]["units"]),
         if (isset($data) && isset($datavalue)) {
             $strvalue = sprintf(S_VALUE . ': %s (' . (round($proc) != $proc ? '%0.2f' : '%s') . '%%)', convert_units($datavalue, $this->items[$i]['units']), $proc);
             $str = sprintf('%s: %s [%s] ', str_pad($this->items[$i]['host'], $max_host_len, ' '), str_pad($this->items[$i]['description'], $max_desc_len, ' '), $fnc_name);
         } else {
             $strvalue = sprintf(S_VALUE . ': ' . S_NO_DATA_SMALL);
             $str = sprintf('%s: %s [ ' . S_NO_DATA_SMALL . ' ]', str_pad($this->items[$i]['host'], $max_host_len, ' '), str_pad($this->items[$i]['description'], $max_desc_len, ' '));
         }
         imagefilledrectangle($this->im, $this->shiftXleft, $this->sizeY + $shiftY + 14 * $i - 5, $this->shiftXleft + 10, $this->sizeY + $shiftY + 5 + 14 * $i, $color);
         imagerectangle($this->im, $this->shiftXleft, $this->sizeY + $shiftY + 14 * $i - 5, $this->shiftXleft + 10, $this->sizeY + $shiftY + 5 + 14 * $i, $this->getColor('Black No Alpha'));
         $dims = imageTextSize(8, 0, $str);
         imageText($this->im, 8, 0, $this->shiftXleft + 15, $this->sizeY + $shiftY + 14 * $i + 5, $this->getColor($this->graphtheme['textcolor'], 0), $str);
         $shiftX = $this->fullSizeX - $this->shiftlegendright - $this->shiftXright + 25;
         //		SDI($shiftX.','.$this->sizeX);
         imagefilledrectangle($this->im, $shiftX - 10, $this->shiftY + 10 + 14 * $i, $shiftX, $this->shiftY + 10 + 10 + 14 * $i, $color);
         imagerectangle($this->im, $shiftX - 10, $this->shiftY + 10 + 14 * $i, $shiftX, $this->shiftY + 10 + 10 + 14 * $i, $this->GetColor('Black No Alpha'));
         imagetext($this->im, 8, 0, $shiftX + 5, $this->shiftY + 10 + 14 * $i + 10, $this->getColor($this->graphtheme['textcolor'], 0), $strvalue);
     }
     if ($this->sizeY < 120) {
         return;
     }
 }
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:57,代码来源:class.cpie.php


示例11: array

$fields = array('text' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), 'font' => array(T_ZBX_INT, O_OPT, null, BETWEEN(1, 5), null), 'color' => array(T_ZBX_STR, O_OPT, null, null, null));
check_fields($fields);
$text = get_request('text', ' ');
$font = get_request('font', 9);
$color = get_request('color', 'black');
switch ($color) {
    case 'white':
        $color = array('red' => 255, 'green' => 255, 'blue' => 255);
        $shadow = array('red' => 105, 'green' => 105, 'blue' => 105);
        break;
    case 'black':
    default:
        $color = array('red' => 0, 'green' => 0, 'blue' => 0);
        $shadow = array('red' => 175, 'green' => 175, 'blue' => 175);
}
$size = imageTextSize($font, $angle, $text);
$im = imagecreatetruecolor($size['width'] + 4, $size['height'] + 4);
$width = imagesx($im);
$height = imagesy($im);
$white = imagecolorallocate($im, $shadow['red'], $shadow['green'], $shadow['blue']);
imagefilledrectangle($im, 0, 0, $width - 1, $height - 1, $white);
$text_color = imagecolorallocate($im, $color['red'], $color['green'], $color['blue']);
imageText($im, $font, 0, 0, $size['height'], $text_color, $text);
$newImage = imagecreatetruecolor($height, $width);
$white = imagecolorallocate($newImage, $shadow['red'], $shadow['green'], $shadow['blue']);
// imagealphablending($newImage, false);
// imagesavealpha($newImage, true);
for ($w = 0; $w < $width; $w++) {
    for ($h = 0; $h < $height; $h++) {
        $ref = imagecolorat($im, $w, $h);
        imagesetpixel($newImage, $h, $width - 1 - $w, $ref);
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:31,代码来源:vtext.php


示例12: imageText

function imageText($image, $fontsize, $angle, $x, $y, $color, $string)
{
    $gdinfo = gd_info();
    if ($gdinfo['FreeType Support'] && function_exists('imagettftext')) {
        if (preg_match(ZBX_PREG_DEF_FONT_STRING, $string) && $angle != 0 || ZBX_FONT_NAME == ZBX_GRAPH_FONT_NAME) {
            $ttf = ZBX_FONTPATH . '/' . ZBX_FONT_NAME . '.ttf';
            imagettftext($image, $fontsize, $angle, $x, $y, $color, $ttf, $string);
        } elseif ($angle == 0) {
            $ttf = ZBX_FONTPATH . '/' . ZBX_GRAPH_FONT_NAME . '.ttf';
            imagettftext($image, $fontsize, $angle, $x, $y, $color, $ttf, $string);
        } else {
            $ttf = ZBX_FONTPATH . '/' . ZBX_GRAPH_FONT_NAME . '.ttf';
            $size = imageTextSize($fontsize, 0, $string);
            $imgg = imagecreatetruecolor($size['width'] + 1, $size['height']);
            $transparentColor = imagecolorallocatealpha($imgg, 200, 200, 200, 127);
            imagefill($imgg, 0, 0, $transparentColor);
            imagettftext($imgg, $fontsize, 0, 0, $size['height'], $color, $ttf, $string);
            $imgg = imagerotate($imgg, $angle, $transparentColor);
            ImageAlphaBlending($imgg, false);
            imageSaveAlpha($imgg, true);
            imagecopy($image, $imgg, $x - $size['height'], $y - $size['width'], 0, 0, $size['height'], $size['width'] + 1);
            imagedestroy($imgg);
        }
    } else {
        show_error_message(_('PHP gd FreeType support missing'));
    }
}
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:27,代码来源:graphs.inc.php


示例13: drawLegend

 protected function drawLegend()
 {
     if (!$this->drawLegend) {
         return;
     }
     $shiftY = $this->shiftY;
     $shiftX = $this->fullSizeX - $this->shiftlegendright - $this->shiftXright;
     $count = 0;
     foreach ($this->series as $key => $serie) {
         foreach ($serie as $num => $value) {
             $caption = $this->seriesLegend[$num];
             $color = $this->getColor($this->seriesColor[$num], 0);
             imagefilledrectangle($this->im, $shiftX - 5, $shiftY + 14 * $count - 5, $shiftX + 5, $shiftY + 5 + 14 * $count, $color);
             imagerectangle($this->im, $shiftX - 5, $shiftY + 14 * $count - 5, $shiftX + 5, $shiftY + 5 + 14 * $count, $this->getColor('Black No Alpha'));
             $dims = imageTextSize(8, 0, $caption);
             imageText($this->im, 8, 0, $shiftX + 10, $shiftY - 5 + 14 * $count + 10, $this->getColor($this->graphtheme['textcolor'], 0), $caption);
             $count++;
         }
         break;
         //!!!!
     }
 }
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:22,代码来源:class.cbar.php


示例14: calcRows

 /**
  * Calculates the size of each row and column.
  *
  * @return void
  */
 private function calcRows()
 {
     $rowHeight = 0;
     $colWidth = array();
     foreach ($this->table as $y => $row) {
         foreach ($row as $x => $col) {
             // calculate size from image
             if (isset($col['image'])) {
                 $dims = array('width' => imagesx($col['image']), 'height' => imagesy($col['image']));
             } else {
                 if (!isset($col['fontsize'])) {
                     $col['fontsize'] = $this->fontsize;
                 }
                 $this->table[$y][$x]['fontsize'] = $col['fontsize'];
                 $dims = imageTextSize($col['fontsize'], 0, $col['text']);
             }
             $this->table[$y][$x]['size'] = $dims;
             $rowHeight = $dims['height'] > $rowHeight ? $dims['height'] : $rowHeight;
             if (!isset($colWidth[$x])) {
                 $colWidth[$x] = $dims['width'];
             } elseif ($dims['width'] > $colWidth[$x]) {
                 $colWidth[$x] = $dims['width'];
             }
         }
     }
     if ($rowHeight < $this->rowheight) {
         $rowHeight = $this->rowheight;
     } else {
         $this->rowheight = $rowHeight;
     }
     foreach ($this->table as $y => $row) {
         foreach ($row as $x => $col) {
             $this->table[$y][$x]['height'] = $rowHeight;
             $this->table[$y][$x]['width'] = $colWidth[$x];
         }
     }
 }
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:42,代码来源:CImageTextTable.php


示例15: drawSides

 private function drawSides()
 {
     if (isset($this->axis_valuetype[GRAPH_YAXIS_SIDE_RIGHT]) && ($this->yaxisright != 0 || $this->skipRightScale != 1)) {
         $sides[] = GRAPH_YAXIS_SIDE_RIGHT;
     }
     if (isset($this->axis_valuetype[GRAPH_YAXIS_SIDE_LEFT]) && ($this->yaxisleft != 0 || $this->skipLeftScale != 1) || !isset($sides)) {
         $sides[] = GRAPH_YAXIS_SIDE_LEFT;
     }
     foreach ($sides as $side) {
         $minY = $this->m_minY[$side];
         $maxY = $this->m_maxY[$side];
         $units = null;
         $unitsLong = null;
         $byteStep = false;
         for ($item = 0; $item < $this->num; $item++) {
             if ($this->items[$item]['axisside'] == $side) {
                 // check if items use B or Bps units
                 if ($this->items[$item]['units'] == 'B' || $this->items[$item]['units'] == 'Bps') {
                     $byteStep = true;
                 }
                 if (is_null($units)) {
                     $units = $this->items[$item]['units'];
                 } elseif ($this->items[$item]['units'] != $units) {
                     $units = '';
                 }
             }
         }
         if (is_null($units) || $units === false) {
             $units = '';
         } else {
             for ($item = 0; $item < $this->num; $item++) {
                 if ($this->items[$item]['axisside'] == $side && !empty($this->items[$item]['unitsLong'])) {
                     $unitsLong = $this->items[$item]['unitsLong'];
                     break;
                 }
             }
         }
         if (!empty($unitsLong)) {
             $dims = imageTextSize(9, 90, $unitsLong);
             $tmpY = $this->sizeY / 2 + $this->shiftY + $dims['height'] / 2;
             if ($tmpY < $dims['height']) {
                 $tmpY = $dims['height'] + 6;
             }
             $tmpX = $side == GRAPH_YAXIS_SIDE_LEFT ? $dims['width'] + 8 : $this->fullSizeX - $dims['width'];
             imageText($this->im, 9, 90, $tmpX, $tmpY, $this->getColor($this->graphtheme['textcolor'], 0), $unitsLong);
         }
         $step = $this->gridStep[$side];
         $hstr_count = $this->gridLinesCount[$side];
         // ignore milliseconds if  -1 <= maxY => 1 or -1 <= minY => 1
         $ignoreMillisec = bccomp($maxY, -1) <= 0 || bccomp($maxY, 1) >= 0 || bccomp($minY, -1) <= 0 || bccomp($minY, 1) >= 0;
         $newPow = false;
         if ($byteStep) {
             $maxYPow = convertToBase1024($maxY, 1024);
             $minYPow = convertToBase1024($minY, 1024);
             $powStep = 1024;
         } else {
             $maxYPow = convertToBase1024($maxY);
             $minYPow = convertToBase1024($minY);
             $powStep = 1000;
         }
         if (abs($maxYPow['pow']) > abs($minYPow['pow']) && $maxYPow['value'] != 0) {
             $newPow = $maxYPow['pow'];
             if (abs(bcdiv($minYPow['value'], bcpow($powStep, $maxYPow['pow']))) > 1000) {
                 $newPow = $minYPow['pow'];
             }
         }
         if (abs($maxYPow['pow']) < abs($minYPow['pow']) && $minYPow['value'] != 0) {
             $newPow = $minYPow['pow'];
             if (abs(bcdiv($maxYPow['value'], bcpow($powStep, $minYPow['pow']))) > 1000) {
                 $newPow = $maxYPow['pow'];
             }
         }
         if ($maxYPow['pow'] == $minYPow['pow']) {
             $newPow = $maxYPow['pow'];
         }
         $maxLength = false;
         // get all values in y-axis if units != 's'
         if ($units != 's') {
             $calcValues = array();
             for ($i = 0; $i <= $hstr_count; $i++) {
                 $hstr_count = $hstr_count == 0 ? 1 : $hstr_count;
                 $val = bcadd(bcmul($i, $step), $minY);
                 if (bccomp(bcadd($val, bcdiv($step, 2)), $maxY) == 1) {
                     continue;
                 }
                 $calcValues[] = convert_units(array('value' => $val, 'convert' => ITEM_CONVERT_NO_UNITS, 'byteStep' => $byteStep, 'pow' => $newPow));
             }
             $calcValues[] = convert_units(array('value' => $maxY, 'convert' => ITEM_CONVERT_NO_UNITS, 'byteStep' => $byteStep, 'pow' => $newPow));
             $maxLength = calcMaxLengthAfterDot($calcValues);
         }
         for ($i = 0; $i <= $hstr_count; $i++) {
             $hstr_count = $hstr_count == 0 ? 1 : $hstr_count;
             $val = bcadd(bcmul($i, $step), $minY);
             if (bccomp(bcadd($val, bcdiv($step, 2)), $maxY) == 1) {
                 continue;
             }
             $str = convert_units(array('value' => $val, 'units' => $units, 'convert' => ITEM_CONVERT_NO_UNITS, 'byteStep' => $byteStep, 'pow' => $newPow, 'ignoreMillisec' => $ignoreMillisec, 'length' => $maxLength));
             if ($side == GRAPH_YAXIS_SIDE_LEFT) {
                 $dims = imageTextSize(8, 0, $str);
                 $posX = $this->shiftXleft - $dims['width'] - 9;
//.........这里部分代码省略.........
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:101,代码来源:CLineGraphDraw_Zabbix.php


示例16: show_messages

function show_messages($bool = true, $okmsg = null, $errmsg = null)
{
    global $page, $ZBX_MESSAGES;
    if (!defined('PAGE_HEADER_LOADED')) {
        return null;
    }
    if (defined('ZBX_API_REQUEST')) {
        return null;
    }
    if (!isset($page['type'])) {
        $page['type'] = PAGE_TYPE_HTML;
    }
    $imageMessages = array();
    if (!$bool && !is_null($errmsg)) {
        $msg = _('ERROR') . ': ' . $errmsg;
    } elseif ($bool && !is_null($okmsg)) {
        $msg = $okmsg;
    }
    if (isset($msg)) {
        switch ($page['type']) {
            case PAGE_TYPE_IMAGE:
                // save all of the messages in an array to display them later in an image
                $imageMessages[] = array('text' => $msg, 'color' => !$bool ? array('R' => 255, 'G' => 0, 'B' => 0) : array('R' => 34, 'G' => 51, 'B' => 68));
                break;
            case PAGE_TYPE_XML:
                echo htmlspecialchars($msg) . "\n";
                break;
            case PAGE_TYPE_HTML:
            default:
                $msg_tab = new CTable($msg, $bool ? 'msgok' : 'msgerr');
                $msg_tab->setCellPadding(0);
                $msg_tab->setCellSpacing(0);
                $row = array();
                $msg_col = new CCol(bold($msg), 'msg_main msg');
                $msg_col->setAttribute('id', 'page_msg');
                $row[] = $msg_col;
                if (isset($ZBX_MESSAGES) && !empty($ZBX_MESSAGES)) {
                    $msg_details = new CDiv(_('Details'), 'blacklink');
                    $msg_details->setAttribute('onclick', 'javascript: showHide("msg_messages", IE ? "block" : "table");');
                    $msg_details->setAttribute('title', _('Maximize') . '/' . _('Minimize'));
                    array_unshift($row, new CCol($msg_details, 'clr'));
                }
                $msg_tab->addRow($row);
                $msg_tab->show();
                break;
        }
    }
    if (isset($ZBX_MESSAGES) && !empty($ZBX_MESSAGES)) {
        if ($page['type'] == PAGE_TYPE_IMAGE) {
            foreach ($ZBX_MESSAGES as $msg) {
                // save all of the messages in an array to display them later in an image
                if ($msg['type'] == 'error') {
                    $imageMessages[] = array('text' => $msg['message'], 'color' => array('R' => 255, 'G' => 55, 'B' => 55));
                } else {
                    $imageMessages[] = array('text' => $msg['message'], 'color' => array('R' => 155, 'G' => 155, 'B' => 55));
                }
            }
        } elseif ($page['type'] == PAGE_TYPE_XML) {
            foreach ($ZBX_MESSAGES as $msg) {
                echo '[' . $msg['type'] . '] ' . $msg['message'] . "\n";
            }
        } else {
            $lst_error = new CList(null, 'messages');
            foreach ($ZBX_MESSAGES as $msg) {
                $lst_error->addItem($msg['message'], $msg['type']);
                $bool = $bool && 'error' !== strtolower($msg['type']);
            }
            $msg_show = 6;
            $msg_count = count($ZBX_MESSAGES);
            if ($msg_count > $msg_show) {
                $msg_count = $msg_show * 16;
                $lst_error->setAttribute('style', 'height: ' . $msg_count . 'px;');
            }
            $tab = new CTable(null, $bool ? 'msgok' : 'msgerr');
            $tab->setCellPadding(0);
            $tab->setCellSpacing(0);
            $tab->setAttribute('id', 'msg_messages');
            $tab->setAttribute('style', 'width: 100%;');
            if (isset($msg_tab) && $bool) {
                $tab->setAttribute('style', 'display: none;');
            }
            $tab->addRow(new CCol($lst_error, 'msg'));
            $tab->show();
        }
        $ZBX_MESSAGES = null;
    }
    // draw an image with the messages
    if ($page['type'] == PAGE_TYPE_IMAGE && count($imageMessages) > 0) {
        $imageFontSize = 8;
        // calculate the size of the text
        $imageWidth = 0;
        $imageHeight = 0;
        foreach ($imageMessages as &$msg) {
            $size = imageTextSize($imageFontSize, 0, $msg['text']);
            $msg['height'] = $size['height'] - $size['baseline'];
            // calculate the total size of the image
            $imageWidth = max($imageWidth, $size['width']);
            $imageHeight += $size['height'] + 1;
        }
        unset($msg);
//.........这里部分代码省略.........
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:101,代码来源:func.inc.php


示例17: draw


//.........这里部分代码省略.........
     $this->calcMinMaxInterval();
     $th 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP imageTrueColorToPalette函数代码示例发布时间:2022-05-15
下一篇:
PHP imageText函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap