本文整理汇总了PHP中imageRectangle函数的典型用法代码示例。如果您正苦于以下问题:PHP imageRectangle函数的具体用法?PHP imageRectangle怎么用?PHP imageRectangle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imageRectangle函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCreateImage
private function getCreateImage()
{
$this->image = imageCreate($this->width, $this->height);
$background = imageColorAllocate($this->image, 255, 255, 255);
$border = imageColorAllocate($this->image, 0, 0, 0);
imageRectangle($this->image, 0, 0, $this->width - 1, $tihs->height - 1, $border);
}
示例2: createImage
public function createImage($text = '', $fontSize = 5)
{
// GD's built-in fonts are numbered from 1 - 5
$font_size = $fontSize;
// Calculate the appropriate image size
$image_height = intval(imageFontHeight($font_size) * 2);
$image_width = intval(strlen($text) * imageFontWidth($font_size) * 1.3);
// Create the image
$image = imageCreate($image_width, $image_height);
// Create the colors to use in the image
// gray background
$back_color = imageColorAllocate($image, 216, 216, 216);
// blue text
$text_color = imageColorAllocate($image, 0, 0, 255);
// black border
$rect_color = imageColorAllocate($image, 0, 0, 0);
// Figure out where to draw the text
// (Centered horizontally and vertically
$x = ($image_width - imageFontWidth($font_size) * strlen($text)) / 2;
$y = ($image_height - imageFontHeight($font_size)) / 2;
// Draw the text
imageString($image, $font_size, $x, $y, $text, $text_color);
// Draw a black border
imageRectangle($image, 0, 0, imageSX($image) - 1, imageSY($image) - 1, $rect_color);
// Send the image to the browser
header('Content-Type: image/png');
imagePNG($image);
imageDestroy($image);
}
示例3: getCreateImage
private function getCreateImage()
{
//用来创建图像资源,并初使化背影
$this->image = imageCreate($this->width, $this->height);
$back = imageColorAllocate($this->image, 255, 255, 255);
$border = imageColorAllocate($this->image, 0, 0, 0);
imageRectangle($this->image, 0, 0, $this->width - 1, $this->height - 1, $border);
}
示例4: getCreateImage
private function getCreateImage()
{
//用来创建图像资源,并初使化背影
$this->image = imagecreatetruecolor($this->width, $this->height);
$backColor = imagecolorallocate($this->image, rand(225, 255), rand(225, 255), rand(225, 255));
//背景色(随机)
@imagefill($this->image, 0, 0, $backColor);
$border = imageColorAllocate($this->image, 0, 0, 0);
imageRectangle($this->image, 0, 0, $this->width - 1, $this->height - 1, $border);
}
示例5: getCreateImage
private function getCreateImage()
{
//创建指定大小的画布(基于调色板)
$this->image = imageCreate($this->width, $this->height);
//设置颜色(白色)
$back = imagecolorallocate($this->image, 255, 255, 255);
//设置颜色(黑色)
$border = imagecolorallocate($this->image, 0, 0, 0);
//在图像中绘制一个矩形
imageRectangle($this->image, 0, 0, $this->width - 1, $this->height - 1, $border);
}
示例6: create_pix
private function create_pix()
{
for ($i = 0; $i < 3; $i++) {
imageline($this->img, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $this->font_color_res);
}
for ($i = 0; $i < 2; $i++) {
imageEllipse($this->img, mt_rand(0, $this->width), mt_rand(0, $this->height), 100, 100, $this->font_color_res);
}
for ($i = 0; $i < 100; $i++) {
imagesetpixel($this->img, mt_rand(0, $this->width), mt_rand(0, $this->height), $this->font_color_res);
}
imageRectangle($this->img, 0, 0, $this->width - 1, $this->height - 1, $this->font_color_res);
}
示例7: getPNG
public function getPNG()
{
// создаем картинку
$image = imageCreate($this->width + $this->widthLegend, $this->height);
$backColor = imageColorAllocate($image, $this->colorBG >> 16, ($this->colorBG >> 8) % 256, $this->colorBG % 256);
$centerColor = imageColorAllocate($image, $this->colorCenter >> 16, ($this->colorCenter >> 8) % 256, $this->colorCenter % 256);
$pointsColor = imageColorAllocate($image, $this->colorPoints >> 16, ($this->colorPoints >> 8) % 256, $this->colorPoints % 256);
$legendColor = imageColorAllocate($image, $this->colorLegend >> 16, ($this->colorLegend >> 8) % 256, $this->colorLegend % 256);
// background
imageFilledRectangle($image, 0, 0, $this->width, $this->height, $backColor);
imageRectangle($image, $this->width, 0, $this->widthLegend + $this->width - 1, $this->height - 1, $legendColor);
// добавляем масштаб в легенду
imageLine($image, $this->width + 10, $this->height - $this->fontSize * 2 - 1, $this->width + 10, $this->height - $this->fontSize * 2 + 1, $legendColor);
imageLine($image, $this->width + 10, $this->height - $this->fontSize * 2, $this->width + 20, $this->height - $this->fontSize * 2, $legendColor);
imageLine($image, $this->width + 20, $this->height - $this->fontSize * 2 - 1, $this->width + 20, $this->height - $this->fontSize * 2 + 1, $legendColor);
imageTTFText($image, $this->fontSize, 0, $this->width + $this->fontSize + 20, $this->height - $this->fontSize * 1.5, $legendColor, $this->pathToFont, "{$this->metersIn10Pix} {$this->metersLabel}");
// center
imageFilledEllipse($image, $this->centerWidth, $this->centerHeight, $this->sizePoints, $this->sizePoints, $centerColor);
imageTTFText($image, $this->fontSize, 0, $this->centerWidth, $this->centerHeight + $this->fontSize + $this->sizePoints, $centerColor, $this->pathToFont, "0");
imageTTFText($image, $this->fontSize, 0, $this->width + $this->fontSize, $this->fontSize * 2, $legendColor, $this->pathToFont, "0 - {$this->centerLabel}");
// points
$i = 1;
foreach ($this->pointsBased as $v) {
$angle = $v->getPoint()->getAzimuth() - 90;
// угол для тригонометрии
$pointWidth = $this->centerWidth + $this->k * ($v->getPoint()->getDistance() * cos(deg2rad($angle)));
$pointHeight = $this->centerHeight + $this->k * ($v->getPoint()->getDistance() * sin(deg2rad($angle)));
// рисуем точку
imageEllipse($image, $pointWidth, $pointHeight, $this->sizePoints, $this->sizePoints, $pointsColor);
// подпись
imageTTFText($image, $this->fontSize, 0, $pointWidth, $pointHeight + $this->fontSize + $this->sizePoints, $pointsColor, $this->pathToFont, $i);
// в легенду
imageTTFText($image, $this->fontSize, 0, $this->width + $this->fontSize, $this->fontSize * 2 * ($i + 1), $legendColor, $this->pathToFont, "{$i} - " . $v->getTitle());
$i++;
}
ob_start();
imagePng($image);
$str = ob_get_clean();
return $str;
}
示例8: show
public static function show()
{
$width = self::$width;
$height = self::$height;
$len = self::$len;
$bgcolor = self::$bgcolor;
$noise = self::$noise;
$noisenum = self::$noisenum;
$border = self::$border;
$bordercolor = self::$bordercolor;
self::$_image = imageCreate($width, $height);
$back = self::getcolor($bgcolor);
imageFilledRectangle(self::$_image, 0, 0, $width, $height, $back);
$size = $width / $len;
if ($size > $height) {
$size = $height;
}
$left = ($width - $len * ($size + $size / 10)) / $size;
for ($i = 0; $i < $len; $i++) {
$randtext = self::vchar();
self::$_code .= $randtext;
$textColor = imageColorAllocate(self::$_image, rand(0, 100), rand(0, 100), rand(0, 100));
$font = dirname(__FILE__) . "/3.ttf";
$randsize = rand($size - $size / 5, $size - $size / 10);
$location = $left + ($i * $size + $size / 10);
imagettftext(self::$_image, $randsize, rand(-18, 18), $location, rand($size - $size / 100, $size + $size / 100), $textColor, $font, $randtext);
}
if ($noise == true) {
self::setnoise();
}
self::setCode(self::$_code);
//setrawcookie("code",$code,time()+3600,"/");
//setcookie("code", $code, time()+120);
$bordercolor = self::getcolor($bordercolor);
if ($border == true) {
imageRectangle(self::$_image, 0, 0, $width - 1, $height - 1, $bordercolor);
}
return self::$_image;
}
示例9: show
/**
* 显示验证码
*
*/
function show()
{
$this->image = imageCreate($this->width, $this->height);
$this->back = $this->getColor($this->bgcolor);
imageFilledRectangle($this->image, 0, 0, $this->width, $this->height, $this->back);
$size = $this->width / $this->charLen - 4;
if ($size > $this->height) {
$size = $this->height;
}
$left = ($this->width - $this->charLen * ($size + $size / 10)) / $size + 5;
$code = '';
for ($i = 0; $i < $this->charLen; $i++) {
$randKey = rand(0, count($this->arrChr) - 1);
$randText = $this->arrChr[$randKey];
$code .= $randText;
$textColor = imageColorAllocate($this->image, rand(0, 100), rand(0, 100), rand(0, 100));
$font = $this->fontPath . "1.ttf";
$randsize = rand($size - $size / 10, $size + $size / 10);
$location = $left + ($i * $size + $size / 10);
imagestring($this->image, mt_rand(3, 5), $location, 5, $randText, imagecolorallocate($this->image, mt_rand(0, 100), mt_rand(0, 150), mt_rand(0, 200)));
//imagettftext($this->image, $randsize, rand(- 18, 18), $location, rand($size - $size / 10, $size + $size / 10) + 2, $textColor, $font, $code);
}
if ($this->showNoisePix == true) {
$this->setNoisePix();
}
if ($this->showNoiseLine == true) {
$this->setNoiseLine();
}
if ($this->showBorder == true) {
$this->borderColor = $this->getColor($this->borderColor);
imageRectangle($this->image, 0, 0, $this->width - 1, $this->height - 1, $this->borderColor);
}
$this->CI->session->set_userdata('auth_code', $code);
ob_clean();
header("Content-type: image/jpeg");
imagejpeg($this->image);
imagedestroy($this->image);
}
示例10: elseif
}
} elseif ($sig_level < $configData['expbar_max_level'] || !$configData['expbar_max_hidden']) {
// Variables to get and hold eXP bar data
$outexp = printXP($sig_exp);
$outperc = retPerc($sig_exp, $configData['expbar_loc_x'], $configData['expbar_length']);
// Fix eXp bar text alignment
if ($configData['expbar_align'] == 'center') {
$exp_text_loc = $x_end - $configData['expbar_length'] / 2;
} elseif ($configData['expbar_align'] == 'right') {
$exp_text_loc = $x_end - 3;
} else {
$exp_text_loc = $configData['expbar_loc_x'] + 3;
}
// The eXP bar (outside border)
if ($configData['expbar_disp_bdr']) {
@imageRectangle($im, $configData['expbar_loc_x'] - 1, $configData['expbar_loc_y'] - 1, $x_end + 1, $y_end + 1, setColor($im, $configData['expbar_color_border'], $configData['expbar_trans_border'])) or debugMode(__LINE__, $php_errormsg);
}
// The eXP bar (inside box)
if ($configData['expbar_disp_inside']) {
@imageFilledRectangle($im, $configData['expbar_loc_x'], $configData['expbar_loc_y'], $x_end, $y_end, setColor($im, $configData['expbar_color_inside'], $configData['expbar_trans_inside'])) or debugMode(__LINE__, $php_errormsg);
}
// The progress bar
@imageFilledRectangle($im, $configData['expbar_loc_x'], $configData['expbar_loc_y'], $outperc, $y_end, setColor($im, $configData['expbar_color_bar'], $configData['expbar_trans_bar'])) or debugMode(__LINE__, $php_errormsg);
// eXpbar text
if ($configData['expbar_disp_text']) {
writeText($im, $configData['expbar_font_size'], $exp_text_loc, $y_end - 1, $configData['expbar_font_color'], $configData['expbar_font_name'], $configData['expbar_string_before'] . $outexp . $configData['expbar_string_after'], $configData['expbar_align'], $configData['expbar_text_shadow']);
}
}
}
#--[ PLACE DYNAMIC TEXT IN THE IMAGE ]-------------------------------------
// Place the Character's Name
示例11: imageCreateTrueColor
/* Создание изображения */
// $i = imageCreate(500, 300);
$i = imageCreateTrueColor(500, 300);
/* Подготовка к работе */
imageAntiAlias($i, true);
$red = imageColorAllocate($i, 255, 0, 0);
$white = imageColorAllocate($i, 0xff, 0xff, 0xff);
$black = imageColorAllocate($i, 0, 0, 0);
$green = imageColorAllocate($i, 0, 255, 0);
$blue = imageColorAllocate($i, 0, 0, 255);
$grey = imageColorAllocate($i, 192, 192, 192);
imageFill($i, 0, 0, $grey);
/* Рисуем примитивы */
imageSetPixel($i, 10, 10, $black);
imageLine($i, 20, 20, 280, 180, $red);
imageRectangle($i, 20, 20, 280, 180, $blue);
//array of dots
$points = [120, 120, 100, 200, 300, 200];
imagePolygon($i, $points, 3, $green);
imageEllipse($i, 200, 150, 300, 200, $red);
// imageArc($i, 210, 160, 300, 200, 0, 90, $black);
imageFilledArc($i, 200, 150, 300, 200, 0, 40, $red, IMG_ARC_PIE);
/* Рисуем текст */
imageString($i, 5, 150, 200, 'php7', $black);
imageCharUp($i, 3, 200, 200, 'PHP5', $blue);
imageTtfText($i, 30, 10, 300, 150, $green, 'arial.ttf', 'PHP7');
/* Отдаем изображение */
// header("Content-type: image/gif");
// imageGif($i);
header("Content-type: image/png");
imagePng($i);
示例12: border2
public function border2($color = 0x0)
{
return imageRectangle($this->res, $this->offsetX, $this->offsetY, $this->sW + $this->offsetX, $this->sH + $this->offsetY, $this->hex2color($color));
}
示例13: array
* GNU General Public License as published by the Free Software Foundation, either version 3 of *
* the License, or (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, see <http://www.gnu.org/licenses/>. *
**************************************************************************************************/
$alphabeth = array();
for ($i = ord('a'); $i <= ord('z'); $i++) {
array_push($alphabeth, chr($i));
}
for ($i = 0; $i <= 9; $i++) {
array_push($alphabeth, $i);
}
$key = 'lolasd';
$randstr = '';
$cyph = urldecode(base64_decode($_GET['str']));
for ($i = 0; $i < 6; $i++) {
$randstr .= $cyph[$i] ^ $key[$i % 6];
}
$img = imageCreate(60, 30);
$black = imageColorAllocate($img, 0, 0, 0);
$white = imageColorAllocate($img, 255, 255, 255);
imageRectangle($img, 0, 0, 99, 49, $white);
imageString($img, 5, 2, 10, $randstr, $white);
header("Content-type: image/png");
imagePng($img);
imageDestroy($img);
?>
示例14: rand
for ($i = 0; $i < $len; $i++) {
$randtext = rand(0, 9);
$code .= $randtext;
$textColor = imageColorAllocate($image, rand(0, 100), rand(0, 100), rand(0, 100));
$font = rand(1, 4) . ".ttf";
$randsize = rand($size - $size / 10, $size + $size / 10);
$location = $left + ($i * $size + $size / 10);
imagettftext($image, $randsize, rand(-18, 18), $location, rand($size - $size / 10, $size + $size / 10), $textColor, $font, $randtext);
}
if ($noise == true) {
setnoise();
}
$_SESSION['cv_yzm'] = $code;
$bordercolor = getcolor($bordercolor);
if ($border == true) {
imageRectangle($image, 0, 0, $width - 1, $height - 1, $bordercolor);
}
header("Content-type: image/png");
imagePng($image);
imagedestroy($image);
function getcolor($color)
{
global $image;
$color = eregi_replace("^#", "", $color);
$r = $color[0] . $color[1];
$r = hexdec($r);
$b = $color[2] . $color[3];
$b = hexdec($b);
$g = $color[4] . $color[5];
$g = hexdec($g);
$color = imagecolorallocate($image, $r, $b, $g);
示例15: draw_rectangle
function draw_rectangle($x1, $y1, $x2, $y2, $color, $filled)
{
if ($filled) {
imageFilledRectangle($this->image, $x1, $y1, $x2, $y2, $color);
} else {
imageRectangle($this->image, $x1, $y1, $x2, $y2, $color);
}
}