note 74068 added to ref.image
| From: | obao at osu1 dot php dot net | Date: | Thu, 22 Mar 2007 18:36:45 +0000 |
| Subject: | note 74068 added to ref.image | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-124728@lists.php.net to get a copy of this message | ||
<?php
// I tried to create a very simple function to create an image
// to increment any user-defined function for graph
// generation. I've one. But, the reference goes below.
function prcLegenda($intQtdLeg, $arrStrLeg = array(), $arrStrCor = array(), $strDirLeg =
"") {
// Creates a graph reference
// Four args
// Number of reference items: integer
// Reference Strings: array
// Colors Hex: array
// Optional Dir Output Image
header ("Content-type: image/jpeg");
$intX1Rec = 5;
$intY1Rec = 5;
$intX2Rec = 18;
$intY2Rec = 18;
$intHeiImg = (18 * $intQtdLeg) + 7;
$varImgIni = imagecreatetruecolor(200, $intHeiImg)
or die("GD not installed, not correctly initialized or not compatibily !");
$varCorApl = imagecolorallocate($varImgIni, 0, 0, 0);
imagefilledrectangle($varImgIni, 1, 1, 198, $intHeiImg - 2, imagecolorallocate($varImgIni, 255,
255, 255));
for ($intConAux = 0; $intConAux <= $intQtdLeg - 1;
$intConAux++) {
$strCor = prcConverteHexRGB($arrStrCor
[$intConAux]);
$varCorApl = imagecolorallocate
($varImgIni, $strCor["r"], $strCor["g"], $strCor["b"]);
imagefilledrectangle($varImgIni, $intX1Rec,
$intY1Rec, $intX2Rec, $intY2Rec, imagecolorallocate
($varImgIni, 0, 0, 0));
imagefilledrectangle($varImgIni, $intX1Rec
+ 1, $intY1Rec + 1, $intX2Rec - 1, $intY2Rec - 1, $varCorApl);
imagestring($varImgIni, 2, $intX2Rec + 5,
$intY1Rec, $arrStrLeg[$intConAux], $varCorApl);
$intY1Rec += 18;
$intY2Rec += 18;
}
if (strlen($strDirLeg) > 0) {
imagejpeg($varImgIni, $strDirLeg);
}
else {
imagejpeg($varImgIni);
}
imagedestroy($varImgIni);
}
function prcConverteHexRGB($strCorHex) {
if(!$strCorHex) {
return false;
}
$strCorHex = trim($strCorHex);
$strCorRet = false;
if(eregi("^[0-9ABCDEFabcdef\#]+$", $strCorHex)){
$strCorHex = str_replace('#','', $strCorHex);
$strCorHex001 = strlen($strCorHex);
if($strCorHex001 == 3){
unset($strCorRet);
$strCorRet[0] = $strCorRet['r'] =
$strCorRet['red'] = hexdec(substr($strCorHex, 0, 1));
$strCorRet[1] = $strCorRet['g'] =
$strCorRet['green'] = hexdec(substr($strCorHex, 1, 1));
$strCorRet[2] = $strCorRet['b'] =
$strCorRet['blue'] = hexdec(substr($strCorHex, 2, 1));
}
elseif($strCorHex001 == 6) {
unset($strCorRet);
$strCorRet[0] = $strCorRet['r'] =
$strCorRet['red'] = hexdec(substr($strCorHex, 0, 2));
$strCorRet[1] = $strCorRet['g'] =
$strCorRet['green'] = hexdec(substr($strCorHex, 2, 2));
$strCorRet[2] = $strCorRet['b'] =
$strCorRet['blue'] = hexdec(substr($strCorHex, 4, 2));
}
else {
$strCorRet = false;
}
}
else {
$strCorRet = false;
}
return $strCorRet;
}
for ($intConAux = 0; $intConAux <= 10; $intConAux++){
$str001 = "";
$str002 = array
("A","B","C","D","E","F","G","H","J","K","L",
"M","N","P","R","S","T","U
","V","W","X","Y","Z","2","3","4",
"5","6","7","8","9");
$mixArr = array_rand($str002, mt_rand(mt_rand(1,
10), mt_rand(11, strlen(md5(count($str002))) - 2)));
foreach($mixArr as $str003 => $str004){
$str001 .= $str002[$str004];
}
$arrLabels[] = $str001;
$arrCores[] = sprintf("%02X%02X%02X", mt_rand
(mt_rand(0, 255), mt_rand(0, 255)),
mt_rand(mt_rand(0,
255), mt_rand(0, 255)), mt_rand(mt_rand(0, 255),
mt_rand(0,
255)));
}
prcLegenda($intConAux, $arrLabels, $arrCores);
?>
----
Server IP: 69.147.83.197
Probable Submitter: 201.62.152.6
----
Manual Page -- http://www.php.net/manual/en/ref.image.php
Edit -- https://master.php.net/note/edit/74068
Del: integrated -- https://master.php.net/note/delete/74068/integrated
Del: useless -- https://master.php.net/note/delete/74068/useless
Del: bad code -- https://master.php.net/note/delete/74068/bad+code
Del: spam -- https://master.php.net/note/delete/74068/spam
Del: non-english -- https://master.php.net/note/delete/74068/non-english
Del: in docs -- https://master.php.net/note/delete/74068/in+docs
Del: other reasons-- https://master.php.net/note/delete/74068
Reject -- https://master.php.net/note/reject/74068
Search -- https://master.php.net/manage/user-notes.php