本文整理汇总了PHP中ImageStringUp函数的典型用法代码示例。如果您正苦于以下问题:PHP ImageStringUp函数的具体用法?PHP ImageStringUp怎么用?PHP ImageStringUp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ImageStringUp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
function display($db_object, $common, $user_id, $default, $error_msg, $learning, $post_var)
{
$width = 340;
$height = 220;
// $labelfont = '2';
$labeltitlefont = '3';
$image = ImageCreate($width, $height);
while (list($kk, $vv) = @each($post_var)) {
${$kk} = $vv;
}
/*
$to_date=2004-01-02;
$from_date=2004-01-02;
$avg_rater=50.23;
*/
$bgcolor = ImageColorAllocate($image, 0xffffff, 0xffffff, 0xffffff);
$border = ImageColorAllocate($image, 0x0, 0x0, 0x0);
$border1 = ImageColorAllocate($image, 0xcccccc, 0x0, 0x0);
//$border2 = ImageColorAllocate($image,0x000000, 0xcccccc, 0x000000);
ImageRectangle($image, 40, 20, 240, 160, $border);
ImageString($image, $labelfont, 15, 20, "100%", $border);
ImageString($image, $labelfont, 20, 55, "75%", $border);
ImageString($image, $labelfont, 20, 90, "50%", $border);
ImageString($image, $labelfont, 20, 125, "25%", $border);
ImageString($image, $labelfont, 20, 155, "0%", $border);
$fdate = $learning->changedate_display($from_date);
$tdate = $learning->changedate_display($to_date);
$days = $error_msg['cDays'] . " {$fdate} " . $error_msg['cTo'] . " {$tdate} ";
$avg_rt = @explode(",", $avg_rater);
$id = @explode(",", $ids);
for ($i = 0; $i < count($avg_rt); $i++) {
$p1 = rand(0, 200);
$p2 = rand(30, 250);
$p3 = rand(100, 250);
$color = imagecolorallocate($image, $p1, $p2, $p3);
$avg = $avg_rt[$i];
$avg_comp = 160 - 140 / 100 * $avg;
$avg = round($avg, 2);
$rid = $id[$i];
$rname = $common->name_display($db_object, $rid);
ImageStringUp($image, $labeltitlefont, 5, 110, $error_msg['cResults'], $border);
ImageString($image, $labeltitlefont, 245, 20, $error_msg['cCommitment'], $border);
ImageString($image, $labeltitlefont, 50, 170, "{$days}", $border);
//ImageString($image, $labeltitlefont, 50,180, "$rname", $color);
ImageLine($image, 240, 20, 40, 160, $border1);
//COMMITMENT LINE
ImageLine($image, 240, $avg_comp, 40, 160, $color);
//AVERAGE COMPLETION
header("Content-type: image/png");
// or "Content-type: image/png"
Imagepng($image);
// or imagepng($image)
}
ImageDestroy($image);
}
示例2: drawTitles
function drawTitles($image, $w, $h, $col, $title, $xtitle, $ytitle)
{
$width = ImageFontWidth(1) * strlen($title);
$x = ($w - $width) / 2;
ImageString($image, 1, $x, 3, $title, $col);
$width = ImageFontWidth(1) * strlen($ytitle);
$x = ($w - $width) / 2;
ImageString($image, 1, $x, $h - 10, $ytitle, $col);
$height = ImageFontWidth(1) * strlen($xtitle);
$y = ($h - $height) / 2;
ImageStringUp($image, 1, 1, $y + $height, $xtitle, $col);
}
示例3: display
function display($db_object, $common, $user_id, $default, $error_msg, $learning, $post_var)
{
$width = 340;
$height = 220;
// $labelfont = '2';
$labeltitlefont = '3';
$image = ImageCreate($width, $height);
while (list($kk, $vv) = @each($post_var)) {
${$kk} = $vv;
}
$bgcolor = ImageColorAllocate($image, 0xffffff, 0xffffff, 0xffffff);
$border = ImageColorAllocate($image, 0x0, 0x0, 0x0);
$border1 = ImageColorAllocate($image, 0xcccccc, 0x0, 0x0);
$border2 = ImageColorAllocate($image, 0x0, 0xcccccc, 0x0);
ImageRectangle($image, 40, 20, 240, 160, $border);
ImageString($image, $labelfont, 15, 20, "100%", $border);
ImageString($image, $labelfont, 20, 55, "75%", $border);
ImageString($image, $labelfont, 20, 90, "50%", $border);
ImageString($image, $labelfont, 20, 125, "25%", $border);
ImageString($image, $labelfont, 20, 155, "0%", $border);
$fdate = $learning->changedate_display($from_date);
$tdate = $learning->changedate_display($to_date);
$days = $error_msg['cDays'] . " {$fdate} " . $error_msg['cTo'] . " {$tdate} ";
$avg_comp = 160 - 140 / 100 * $avg;
$avg = round($avg, 2);
ImageStringUp($image, $labeltitlefont, 5, 110, $error_msg['cResults'], $border);
ImageString($image, $labeltitlefont, 245, 20, $error_msg['cCommitment'], $border);
ImageString($image, $labeltitlefont, 50, 170, "{$days}", $border);
ImageString($image, $labeltitlefont, 50, 200, $error_msg['cCTimelyCompletionofActivities'], $border);
ImageString($image, $labeltitlefont, 50, 185, $error_msg['cAverage'], $border);
ImageString($image, $labeltitlefont, 115, 185, $avg, $border);
ImageLine($image, 240, 20, 40, 160, $border1);
//COMMITMENT LINE
ImageLine($image, 240, $avg_comp, 40, 160, $border2);
//AVERAGE COMPLETION
ImageString($image, $labeltitlefont, 245, $avg_comp, $error_msg['cAccomplishment'], $border);
header("Content-type: image/png");
// or "Content-type: image/png"
Imagepng($image);
// or imagepng($image)
ImageDestroy($image);
}
示例4: createGistagramm
function createGistagramm($width, $heigth)
{
$image = @imagecreate($width, $heigth);
$maxKey = findMaxKey($this->array);
$maxValue = findMaxValue($this->array);
ImageColorAllocate($image, 255, 255, 255);
ImageLine($image, $this->align, $heigth - $this->align, $width - $this->align, $heigth - $this->align, 1);
ImageLine($image, $this->align, $this->align, $this->align, $heigth - $this->align, 1);
$widthRect = round(($width - 2 * $this->align) / ($maxKey + 1)) * $this->widthColumn;
foreach ($this->array as $key => $value) {
$color = getColor($image, $value, $maxValue);
$heigthRect = round($value * ($heigth - 2 * $this->align) / $maxValue);
$pos = round($key / ($maxKey + 1) * ($width - 2 * $this->align)) + $this->align;
ImageFilledRectangle($image, $pos - $widthRect / 2, $heigth - $heigthRect, $pos + $widthRect / 2, $heigth - $this->align, $color);
$white = ImageColorAllocate($image, 217, 220, 57);
ImageStringUp($image, 0, $pos - $widthRect / 2 + 4, $heigth - $heigthRect / 2, $value, $white);
ImageString($image, 0, $pos - $widthRect / 2, $heigth - $this->align, $key, 1);
}
$this->image = $image;
}
示例5: executeText2img
/**
* Convierte un texto a imagen
* @param string $texto
*/
public function executeText2img(sfWebRequest $request)
{
//fuente por defecto
$this->font = 2;
//obtengo el texto
$texto = utf8_decode($request->getParameter('texto', 'null'));
//seteo el header
header("Content-type: image/png");
// calculo el alto
$alto = strlen($texto) * imagefontwidth($this->font) + imagefontwidth($this->font);
$img_handle = imagecreatetruecolor(imagefontheight($this->font), $alto) or die("Cannot Create image");
// ImageColorAllocate (image, red, green, blue)
$back_color = ImageColorAllocate($img_handle, 255, 255, 255);
$txt_color = ImageColorAllocate($img_handle, 0, 0, 0);
ImageFill($img_handle, 0, 0, $back_color);
ImageStringUp($img_handle, $this->font, 0, $alto - imagefontwidth($this->font) / 2, $texto, $txt_color);
ImagePng($img_handle);
ImageDestroy($img_handle);
return sfView::NONE;
}
示例6: MakeBarChart
function MakeBarChart()
{
// #DEFINITIONS#####################################
$chartx = 5;
$charty = 5;
$chartw = $this->Width - 10;
$charth = $this->Height - 10;
$im = imagecreate($this->Width, $this->Height);
$black = ImageColorAllocate($im, 0, 0, 0);
$white = ImageColorAllocate($im, 255, 255, 255);
imagesetstyle($im, array($black, $black, $black, $white, $white, $white));
$colors[0] = ImageColorAllocate($im, 100, 149, 237);
$colors[1] = ImageColorAllocate($im, 240, 128, 128);
$colors[2] = ImageColorAllocate($im, 50, 205, 50);
$colors[3] = ImageColorAllocate($im, 255, 215, 0);
$colors[4] = ImageColorAllocate($im, 131, 111, 255);
$colors[5] = ImageColorAllocate($im, 144, 238, 144);
$colors[6] = ImageColorAllocate($im, 70, 130, 180);
$colors[7] = ImageColorAllocate($im, 244, 164, 96);
$colors[8] = ImageColorAllocate($im, 139, 121, 94);
$colors[9] = ImageColorAllocate($im, 190, 190, 190);
$font1 = 5;
$ifh1 = ImageFontHeight($font1);
$ifw1 = ImageFontWidth($font1);
$font2 = 4;
$ifh2 = ImageFontHeight($font2);
$ifw2 = ImageFontWidth($font2);
$font3 = 3;
$ifh3 = ImageFontHeight($font3);
$ifw3 = ImageFontWidth($font3);
// #################################################
ImageFill($im, 0, 0, $white);
// #DRAWING CAPTIONS################################
if ($this->Title) {
$len = strlen($this->Title) * $ifw1;
ImageString($im, $font1, ($this->Width - $len) / 2, $charty, $this->Title, $black);
ImageLine($im, ($this->Width - $len) / 2, $charty + $ifh1, ($this->Width + $len) / 2, $charty + $ifh1, $black);
$charty += $ifh1 + 5;
$charth -= $ifh1 + 5;
}
if ($this->SubTitle) {
// GET A LITTLE NEAR TO TITLE
$charty -= 3;
$charth += 3;
$len = strlen($this->SubTitle) * $ifw3;
ImageString($im, $font3, ($this->Width - $len) / 2, $charty, $this->SubTitle, $black);
$charty += $ifh3 + 5;
$charth -= $ifh3 + 5;
}
if ($this->xCaption) {
$len = strlen($this->xCaption) * $ifw3;
ImageString($im, $font3, ($this->Width - $len) / 2, $this->Height - $ifh3 - 5, $this->xCaption, $black);
$charth -= $ifh3 + 5;
}
if ($this->yCaption) {
$len = strlen($this->yCaption) * $ifw3;
ImageStringUp($im, $font3, $chartx, ($this->Height + $len) / 2, $this->yCaption, $black);
$chartx += $ifh3 + 15;
$chartw -= $ifh3 + 15;
}
// #################################################
/* X,Y AXIS MUST BE RESIZED TO FIT THE LONGEST CAPTION
BEFORE WE START DRAWING ON THEM */
// #RESERVING SPACE FOR X VALUES####################
if ($this->xCount && $this->xShowValue) {
$xValueMaxLen = 0;
if (is_array($this->xValue)) {
foreach ($this->xValue as $value) {
$xValueMaxLen = max($xValueMaxLen, strlen($value));
}
}
$charth -= $xValueMaxLen * $ifw3 + 5;
}
// #################################################
// #RESERVING SPACE FOR Y VALUES####################
if ($this->yCount) {
$yValueMaxLen = 0;
$yScale = array();
$valueInc = ($this->DataMax - $this->DataMin) / $this->yCount;
$value = $this->DataMin;
for ($i = 0; $i <= $this->yCount; $i++) {
if (isset($this->DataDecimalPlaces)) {
$str = number_format($value, $this->DataDecimalPlaces, ',', '');
} else {
$str = $value;
}
$yValueMaxLen = max($yValueMaxLen, strlen($str));
$yAxis[] = $str;
$value += $valueInc;
}
// THE SPACE SHOULD BE RESERVED ONLY IF WE ARE GOING TO PRINT THE VALUES
if ($this->yShowValue) {
$chartx += $yValueMaxLen * $ifw3 + 5;
$chartw -= $yValueMaxLen * $ifw3 + 5;
}
}
// #################################################
// #DRAWING VALUES AT X AXIS########################
if ($this->xCount) {
$xdelta = $chartw / (3 * $this->xCount + 1);
//.........这里部分代码省略.........
示例7: SetyTitle
/**
* SetyTitle sets a title to the left of the y-axis.
*/
function SetyTitle($ytitle)
{
$text_left = 10;
$text_top = $this->image_height / 2 + strlen($ytitle) * 2.4;
ImageStringUp($this->im, 1, $text_left, $text_top, $ytitle, $this->color['black']);
}
示例8: _write
/**
* Write a text on the canvas
* @param int $x The X (horizontal) position of the text
* @param int $y The Y (vertical) position of the text
* @param string $text The text to write on the canvas
* @access private
*/
function _write($x, $y, $text)
{
ImageStringUp($this->_canvas(), IMAGE_GRAPH_FONT, $x, $y + $this->height($text), $text, $this->_getColor());
}
示例9: ImageCreate
<?php
$im = ImageCreate(175, 125);
$white = ImageColorAllocate($im, 255, 255, 255);
$black = ImageColorAllocate($im, 0, 0, 0);
ImageString($im, 1, 10, 20, "Font 1: ABCdef", $black);
ImageString($im, 2, 10, 35, "Font 2: ABCdef", $black);
ImageString($im, 3, 10, 53, "Font 3: ABCdef", $black);
ImageString($im, 4, 10, 70, "Font 4: ABCdef", $black);
ImageString($im, 5, 10, 90, "Font 5: ABCdef", $black);
ImageStringUp($im, 5, 150, 118, "Vertical Text", $black);
Header('Content-Type: image/png');
ImagePNG($im);
示例10: _done
/**
* Output the element to the canvas
* @see Image_Graph_Common
* @access private
*/
function _done()
{
if (is_a($this->_fillStyle, "Image_Graph_Fill")) {
$this->_fillStyle->_reset();
}
if ($this->_background != null) {
$this->_debug("Drawing background");
ImageFilledRectangle($this->_canvas(), $this->_left, $this->_top, $this->_right, $this->_bottom, $this->_getBackground());
}
if ($this->_identify) {
$this->_debug("Identifying");
$red = rand(0, 255);
$green = rand(0, 255);
$blue = rand(0, 255);
$color = ImageColorAllocate($this->_canvas(), $red, $green, $blue);
if (isset($GLOBALS['_Image_Graph_gd2'])) {
$alphaColor = ImageColorResolveAlpha($this->_canvas(), $red, $green, $blue, 200);
} else {
$alphaColor = $color;
}
ImageRectangle($this->_canvas(), $this->_left, $this->_top, $this->_right, $this->_bottom, $color);
ImageFilledRectangle($this->_canvas(), $this->_left, $this->_top, $this->_right, $this->_bottom, $alphaColor);
if ($this->_identifyText) {
$text = eregi_replace("<[^>]*>([^<]*)", "\\1", $this->_identification());
if (ImageFontWidth(IMAGE_GRAPH_FONT) * strlen($text) > $this->width()) {
$x = max($this->_left, min($this->_right, $this->_left + ($this->width() - ImageFontHeight(IMAGE_GRAPH_FONT)) / 2));
$y = max($this->_top, min($this->_bottom, $this->_bottom - ($this->height() - ImageFontWidth(IMAGE_GRAPH_FONT) * strlen($text)) / 2));
ImageStringUp($this->_canvas(), FONT, $x, $y, $text, $color);
} else {
$x = max($this->_left, min($this->_right, $this->_left + ($this->width() - ImageFontWidth(IMAGE_GRAPH_FONT) * strlen($text)) / 2));
$y = max($this->_top, min($this->_bottom, $this->_top + ($this->height() - ImageFontHeight(IMAGE_GRAPH_FONT)) / 2));
ImageString($this->_canvas(), FONT, $x, $y, $text, $color);
}
}
}
if ($this->_borderStyle != null) {
$this->_debug("Drawing border");
ImageRectangle($this->_canvas(), $this->_left, $this->_top, $this->_right, $this->_bottom, ((is_a($this->_borderStyle, "Image_Graph_Color")) ? $this->_borderStyle->_index : $this->_borderStyle->_getLineStyle()));
}
parent::_done();
if ($this->_shadow) {
$this->_displayShadow();
}
}
示例11: define
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
define('ZBX_PAGE_NO_AUTHERIZATION', 1);
require_once "include/config.inc.php";
$page['file'] = 'vtext.php';
$page['type'] = PAGE_TYPE_IMAGE;
include_once "include/page_header.php";
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
$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));
check_fields($fields);
$text = get_request("text", ' ');
$font = get_request("font", 3);
$width = ImageFontWidth($font) * strlen($text);
$height = ImageFontHeight($font);
$im = imagecreate($height, $width);
$backgroud_color = ImageColorAllocate($im, 255, 255, 255);
$text_color = ImageColorAllocate($im, 0, 0, 0);
ImageStringUp($im, $font, 0, $width - 1, $text, $text_color);
imagecolortransparent($im, $backgroud_color);
ImageOut($im);
ImageDestroy($im);
include_once "include/page_footer.php";
示例12: list
list($LangName, $valid) = ValidLangs($WhiteListLangs, TRUE);
list($Shapes, $valid) = ValidMatrix('s', 1, $valid);
for ($i = 0; $i < sizeof($Shapes); $i++) {
$Shapes[$i] = log10($Shapes[$i]);
}
list($Centers, $valid) = ValidMatrix('c', 1, $valid);
for ($i = 0; $i < sizeof($Centers); $i++) {
$Centers[$i] = log10($Centers[$i]);
}
// CHART //////////////////////////////////////////////////
$w = 150;
$h = 120;
$xo = 48;
$yo = MARGIN;
$chart = new ShapeChart();
if ($valid) {
$chart->yAxis(log10axis(axis3_5_10()));
$chart->xAxis(log10axis(axisOneTen()), 101.0);
$chart->frame();
$chart->title_($LangName[0], 2, CHAR_WIDTH_2);
// hard-code a shortest programs example
if (!isset($LangName[0])) {
$chart->title_('Shortest C++', 2, CHAR_WIDTH_2);
}
$chart->shapes($Shapes, $Centers);
$label = 'concise';
ImageString($chart->im, 2, $xo, $h - $yo + 4, $label, $chart->colour[DARK_GRAY]);
$label = 'fast';
ImageStringUp($chart->im, 2, 30, $h, $label, $chart->colour[DARK_GRAY]);
}
$chart->complete();
示例13: print_fan_chart
//.........这里部分代码省略.........
print "<br /><a href=\"hourglass.php?pid={$pid}\" onmouseover=\"clear_family_box_timeout('" . $pid . "." . $count . "');\" onmouseout=\"family_box_timeout('" . $pid . "." . $count . "');\">" . $pgv_lang["hourglass_chart"] . "</a>";
if ($sosa >= 1) {
$famids = find_sfamily_ids($pid);
//-- make sure there is more than 1 child in the family with parents
$cfamids = find_family_ids($pid);
$num = 0;
for ($f = 0; $f < count($cfamids); $f++) {
$famrec = find_family_record($cfamids[$f]);
if ($famrec) {
$num += preg_match_all("/1\\s*CHIL\\s*@(.*)@/", $famrec, $smatch, PREG_SET_ORDER);
}
}
if ($famids || $num > 1) {
//-- spouse(s) and children
for ($f = 0; $f < count($famids); $f++) {
$famrec = find_family_record(trim($famids[$f]));
if ($famrec) {
$parents = find_parents($famids[$f]);
if ($parents) {
if ($pid != $parents["HUSB"]) {
$spid = $parents["HUSB"];
} else {
$spid = $parents["WIFE"];
}
$person = Person::getInstance($spid);
if ($person) {
echo '<br /><a href="', $person->getLinkUrl(), '" class="name1">', $person->getFullName(), '</a>';
}
}
$num = preg_match_all("/1\\s*CHIL\\s*@(.*)@/", $famrec, $smatch, PREG_SET_ORDER);
for ($i = 0; $i < $num; $i++) {
$person = Person::getInstance($smatch[$i][1]);
if ($person) {
echo '<br /> <a href="', $person->getLinkUrl(), '" class="name1">< ', $person->getFullName(), '</a>';
}
}
}
}
//-- siblings
for ($f = 0; $f < count($cfamids); $f++) {
$famrec = find_family_record($cfamids[$f]);
if ($famrec) {
$num = preg_match_all("/1\\s*CHIL\\s*@(.*)@/", $famrec, $smatch, PREG_SET_ORDER);
if ($num > 2) {
print "<br /><span class=\"name1\">" . $pgv_lang["siblings"] . "</span>";
}
if ($num == 2) {
print "<br /><span class=\"name1\">" . $pgv_lang["sibling"] . "</span>";
}
for ($i = 0; $i < $num; $i++) {
$cpid = $smatch[$i][1];
if ($cpid != $pid) {
$person = Person::getInstance($cpid);
if ($person) {
echo '<br /> <a href="', $person->getLinkUrl(), '" class="name1"> ', $person->getFullName(), '</a>';
}
}
}
}
}
}
}
print "</td></tr></table>";
print "</div>";
$imagemap .= " onclick=\"show_family_box('" . $pid . "." . $count . "', 'relatives'); return false;\"";
$imagemap .= " onmouseout=\"family_box_timeout('" . $pid . "." . $count . "'); return false;\"";
$imagemap .= " alt=\"" . PrintReady(strip_tags($name)) . "\" title=\"" . PrintReady(strip_tags($name)) . "\" />";
}
$deg1 -= $angle;
$deg2 -= $angle;
$sosa--;
}
$rx -= $rw;
$gen--;
}
$imagemap .= "</map>";
echo $imagemap;
// PGV banner ;-)
ImageStringUp($image, 1, $fanw - 10, $fanh / 3, PGV_PHPGEDVIEW_URL, $color);
// here we cannot send image to browser ('header already sent')
// and we dont want to use a tmp file
// step 1. save image data in a session variable
ob_start();
ImagePng($image);
$image_data = ob_get_contents();
ob_end_clean();
$image_data = serialize($image_data);
unset($_SESSION['image_data']);
$_SESSION['image_data'] = $image_data;
// step 2. call imageflush.php to read this session variable and display image
// note: arg "image_name=" is to avoid image miscaching
$image_name = "V" . time();
unset($_SESSION[$image_name]);
// statisticsplot.php uses this to hold a file name to send to browser
$image_title = preg_replace("~<.*>~", "", $name) . " " . $pgv_lang["fan_chart"];
echo "<p align=\"center\" >";
echo "<img src=\"imageflush.php?image_type=png&image_name={$image_name}&height={$fanh}&width={$fanw}\" width=\"{$fanw}\" height=\"{$fanh}\" border=\"0\" alt=\"{$image_title}\" title=\"{$image_title}\" usemap=\"#fanmap\" />";
echo "</p>";
ImageDestroy($image);
}
示例14: strlen
$x += 20;
$x1 = $x;
$chart->xo = $x;
$chart->barspace = 3;
$chart->barwidth = 5;
$x = $chart->bars(DARK_GRAY, $gz, FALSE);
$label = 'Code';
$z = $x1 + ($x - $x1 - strlen($label) * CHAR_WIDTH_2) / 2.0;
ImageString($chart->im, 2, $z, $chart->h - 30, $label, $chart->colour[BLACK]);
ImageString($chart->im, 2, $z, 23, $label, $chart->colour[BLACK]);
$chart->xo = $chart->defaultOriginX();
// Y AXIS LABEL
$names0 = explode(' ', $LangName[0]);
$names1 = explode(' ', $LangName[1]);
$label = $names0[0] == $names1[0] ? $LangName[0] : $names0[0];
$size = $chart->yo - MARGIN;
$labelsize = strlen($label) * CHAR_WIDTH_3;
if ($size < $labelsize) {
$label = $names0[1];
$labelsize = strlen($label) * CHAR_WIDTH_3;
}
$inset = $size / 2.0 + $labelsize / 2.0;
$label = $label . ' used';
$labelsize = strlen($label) * CHAR_WIDTH_3;
ImageStringUp($chart->im, 3, 0, $chart->yo - MARGIN / 2.0 + $labelsize / 2.0, $label, $chart->colour[BLACK]);
//
$chart->title($LangName[0] . ' ÷ ' . $LangName[1]);
$chart->notice($Mark);
}
$chart->frame();
$chart->complete();
示例15: Draw
function Draw($site)
{
global $image, $racks, $devices, $links, $port_count, $ports;
$rack_count = CountRacksInSite($site);
// Define the modifiers
$modifier = 3;
$top_modifier = 0;
$dev_modifier = array();
$side_modifier = array();
$rack_buffer = (CountLinks($site) + 2) * $modifier;
// Space between racks
$rack_margin = $rack_buffer;
// Space between the racks and edge of page
$y_top_margin = 100 + CountLinks($site) * 1.25;
$y_bot_margin = 75;
$page_size = 7;
$page_counter = 0;
$x_offset = 25;
$y_offset = 50;
$height = 100;
$rack_width = 300;
$rack_height = CountDevicesInRack($site) * $height;
$width = $rack_width;
$x_buffer = $width + intval($width * 0.5);
$y_buffer = 50;
ksort($racks);
ksort($devices);
$x_max = $rack_count * $rack_width + $rack_count * $rack_buffer + $rack_margin * 2;
$y_max = $rack_height + $y_top_margin + intval(ImageFontHeight(2) * (CountLinks($site) * 1.25) + 0.5);
$image = ImageCreate($x_max, $y_max) or die("Cannot Create image");
$background_color = imagecolorallocate($image, 255, 255, 255);
$pink = ImageColorAllocate($image, 255, 105, 180);
$white = ImageColorAllocate($image, 255, 255, 255);
$black = ImageColorAllocate($image, 0, 0, 0);
$red = ImageColorAllocate($image, 255, 0, 0);
$green = ImageColorAllocate($image, 89, 200, 180);
$blue = ImageColorAllocate($image, 34, 68, 228);
$grey = ImageColorAllocate($image, 225, 225, 225);
$title = "RackTables Visualised ({$site})";
$title_font = 5;
$title_font_width = ImageFontWidth($title_font);
ImageString($image, $title_font, $x_max / 2 - $title_font_width * strlen($title) / 2, $title_font_width * 2, $title, $black);
// Draw racks
$rc = 1;
ksort($racks, SORT_STRING);
foreach ($racks as $rackname => $sitename) {
if ($site != $sitename) {
continue;
}
$y = $y_top_margin;
$x = $rack_margin + ($rc - 1) * $rack_width + $rc * $rack_buffer;
$x = ($rc - 1) * $rack_width + $rc * $rack_buffer;
ImageRectangle($image, $x, $y, $x + $rack_width, $y + $rack_height, $black);
$rack_name_width = ImageFontWidth($rackname);
$rack_name_font = 2;
ImageString($image, $rack_name_font, $x + ($rack_width - $rack_name_width * strlen($rackname)) / 2, $y - intval(ImageFontHeight($rack_name_font) * 1.25), $rackname, $black);
// Draw devices
foreach ($devices as $device_name => $installed_rack) {
if ($installed_rack != $rackname) {
continue;
}
ImageRectangle($image, $x, $y, $x + $width, $y + $height, $black);
ImageString($image, 2, $x + 5, $y + 3, strtoupper($device_name), $black);
$unit = $width / ($port_count[$device_name] + 1);
for ($i = 0; $i < $port_count[$device_name]; $i++) {
$cx = $x + $unit * ($i + 1);
$coord[$device_name][$ports[$device_name][$i]][0] = $cx;
$coord[$device_name][$ports[$device_name][$i]][1] = intval($y + $height / 2);
ImageFilledEllipse($image, $cx, $coord[$device_name][$ports[$device_name][$i]][1], 3, 3, $black);
ImageStringUp($image, 1, $cx - intval(ImageFontWidth(1) / 2), $coord[$device_name][$ports[$device_name][$i]][1] - 5, $ports[$device_name][$i], $black);
}
$y = $y + $height;
}
$rc++;
}
unset($rc);
$line_tracker = array();
$index = 0;
$label = "Device Inter-Connections";
ImageString($image, 3, $rack_margin, $y_top_margin + $rack_height + 20, $label, $black);
ImageLine($image, $rack_margin, $y_top_margin + $rack_height + 20 + ImageFontHeight(3) + 1, $rack_margin + ImageFontWidth(3) * strlen($label), $y_top_margin + $rack_height + 20 + ImageFontHeight(3) + 1, $black);
unset($label);
$y = $y_top_margin - intval(ImageFontHeight(2) * 1.25);
$text_x_coord['data'] = $rack_margin;
$text_x_coord['power'] = $rack_margin + 320;
$text_x_coord['kvm'] = $rack_margin + 640;
// Iterate through the links
foreach ($links as $link) {
switch ($link['Type']) {
case 16:
// Power
$colour = $red;
$type = 'power';
break;
case 19:
// Fast Ethernet
$colour = $blue;
$type = 'data';
break;
case 24:
//.........这里部分代码省略.........