本文整理汇总了PHP中imageellipse函数的典型用法代码示例。如果您正苦于以下问题:PHP imageellipse函数的具体用法?PHP imageellipse怎么用?PHP imageellipse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imageellipse函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: circle
protected static function circle($params)
{
$borderColor = isset($params['borderColor']) ? $params['borderColor'] : null;
$bgColor = isset($params['bgColor']) ? $params['bgColor'] : null;
$bgColorFigure = isset($params['bgColorFigure']) ? $params['bgColorFigure'] : null;
$indent = $params['diametr'] / 2 + 1;
// Размер картинки с отступами
$im = imagecreatetruecolor($params['diametr'], $params['diametr']);
// Устанавливаем цвет границ
if ($borderColor) {
$border = imagecolorallocate($im, $borderColor[0], $borderColor[1], $borderColor[2]);
}
// Устанавливаем заливку поля
if (empty($params['transparent'])) {
$bg = imagecolorallocate($im, $bgColor[0], $bgColor[1], $bgColor[2]);
} else {
$bg = imagecolorallocatealpha($im, 0, 0, 0, 127);
}
// Устанавливаем заливку круга
$bgCircle = imagecolorallocate($im, $bgColorFigure[0], $bgColorFigure[1], $bgColorFigure[2]);
imagefill($im, 1, 1, $bg);
imagesavealpha($im, TRUE);
// Рисуем круг
imagefilledellipse($im, $indent - 1, $indent - 1, $params['diametr'] - 1, $params['diametr'] - 1, $bgCircle);
if ($borderColor) {
imageellipse($im, $indent - 1, $indent - 1, $params['diametr'] - 1, $params['diametr'] - 1, $border);
}
// Выводим изображение
imagepng($im);
}
示例2: smart_spam
function smart_spam($code)
{
@putenv('GDFONTPATH=' . realpath('.'));
$font = 'FONT.TTF';
// antispam image height
$height = 40;
// antispam image width
$width = 110;
$font_size = $height * 0.6;
$image = @imagecreate($width, $height);
$background_color = @imagecolorallocate($image, 255, 255, 255);
$noise_color = @imagecolorallocate($image, 20, 40, 100);
/* add image noise */
for ($i = 0; $i < $width * $height / 4; $i++) {
@imageellipse($image, mt_rand(0, $width), mt_rand(0, $height), 1, 1, $noise_color);
}
/* render text */
$text_color = @imagecolorallocate($image, 20, 40, 100);
@imagettftext($image, $font_size, 0, 7, 29, $text_color, $font, $code) or die('Cannot render TTF text.');
//output image to the browser *//*
header('Content-Type: image/png');
@imagepng($image) or die('imagepng error!');
@imagedestroy($image);
exit;
}
示例3: ellipse
public function ellipse(Point $center, $width, $height, $filled = FALSE, Color $color = NULL)
{
if (!$center->isInImage($this)) {
throw new IllegalArgumentException();
}
$filled == TRUE ? imagefilledellipse($this->imageResource, $center->getX(), $center->getY(), $width, $height, $this->prepareColor($color)) : imageellipse($this->imageResource, $center->getX(), $center->getY(), $width, $height, $this->prepareColor($color));
}
示例4: draw
public function draw($dimension = 100)
{
$dimension = $this->reDim($dimension);
$Center = $dimension / 2;
$ScaleFactor = $dimension / max($this->Sizes);
$image = imagecreatetruecolor($dimension, $dimension);
imagefill($image, 0, 0, imagecolorallocate($image, 255, 255, 244));
for ($i = 0; $i < count($this->Sizes); $i++) {
$ArrowDiameter = ceil($dimension / 20);
}
foreach ($this->Sizes as $key => $value) {
$diameter = $value * $ScaleFactor;
//$ArrowDiameter=min($diameter,$ArrowDiameter);
$color = imagecolorallocate($image, $this->Colors[$key][0], $this->Colors[$key][1], $this->Colors[$key][2]);
$bordercolor = imagecolorallocate($image, $this->BorderColors[$key][0], $this->BorderColors[$key][1], $this->BorderColors[$key][2]);
imagefilledellipse($image, $Center, $Center, $diameter, $diameter, $color);
imageellipse($image, $Center, $Center, $diameter, $diameter, $bordercolor);
}
//$ArrowDiameter=max($dimension/25, $ArrowDiameter/2);
$color = imagecolorallocate($image, 64, 255, 64);
foreach ($this->ArrowPos as $pos) {
if (preg_match("/^[\\-0-9]*,[\\-0-9]*\$/", $pos)) {
list($x, $y) = explode(',', $pos);
$x = $dimension / 2 + $x * $dimension / 2000;
$y = $dimension / 2 + $y * $dimension / 2000;
imagefilledellipse($image, $x, $y, $ArrowDiameter, $ArrowDiameter, $color);
imageellipse($image, $x, $y, $ArrowDiameter, $ArrowDiameter, $bordercolor);
}
}
header("Content-type: image/png");
imagepng($image);
imagedestroy($image);
}
示例5: _drawLine
private function _drawLine($image, $x1, $y1, $x2, $y2)
{
$thick = $this->_thickness->getThickness();
$color = $this->_getDrawColor($image);
if ($thick == 1) {
return imageline($image, $x1, $y1, $x2, $y2, $color);
}
if ($this->hasTransparency() && $this->_transparency->getTransparency() != ParamTransparency::$minAlpha) {
$t = $thick / 2 - 0.5;
if ($x1 == $x2 || $y1 == $y2) {
return imagefilledrectangle($image, round(min($x1, $x2) - $t), round(min($y1, $y2) - $t), round(max($x1, $x2) + $t), round(max($y1, $y2) + $t), $color);
}
$k = ($y2 - $y1) / ($x2 - $x1);
//y = kx + q
$a = $t / sqrt(1 + pow($k, 2));
$points = array(round($x1 - (1 + $k) * $a), round($y1 + (1 - $k) * $a), round($x1 - (1 - $k) * $a), round($y1 - (1 + $k) * $a), round($x2 + (1 + $k) * $a), round($y2 - (1 - $k) * $a), round($x2 + (1 - $k) * $a), round($y2 + (1 + $k) * $a));
imagefilledpolygon($image, $points, 4, $color);
imagepolygon($image, $points, 4, $color);
} else {
imagesetthickness($image, $thick);
imageline($image, $x1, $y1, $x2, $y2, $color);
imagesetthickness($image, 1);
imagefilledellipse($image, $x1, $y1, $thick, $thick, $color);
imagefilledellipse($image, $x2, $y2, $thick, $thick, $color);
imageellipse($image, $x1, $y1, $thick, $thick, $color);
imageellipse($image, $x2, $y2, $thick, $thick, $color);
}
}
示例6: printImage
function printImage()
{
// Définition du content-type
header("Content-type: image/png");
$grey = imagecolorallocate($this->image, 200, 196, 196);
$white = imagecolorallocate($this->image, 255, 255, 255);
$black = imagecolorallocate($this->image, 0, 0, 0);
imagefilledrectangle($this->image, 0, 0, $this->size, 50, $white);
$font = 'agenda__.ttf';
// dessinons quelques eclipses ;)
for ($t = 0; $t <= 20; $t++) {
imageellipse($this->image, rand(0, $this->size), rand(0, 50), rand(0, 200), rand(0, 200), $grey);
}
// centrage du texte
$maxWord = ($this->size - 30) / 27;
$cur_left = strlen($this->text) == $maxWord ? 15 : 15 + ($maxWord - strlen($this->text)) * 27 / 2;
for ($t = 0; isset($this->text[$t]); $t++) {
$cur_incli = rand(-20, 20);
// ombre
imagettftext($this->image, 32, $cur_incli, $cur_left, 40, $black, $font, $this->text[$t]);
// texte
imagettftext($this->image, 32, $cur_incli, $cur_left - 1, 39, $this->colours[array_rand($this->colours)], $font, $this->text[$t]);
$cur_left += 27;
}
imagepng($this->image);
imagedestroy($this->image);
}
示例7: CaptchaSecurityImages
function CaptchaSecurityImages($width = '120', $height = '40', $characters = '6')
{
$code = $this->generateCode($characters);
/* font size will be 75% of the image height */
$font_size = $height * 0.75;
$image = @imagecreate($width, $height) or die('Cannot initialize new GD image stream');
/* set the colours */
$background_color = imagecolorallocate($image, 255, 255, 255);
$text_color = imagecolorallocate($image, 0, 0, 0);
$noise_color = imagecolorallocate($image, 226, 82, 207);
$noise_color1 = imagecolorallocate($image, 64, 179, 255);
$noise_color2 = imagecolorallocate($image, 255, 204, 190);
/* generate random dots in background */
for ($i = 0; $i < $width * $height / 250; $i++) {
imageellipse($image, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), $noise_color2);
}
/* generate random dots in background */
for ($i = 0; $i < $width * $height / 150; $i++) {
imagedashedline($image, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), $noise_color1);
}
/* generate random lines in background */
for ($i = 0; $i < $width * $height / 150; $i++) {
imagedashedline($image, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), $noise_color);
}
/* create textbox and add text */
$textbox = imagettfbbox($font_size, 0, $this->font, $code) or die('Error in imagettfbbox function');
$x = ($width - $textbox[4]) / 2;
$y = ($height - $textbox[5]) / 2;
imagettftext($image, $font_size, 0, $x, $y, $text_color, $this->font, $code) or die('Error in imagettftext function');
/* output captcha image to browser */
imagejpeg($image);
imagedestroy($image);
$_SESSION['security_code'] = $code;
}
示例8: perform
/**
* Draws an ellipse on the handle
*
* @param GD-object $handle The handle on which the ellipse is drawn
* @param Zend_Image_Action_DrawEllipse $ellipseObject The object that with all info
*/
public function perform($handle, Zend_Image_Action_DrawEllipse $ellipseObject) { // As of ZF2.0 / PHP5.3, this can be made static.
if($ellipseObject->filled()){
$color = $ellipseObject->getFillColor()->getRgb();
$alpha = $ellipseObject->getFillAlpha();
}else{
$color = $ellipseObject->getStrokeColor()->getRgb();
$alpha = $ellipseObject->getStrokeAlpha();
}
$colorAlphaAlloc = imagecolorallocatealpha($handle->getHandle(),
$color['red'],
$color['green'],
$color['blue'],
127 - $alpha * 1.27);
if($ellipseObject->filled()) {
imagefilledellipse($handle->getHandle(),
$ellipseObject->getLocation()->getX(),
$ellipseObject->getLocation()->getY(),
$ellipseObject->getWidth(),
$ellipseObject->getHeight(),
$colorAlphaAlloc);
} else {
imageellipse($handle->getHandle(),
$ellipseObject->getLocation()->getX(),
$ellipseObject->getLocation()->getY(),
$ellipseObject->getWidth(),
$ellipseObject->getHeight(),
$colorAlphaAlloc);
}
}
示例9: drawdot
function drawdot($coords, $tipo, $valor)
{
global $im, $mapHTML, $inner_text, $linecolor;
imageline($im, $coords[0], $coords[1], $coords[2], $coords[3], $linecolor[$tipo]);
imageellipse($im, $coords[0], $coords[1], 3, 3, $linecolor);
imagestring($im, 1, $coords[0] + 2, $coords[1] + 3, $valor, $inner_text);
}
示例10: gerImage
function gerImage()
{
# Calcular tamanho para caber texto
$this->w = $this->numChars * $this->charx + 40;
#5px de cada lado, 4px por char
# Criar img
$this->im = imagecreatetruecolor($this->w, $this->h);
#desenhar borda e fundo
imagefill($this->im, 0, 0, $this->getColor($this->colBorder));
imagefilledrectangle($this->im, 1, 1, $this->w - 2, $this->h - 2, $this->getColor($this->colBG));
#desenhar circulos
for ($i = 1; $i <= $this->numCirculos; $i++) {
$randomcolor = imagecolorallocate($this->im, rand(120, 255), rand(120, 255), rand(120, 255));
imageellipse($this->im, rand(0, $this->w - 10), rand(0, $this->h - 3), rand(20, 60), rand(20, 60), $randomcolor);
}
#escrever texto
$ident = 20;
for ($i = 0; $i < $this->numChars; $i++) {
$char = substr($this->texto, $i, 1);
$font = rand(5, 5);
$y = round(($this->h - 15) / 4);
$col = $this->getColor($this->colTxt);
if ($i % 4 == 0) {
imagechar($this->im, $font, $ident, $y, $char, $col);
} else {
imagechar($this->im, $font, $ident, $y + rand(3, 18), $char, $col);
}
$ident = $ident + $this->charx;
}
}
示例11: generateImage
/**
* Private function for creating a random image.
*
* This function only works with the GD toolkit. ImageMagick is not supported.
*/
protected function generateImage($extension = 'png', $min_resolution, $max_resolution)
{
if ($tmp_file = drupal_tempnam('temporary://', 'imagefield_')) {
$destination = $tmp_file . '.' . $extension;
file_unmanaged_move($tmp_file, $destination, FILE_CREATE_DIRECTORY);
$min = explode('x', $min_resolution);
$max = explode('x', $max_resolution);
$width = rand((int) $min[0], (int) $max[0]);
$height = rand((int) $min[1], (int) $max[1]);
// Make an image split into 4 sections with random colors.
$im = imagecreate($width, $height);
for ($n = 0; $n < 4; $n++) {
$color = imagecolorallocate($im, rand(0, 255), rand(0, 255), rand(0, 255));
$x = $width / 2 * ($n % 2);
$y = $height / 2 * (int) ($n >= 2);
imagefilledrectangle($im, $x, $y, $x + $width / 2, $y + $height / 2, $color);
}
// Make a perfect circle in the image middle.
$color = imagecolorallocate($im, rand(0, 255), rand(0, 255), rand(0, 255));
$smaller_dimension = min($width, $height);
$smaller_dimension = $smaller_dimension % 2 ? $smaller_dimension : $smaller_dimension;
imageellipse($im, $width / 2, $height / 2, $smaller_dimension, $smaller_dimension, $color);
$save_function = 'image' . ($extension == 'jpg' ? 'jpeg' : $extension);
$save_function($im, drupal_realpath($destination));
return $destination;
}
}
示例12: generate
public function generate()
{
foreach ($this->__shapes as $shape) {
$type = array_shift($shape);
$color = array_shift($shape);
$color = $this->_owner->imagecolorallocate(!isset($color) || is_null($color) ? $this->__base_color : $color, $this->__base_alpha);
switch ($type) {
case self::LINE:
imageline($this->_owner->image, $shape[0], $shape[1], $shape[2], $shape[3], $color);
break;
case self::RECTANGLE:
imagerectangle($this->_owner->image, $shape[0], $shape[1], $shape[2], $shape[3], $color);
break;
case self::FILLED_RECTANGLE:
imagefilledrectangle($this->_owner->image, $shape[0], $shape[1], $shape[2], $shape[3], $color);
break;
case self::ELLIPSE:
imageellipse($this->_owner->image, $shape[0], $shape[1], $shape[2], $shape[3], $color);
break;
case self::FILLED_ELLIPSE:
imagefilledellipse($this->_owner->image, $shape[0], $shape[1], $shape[2], $shape[3], $color);
break;
case self::SPIRAL:
$angle = $r = 0;
while ($r <= $shape[2]) {
imagearc($this->_owner->image, $shape[0], $shape[1], $r, $r, $angle - $shape[3], $angle, $color);
$angle += $shape[3];
$r++;
}
break;
}
}
return true;
}
示例13: store_map
function store_map($im, $data, $shape, $row, $col, $x, $y)
{
static $color = NULL;
if (!isset($color)) {
$color = imagecolorallocate($im, 255, 0, 0);
}
imageellipse($im, $x, $y, 12, 12, $color);
}
示例14: store_map
function store_map($im, $passthru, $shape, $row, $col, $xc, $yc, $diam)
{
static $color = NULL;
if (!isset($color)) {
$color = imagecolorallocate($im, 255, 0, 0);
}
imageellipse($im, $xc, $yc, $diam, $diam, $color);
}
示例15: applyToImage
/**
* Draw ellipse instance on given image
*
* @param Image $image
* @param integer $x
* @param integer $y
* @return boolean
*/
public function applyToImage(Image $image, $x = 0, $y = 0)
{
$background = new Color($this->background);
imagefilledellipse($image->getCore(), $x, $y, $this->width, $this->height, $background->getInt());
if ($this->hasBorder()) {
$border_color = new Color($this->border_color);
imagesetthickness($image->getCore(), $this->border_width);
imageellipse($image->getCore(), $x, $y, $this->width, $this->height, $border_color->getInt());
}
return true;
}