本文整理汇总了PHP中imagesetthickness函数的典型用法代码示例。如果您正苦于以下问题:PHP imagesetthickness函数的具体用法?PHP imagesetthickness怎么用?PHP imagesetthickness使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imagesetthickness函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* Outputs the Captcha image.
*
* @param boolean html output
* @return mixed
*/
public function render($html)
{
// Creates a black image to start from
$this->image_create(Captcha::$config['background']);
// Add random white/gray arcs, amount depends on complexity setting
$count = (Captcha::$config['width'] + Captcha::$config['height']) / 2;
$count = $count / 5 * min(10, Captcha::$config['complexity']);
for ($i = 0; $i < $count; $i++) {
imagesetthickness($this->image, mt_rand(1, 2));
$color = imagecolorallocatealpha($this->image, 255, 255, 255, mt_rand(0, 120));
imagearc($this->image, mt_rand(-Captcha::$config['width'], Captcha::$config['width']), mt_rand(-Captcha::$config['height'], Captcha::$config['height']), mt_rand(-Captcha::$config['width'], Captcha::$config['width']), mt_rand(-Captcha::$config['height'], Captcha::$config['height']), mt_rand(0, 360), mt_rand(0, 360), $color);
}
// Use different fonts if available
$font = Captcha::$config['fontpath'] . Captcha::$config['fonts'][array_rand(Captcha::$config['fonts'])];
// Draw the character's white shadows
$size = (int) min(Captcha::$config['height'] / 2, Captcha::$config['width'] * 0.8 / strlen($this->response));
$angle = mt_rand(-15 + strlen($this->response), 15 - strlen($this->response));
$x = mt_rand(1, Captcha::$config['width'] * 0.9 - $size * strlen($this->response));
$y = (Captcha::$config['height'] - $size) / 2 + $size;
$color = imagecolorallocate($this->image, 255, 255, 255);
imagefttext($this->image, $size, $angle, $x + 1, $y + 1, $color, $font, $this->response);
// Add more shadows for lower complexities
Captcha::$config['complexity'] < 10 and imagefttext($this->image, $size, $angle, $x - 1, $y - 1, $color, $font, $this->response);
Captcha::$config['complexity'] < 8 and imagefttext($this->image, $size, $angle, $x - 2, $y + 2, $color, $font, $this->response);
Captcha::$config['complexity'] < 6 and imagefttext($this->image, $size, $angle, $x + 2, $y - 2, $color, $font, $this->response);
Captcha::$config['complexity'] < 4 and imagefttext($this->image, $size, $angle, $x + 3, $y + 3, $color, $font, $this->response);
Captcha::$config['complexity'] < 2 and imagefttext($this->image, $size, $angle, $x - 3, $y - 3, $color, $font, $this->response);
// Finally draw the foreground characters
$color = imagecolorallocate($this->image, 0, 0, 0);
imagefttext($this->image, $size, $angle, $x, $y, $color, $font, $this->response);
// Output
return $this->image_render($html);
}
示例2: apply
public function apply($resource)
{
// Extract arguments
@(list(, $x1, $y1, $x2, $y2, $thickness, $color) = func_get_args());
$x1 = (int) $x1;
$y1 = (int) $y1;
$x2 = (int) $x2;
$y2 = (int) $y2;
$thickness = (int) $thickness;
if (!$color) {
$color = '#000000';
}
$rgb = html2rgb($color);
if ($thickness < 1) {
$thickness = 1;
}
// Draw line
if (!imagesetthickness($resource, $thickness)) {
throw new Exception("Thickness line changing failed");
}
if (!imageline($resource, $x1, $y1, $x2, $y2, imagecolorallocate($resource, $rgb[0], $rgb[1], $rgb[2]))) {
throw new Exception("Line drawing failed");
}
return $resource;
}
示例3: _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);
}
}
示例4: check
function check($len = 4)
{
session_start();
header('content-type:image/png');
$fs = ['/a.ttf', '/b.ttf', '/f.ttf'];
$font = dirname(__FILE__) . $fs[mt_rand(0, 1)];
$w = 35 * $len;
$h = 50;
$i = imagecreatetruecolor($w, $h);
$c = imagecolorallocatealpha($i, 0, 0, 0, 127);
//imagecolortransparent($i,$c);
//imagefill($i,0,0,$c);
imagefilledrectangle($i, 0, 0, $w, $h, gc($i, 'ffffff', mt_rand(0, 2)));
$sss = '';
for ($j = 0; $j < $len; $j++) {
$st = gs(1);
$sss .= $st;
imagettftext($i, mt_rand(15, 25), mt_rand(-30, 30), $j * 35 + 10, mt_rand(28, 38), gc($i), $font, $st);
}
$_SESSION['code'] = $sss;
imagesetthickness($i, mt_rand(2, 8));
for ($j = 0; $j < mt_rand(5, 10); $j++) {
imagefilledarc($i, mt_rand(0, $w), mt_rand(0, $h), mt_rand(0, $w), mt_rand(0, $h), mt_rand(0, 360), mt_rand(0, 360), gc($i, 'rand', mt_rand(100, 120)), IMG_ARC_NOFILL);
}
for ($j = 0; $j < 10; $j++) {
imagettftext($i, mt_rand(10, 15), mt_rand(-5, 5), mt_rand(0, $w), mt_rand(0, $h), gc($i, 'rand', mt_rand(100, 120)), $font, gs(1));
}
imagepng($i);
imagedestroy($i);
}
示例5: makeGraphicalCaptcha
/**
* Makes a graphical captcha from the provided text string
*
* @param string $captcha_text string to make image captcha from
* @return string $data_url a data url containing the obfuscated image
*/
function makeGraphicalCaptcha($captcha_text)
{
$image = @imagecreatetruecolor(195, 35);
// defines background color, random lines color and text color
$bg_color = imagecolorallocate($image, mt_rand(0, 255), 255, 0);
imagefill($image, 0, 0, $bg_color);
$lines_color = imagecolorallocate($image, 0x99, 0xcc, 0x99);
$text_color = imagecolorallocate($image, mt_rand(0, 255), 0, 255);
// draws random lines
for ($i = 0; $i < 4; $i++) {
imageline($image, 0, rand(0, 35), 195, rand(0, 35), $lines_color);
}
$captcha_letter_array = str_split($captcha_text);
foreach ($captcha_letter_array as $i => $captcha_letter) {
imagesetthickness($image, 1);
imagestring($image, 5, 5 + $i * 35, rand(2, 14), $captcha_letter, $text_color);
}
// creates image
ob_start();
imagejpeg($image);
$image_data = ob_get_contents();
ob_end_clean();
$data_url = "data:image/jpeg;base64," . base64_encode($image_data);
imagedestroy($image);
return $data_url;
}
示例6: showImage
/**
* renders the current captcha image
*/
function showImage()
{
$image = imagecreatetruecolor($this->width, $this->height);
$width = imagesx($image);
$height = imagesy($image);
$black = imagecolorallocate($image, 0, 0, 0);
$white = imagecolorallocate($image, 250, 250, 250);
$red = imagecolorallocatealpha($image, 225, 225, 225, 75);
$green = imagecolorallocatealpha($image, 150, 150, 150, 75);
$blue = imagecolorallocatealpha($image, 200, 200, 200, 75);
imagefilledrectangle($image, 0, 0, $width, $height, $white);
imagefilledellipse($image, ceil(rand(5, 145)), ceil(rand(0, 35)), 30, 30, $red);
$points = array(rand(0, 150), rand(0, 50), rand(0, 150), rand(0, 50), rand(0, 150), rand(0, 50), rand(0, 150), rand(0, 50), rand(0, 150), rand(0, 50), rand(0, 150), rand(0, 50));
imagefilledpolygon($image, $points, 4, $blue);
imagefilledpolygon($image, array_reverse($points), 6, $green);
imagefilledrectangle($image, 0, 0, $width, 0, $black);
imagefilledrectangle($image, $width - 1, 0, $width - 1, $height - 1, $black);
imagefilledrectangle($image, 0, 0, 0, $height - 1, $black);
imagefilledrectangle($image, 0, $height - 1, $width, $height - 1, $black);
for ($i = 0; $i < 50; $i++) {
//imagefilledrectangle($im, $i + $i2, 5, $i + $i3, 70, $black);
imagesetthickness($image, rand(1, 5));
imagearc($image, rand(1, 150), rand(1, 50), rand(1, 150), rand(1, 50), rand(1, 150), rand(1, 50), rand(0, 1) ? $green : $red);
}
if (function_exists("imagettftext")) {
$font = DIR_ROOT . 'view/fonts/Duality.ttf';
imagettftext($image, 24, rand(-5, 5), intval(($width - strlen($this->code) * 10) / 2), intval(($height + 10) / 2), $black, $font, $this->code);
} else {
imagestring($image, 5, intval(($width - strlen($this->code) * 9) / 2), intval(($height - 15) / 2), $this->code, $black);
}
header('Content-type: image/jpeg');
imagejpeg($image);
imagedestroy($image);
}
示例7: creat_line
private function creat_line()
{
imagesetthickness($this->img, 3);
$xpos = $this->size * 2 + rand(-5, 5);
$width = $this->width / 2.66 + rand(3, 10);
$height = $this->size * 2.14;
if (rand(0, 100) % 2 == 0) {
$start = rand(0, 66);
$ypos = $this->height / 2 - rand(10, 30);
$xpos += rand(5, 15);
} else {
$start = rand(180, 246);
$ypos = $this->height / 2 + rand(10, 30);
}
$end = $start + rand(75, 110);
imagearc($this->img, $xpos, $ypos, $width, $height, $start, $end, $this->color);
if (rand(1, 75) % 2 == 0) {
$start = rand(45, 111);
$ypos = $this->height / 2 - rand(10, 30);
$xpos += rand(5, 15);
} else {
$start = rand(200, 250);
$ypos = $this->height / 2 + rand(10, 30);
}
$end = $start + rand(75, 100);
imagearc($this->img, $this->width * 0.75, $ypos, $width, $height, $start, $end, $this->color);
}
示例8: drawLine
function drawLine()
{
//header('Content-type: image/png');
$png_image = imagecreate(150, 150);
imagecolorallocate($png_image, 15, 142, 210);
imagesetthickness($png_image, 5);
$black = imagecolorallocate($png_image, 0, 0, 0);
$x = 0;
$y = 0;
$w = imagesx($png_image) - 1;
$z = imagesy($png_image) - 1;
// Rectangle
// imageline ($image, $x1, $y1, $x2, $y2, $color)
imageline($png_image, $x, $y, $x, $y + $z, $black);
imageline($png_image, $x, $y, $x + $w, $y, $black);
imageline($png_image, $x + $w, $y, $x + $w, $y + $z, $black);
imageline($png_image, $x, $y + $z, $x + $w, $y + $z, $black);
// Lines
imageline($png_image, $x, $y, $w, $z, $black);
imagepng($png_image, 'simpletext.png');
//imagepng($png_image);
imagedestroy($png_image);
$imgNumber = new NumberImage(1, 50, 50, 10);
$imgNumber->setFileName("jedan");
$imgNumber->drawNumberLineImage();
}
示例9: generate_image
function generate_image($canvas)
{
global $captcha_font_path, $captcha_img_path;
imagesetthickness($canvas, 1);
//$rand = preg_replace("/([0-9])/e","chr((\\1+112))",rand(100000,999999));
$var = rand(0, 1);
$color = imagecolorallocate($canvas, rand(100, 255), rand(100, 255), rand(100, 255));
$liney = rand(3, 6);
$linex = rand(6, 12);
for ($i = $liney; $i > 0; $i--) {
$color = imagecolorallocate($canvas, rand(100, 255), rand(100, 255), rand(100, 255));
// if ($i==0)
// {
// $this->arrow($canvas,10,$i*60/$liney,200,$i*60/$liney, 5, 5, $color );
// }
// else
// {
imageline($canvas, 10, $i * 60 / $liney, 200, $i * 60 / $liney, $color);
// }
imagefttext($canvas, 8, rand(-45, 45), 3, $i * 60 / $liney, $color, $captcha_font_path . "/LiberationMono-Bold.ttf", $liney - $i);
$color = imagecolorallocate($canvas, rand(100, 255), rand(100, 255), rand(100, 255));
}
for ($i = 0; $i < $linex; $i++) {
$color = imagecolorallocate($canvas, rand(100, 255), rand(100, 255), rand(100, 255));
imageline($canvas, 30 + $i * 160 / $linex, 0, 30 + $i * 160 / $linex, 70, $color);
$color = imagecolorallocate($canvas, rand(100, 255), rand(100, 255), rand(100, 255));
imagefttext($canvas, 8, rand(-45, 45), 30 + $i * 160 / $linex, 80, $color, $captcha_font_path . "/LiberationMono-Bold.ttf", $i);
$color = imagecolorallocate($canvas, rand(100, 255), rand(100, 255), rand(100, 255));
}
$color = imagecolorallocate($canvas, rand(100, 255), rand(100, 255), rand(100, 255));
imagesetthickness($canvas, 1);
$x = rand(0, $linex - 1);
$y = rand(0, $liney - 1);
for ($i = -5; $i < 5; $i++) {
$xr = rand(0, $linex);
$color = imagecolorallocate($canvas, rand(100, 255), rand(100, 255), rand(100, 255));
$yr = rand(0, $liney);
imageline($canvas, 30 + $x * 160 / $linex, ($liney - $y) * 60 / $liney, 30 + $xr * 160 / $linex, ($liney - $yr) * 60 / $liney, $color);
}
$color = imagecolorallocate($canvas, rand(100, 255), rand(100, 255), rand(100, 255));
//echo "!".$x."===".$y."!<br>";
if ($var) {
imagefttext($canvas, 20, rand(-45, 45), 40 + 20, 50, $color, $captcha_font_path . "/LiberationMono-Bold.ttf", "y=?");
} else {
imagefttext($canvas, 12, rand(-45, 45), 100, 70, $color, $captcha_font_path . "/LiberationMono-Bold.ttf", "X=?");
}
$nme = $this->ucaptcha->get_filename();
imagepng($canvas);
//imagepng($canvas,$captcha_img_path."/".$nme.".png");
$captcha[0] = $nme;
if ($var) {
$captcha[1] = $y;
$captcha[2] = "Введите координату Y точки, откуда берут начало прямые";
} else {
$captcha[1] = $x;
$captcha[2] = "Введите координату X точки, откуда берут начало прямые";
}
return $captcha;
}
示例10: drawLines
private function drawLines()
{
$lineCnt = mt_rand(4, 8);
for ($i = 0; $i < $lineCnt; $i++) {
imagesetthickness($this->tmpImage, rand(1, 3));
imagearc($this->tmpImage, mt_rand(-10, $this->width), mt_rand(-10, $this->height), mt_rand(30, 300), mt_rand(20, 200), mt_rand(80, 360), mt_rand(0, 300), $this->textColor);
}
}
示例11: draw
/**
* {@inheritdoc}
*/
public final function draw(CanvasInterface $canvas, StyleInterface $style = null)
{
if (!$canvas->isHandlerSet()) {
throw new CanvasEmptyException(sprintf('Can Not Draw Drawable (%s) - Canvas Is Empty', (string) $this));
}
@imagesetthickness($canvas->getHandler(), $this->getLineThickness());
$this->doDraw($canvas, $style);
return $this;
}
示例12: renderStroke
protected function renderStroke($image, array $params, $color, $strokeWidth)
{
imagesetthickness($image, $strokeWidth);
if ($params['open']) {
$this->renderStrokeOpen($image, $params['points'], $color);
return;
}
imagepolygon($image, $params['points'], $params['numpoints'], $color);
}
示例13: randsquare
private function randsquare()
{
imagesetthickness($this->image, 1);
srand($this->make_seed());
$x = rand(0, $this->larguaImagem - 15);
$y = rand(0, $this->alturaImagem - 15);
imageFilledRectangle($this->image, $x, $y, $x + 10, $y + 10, $this->color($this->corRetangulos));
imagerectangle($this->image, $x - 10, $y, $x + 10, $y + 10, $this->randcolor());
}
示例14: drawPolygon
/**
* Draw polygon.
*
* @param array $points An array containing the polygon's vertices.
* @param null|array $options
*/
public function drawPolygon(array $points, array $options = null)
{
$this->setOptions($options);
$colorRgb = Utility::htmlToRgb($this->optionStrokeColor);
$color = $this->allocateColor($this->Resource, $colorRgb['r'], $colorRgb['g'], $colorRgb['b']);
imagesetthickness($this->Resource, $this->optionStrokeWidth);
$numPoints = count($points) / 2;
imagepolygon($this->Resource, $points, $numPoints, $color);
}
示例15: __construct
public function __construct($width, $height)
{
// create a GD image to display results and debug
$this->width = $width;
$this->height = $height;
$this->image = imagecreatetruecolor($width, $height);
$white = imagecolorallocate($this->image, 0xff, 0xff, 0xff);
imagefill($this->image, 0, 0, $white);
imagesetthickness($this->image, 3);
}