本文整理汇总了PHP中ImageArc函数的典型用法代码示例。如果您正苦于以下问题:PHP ImageArc函数的具体用法?PHP ImageArc怎么用?PHP ImageArc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ImageArc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: FilledArc
function FilledArc(&$im, $CenterX, $CenterY, $DiameterX, $DiameterY, $Start, $End, $line_color, $fill_color = 'none')
{
if (gd_version() >= 2.0) {
if ($fill_color != 'none') {
// fill
ImageFilledArc($im, $CenterX, $CenterY, $DiameterX, $DiameterY, $Start, $End, $fill_color, IMG_ARC_PIE);
}
// outline
ImageFilledArc($im, $CenterX, $CenterY, $DiameterX, $DiameterY, $Start, $End, $line_color, IMG_ARC_EDGED | IMG_ARC_NOFILL | IMG_ARC_PIE);
} else {
// cbriou@orange-art.fr
// To draw the arc
ImageArc($im, $CenterX, $CenterY, $DiameterX, $DiameterY, $Start, $End, $line_color);
// To close the arc with 2 lines between the center and the 2 limits of the arc
$x = $CenterX + cos(deg2rad($Start)) * ($DiameterX / 2);
$y = $CenterY + sin(deg2rad($Start)) * ($DiameterY / 2);
ImageLine($im, $x, $y, $CenterX, $CenterY, $line_color);
$x = $CenterX + cos(deg2rad($End)) * ($DiameterX / 2);
$y = $CenterY + sin(deg2rad($End)) * ($DiameterY / 2);
ImageLine($im, $x, $y, $CenterX, $CenterY, $line_color);
if ($fill_color != 'none') {
if ($End - $Start > 0.5) {
// ImageFillToBorder() will flood the wrong parts of the image if the slice is too small
// thanks Jami Lowery <jami@ego-systems.com> for pointing out the problem
// To fill the arc, the starting point is a point in the middle of the closed space
$x = $CenterX + cos(deg2rad(($Start + $End) / 2)) * ($DiameterX / 4);
$y = $CenterY + sin(deg2rad(($Start + $End) / 2)) * ($DiameterY / 4);
ImageFillToBorder($im, $x, $y, $line_color, $fill_color);
}
}
}
}
示例2: create
function create($varDesc, $varValues)
{
Header("Content-type: image/png");
$image = ImageCreate($this->imageWidth, $this->imageHeight);
$bgcolor = ImageColorAllocate($image, $this->bgR, $this->bgG, $this->bgB);
$white = ImageColorAllocate($image, 255, 255, 255);
$black = ImageColorAllocate($image, 0, 0, 0);
ImageFill($image, 0, 0, $bgcolor);
$num = 0;
foreach ($varDesc as $v) {
$r = rand(0, 255);
$g = rand(0, 255);
$b = rand(0, 255);
$sliceColors[$num] = ImageColorAllocate($image, $r, $g, $b);
$num++;
}
// now $num has the number of elements
// draw the box
ImageLine($image, 0, 0, $this->imageWidth - 1, 0, $black);
ImageLine($image, $this->imageWidth - 1, 0, $this->imageWidth - 1, $this->imageHeight - 1, $black);
ImageLine($image, $this->imageWidth - 1, $this->imageHeight - 1, 0, $this->imageHeight - 1, $black);
ImageLine($image, 0, $this->imageHeight - 1, 0, 0, $black);
$total = 0;
for ($x = 0; $x < $num; $x++) {
$total += $varValues[$x];
}
// convert each slice into corresponding percentage of 360-degree circle
for ($x = 0; $x < $num; $x++) {
$angles[$x] = $varValues[$x] / $total * 360;
}
for ($x = 0; $x < $num; $x++) {
// calculate and draw arc corresponding to each slice
ImageArc($image, $this->imageWidth / 4, $this->imageHeight / 2, $this->imageWidth / 3, $this->imageHeight / 3, $angle, $angle + $angles[$x], $sliceColors[$x]);
$angle = $angle + $angles[$x];
$x1 = round($this->imageWidth / 4 + $this->imageWidth / 3 * cos($angle * pi() / 180) / 2);
$y1 = round($this->imageHeight / 2 + $this->imageHeight / 3 * sin($angle * pi() / 180) / 2);
// demarcate slice with another line
ImageLine($image, $this->imageWidth / 4, $this->imageHeight / 2, $x1, $y1, $sliceColors[$x]);
}
// fill in the arcs
$angle = 0;
for ($x = 0; $x < $num; $x++) {
$x1 = round($this->imageWidth / 4 + $this->imageWidth / 3 * cos(($angle + $angles[$x] / 2) * pi() / 180) / 4);
$y1 = round($this->imageHeight / 2 + $this->imageHeight / 3 * sin(($angle + $angles[$x] / 2) * pi() / 180) / 4);
ImageFill($image, $x1, $y1, $sliceColors[$x]);
$angle = $angle + $angles[$x];
}
// put the desc strings
ImageString($image, 5, $this->imageWidth / 2, 60, "Legend", $black);
for ($x = 0; $x < $num; $x++) {
$fl = sprintf("%.2f", $varValues[$x] * 100 / $total);
$str = $varDesc[$x] . " (" . $fl . "%)";
ImageString($image, 3, $this->imageWidth / 2, ($x + 5) * 20, $str, $sliceColors[$x]);
}
// put the title
ImageString($image, 5, 20, 20, $this->title, $black);
ImagePng($image);
ImageDestroy($image);
}
示例3: G
function G($width = 100, $heiht = 37)
{
mt_srand((double) microtime() * 1000000);
if ($this->number) {
$hash = sprintf('%0' . $this->length . 'd', mt_rand(0, pow(10, $this->length) - 1));
} else {
$hash = '';
$chars = 'ABCDEQRSTUVWXYZ23456FGHIJKLMNP789';
$max = strlen($chars) - 1;
for ($i = 0; $i < $this->length; $i++) {
$hash .= $chars[mt_rand(0, $max)];
}
}
$this->session->set_userdata('validecode', strtolower($hash));
$im = imagecreate($width, $heiht);
$backgroundcolor = imagecolorallocate($im, 255, 255, 255);
$numorder = array(1, 2, 3, 4);
shuffle($numorder);
$numorder = array_flip($numorder);
for ($i = 1; $i <= 4; $i++) {
$x = $numorder[$i] * 20 + mt_rand(0, 4) - 2;
$y = mt_rand(2, 12);
$text_color = imagecolorallocate($im, mt_rand(50, 255), mt_rand(50, 128), mt_rand(50, 255));
imagechar($im, 5, $x + 12, $y, $hash[$numorder[$i]], $text_color);
}
$linenums = mt_rand(10, 32);
for ($i = 0; $i < 4; $i++) {
$color1 = ImageColorAllocate($im, mt_rand(100, 255), mt_rand(100, 255), mt_rand(100, 255));
ImageArc($im, mt_rand(-5, $width), mt_rand(-5, $heiht), mt_rand(30, $width), mt_rand(30, $heiht), 55, 44, $color1);
}
for ($i = 0; $i <= $linenums; $i++) {
$linecolor = imagecolorallocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
$linex = mt_rand(0, $width - 2);
$liney = mt_rand(0, $heiht - 2);
imageline($im, $linex, $liney, $linex + mt_rand(0, 4) - 2, $liney + mt_rand(0, 4) - 2, $linecolor);
}
for ($i = 0; $i <= $width - 2; $i++) {
$pointcolor = imagecolorallocate($im, mt_rand(50, 255), mt_rand(50, 255), mt_rand(50, 255));
imagesetpixel($im, mt_rand(0, $width - 2), mt_rand(0, $heiht - 2), $pointcolor);
}
$bordercolor = imagecolorallocate($im, 150, 150, 150);
imagerectangle($im, 0, 0, $width - 2, $heiht - 2, $bordercolor);
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
}
示例4: FilledArc
function FilledArc(&$im, $CenterX, $CenterY, $DiameterX, $DiameterY, $Start, $End, $line_color, $fill_color='none',$key='')
{
ImageArc($im, $CenterX, $CenterY, $DiameterX, $DiameterY, $Start, $End, $line_color);
// To close the arc with 2 lines between the center and the 2 limits of the arc
$x = $CenterX + (cos(deg2rad($Start)) * ($DiameterX / 2));
$y = $CenterY + (sin(deg2rad($Start)) * ($DiameterY / 2));
ImageLine($im, $x, $y, $CenterX, $CenterY, $line_color);
$x = $CenterX + (cos(deg2rad($End)) * ($DiameterX / 2));
$y = $CenterY + (sin(deg2rad($End)) * ($DiameterY / 2));
ImageLine($im, $x, $y, $CenterX, $CenterY, $line_color);
// To fill the arc, the starting point is a point in the middle of the closed space
$x = $CenterX + (cos(deg2rad(($Start + $End) / 2)) * ($DiameterX / 4));
$y = $CenterY + (sin(deg2rad(($Start + $End) / 2)) * ($DiameterY / 4));
ImageFillToBorder($im, $x, $y, $line_color, $fill_color);
// Ainda faltam vários ajustes para escrita do label na vertical... Anderson Peterle => 08/08/2007
if ($key)
imagestringup($im,2,$x,$y,$key,$x);
}
示例5: ImageColorAllocate
$black = ImageColorAllocate($im, 0, 0, 0);
$color[0] = ImageColorAllocate($im, 255, 204, 102); //оранжевый
$color[1] = ImageColorAllocate($im, 51, 204, 0); // «еленый
$color[2] = ImageColorAllocate($im, 0, 102, 152); // темно синий
$color[3] = ImageColorAllocate($im, 255, 0, 0); // красный
$color[4] = ImageColorAllocate($im, 255, 255, 255); // белый
ImageColorTransparent($im, $white);
$sum = $vote1 + $vote2 + $vote3 + $vote4 + $vote5;
$vote1 = ($vote1/$sum)*360;
$vote2 = (($vote2/$sum)*360) + $vote1;
$vote3 = ($vote3/$sum)*360 + $vote2;
$vote4 = ($vote4/$sum)*360 + $vote3;
$vote5 = ($vote5/$sum)*360 + $vote4;
ImageArc($im, $xsize/2, $ysize/2, $xsize, $ysize, 0, 360, $black);
function linealfa ($alfa, $alfaold, $numcolor)
{
global $xsize, $ysize, $im, $black, $color;
$gradus = ($alfa + $alfaold)/2;
$alfa = ($alfa * pi())/180;
$x = $xsize/2 + ($xsize/2) * sin($alfa);
$y = $ysize/2 - ($xsize/2) * cos($alfa);
ImageLine($im, $xsize/2, $ysize/2, $x, $y, $black);
$gradus = ($gradus * pi())/180;
$x = $xsize/2 + ($xsize/3) * sin($gradus);
$y = $ysize/2 - ($ysize/3) * cos($gradus);
if ($gradus!=0) ImageFill($im, $x, $y, $color[$numcolor]);
示例6: draw_slice
function draw_slice($x, $y, $from, $to, $color)
{
# Awful Kludge!!!
if ($to > 360) {
$to = 360;
}
ImageArc($this->im, $this->center_x, $this->center_y, $this->diameter, $this->diameter, $from, $to, $color);
/* First line */
$axy2 = $this->get_xy_factors($from);
$ax2 = floor($this->center_x + $axy2[0] * ($this->diameter / 2));
$ay2 = floor($this->center_y + $axy2[1] * ($this->diameter / 2));
ImageLine($this->im, $this->center_x, $this->center_y, $ax2, $ay2, $color);
/* Second line */
$bxy2 = $this->get_xy_factors($to);
$bx2 = ceil($this->center_x + $bxy2[0] * ($this->diameter / 2));
$by2 = ceil($this->center_y + $bxy2[1] * ($this->diameter / 2));
ImageLine($this->im, $this->center_x, $this->center_y, $bx2, $by2, $color);
/* decide where to start filling, then fill */
$xy2 = $this->get_xy_factors(($to - $from) / 2 + $from);
$x2 = floor($this->center_x + $xy2[0] * ($this->diameter / 3));
$y2 = floor($this->center_y + $xy2[1] * ($this->diameter / 3));
ImageFillToBorder($this->im, $x2, $y2, $color, $color);
}
示例7: sin
} else {
if ($min % 5 == 0) {
$len = $radius / 10;
} else {
$len = $radius / 25;
}
}
$ang = 2 * M_PI * $min / 60;
$x1 = sin($ang) * ($radius - $len) + $radius;
$y1 = cos($ang) * ($radius - $len) + $radius;
$x2 = 1 * sin($ang) * $radius;
$y2 = 1 * cos($ang) * $radius;
ImageLine($img, $x1, $y1, $x2, $y2, $color_black);
}
list($hour, $min, $sec) = preg_split("/-/", Date("h-i-s", time() - 3600));
$hour = $hour % 12;
$xs = intval(cos($sec * M_PI / 30 - M_PI / 2) * 0.75 * $radius + $radius);
$ys = intval(sin($sec * M_PI / 30 - M_PI / 2) * 0.75 * $radius + $radius);
$xm = intval(cos($min * M_PI / 30 - M_PI / 2) * 0.65 * $radius + $radius);
$ym = intval(sin($min * M_PI / 30 - M_PI / 2) * 0.65 * $radius + $radius);
$xh = intval(cos($hour * 5 * M_PI / 30 - M_PI / 2) * 0.5 * $radius + $radius);
$yh = intval(sin($hour * 5 * M_PI / 30 - M_PI / 2) * 0.5 * $radius + $radius);
ImageLine($img, $radius, $radius, $xs, $ys, $color_grey);
ImageLine($img, $radius, $radius - 1, $xm, $ym, $color_blue);
ImageLine($img, $radius - 1, $radius, $xm, $ym, $color_blue);
ImageLine($img, $radius, $radius - 1, $xh, $yh, $color_blue);
ImageLine($img, $radius - 1, $radius, $xh, $yh, $color_blue);
ImageArc($img, $radius, $radius, $radius / 8, $radius / 8, 0, 360, $color_red);
ImageFillToBorder($img, $radius, $radius, $color_red, $color_red);
ImageGif($img);
ImageDestroy($img);
示例8: DrawPie
function DrawPie()
{
$width = $this->chart_area[2] - $this->chart_area[0];
$height = $this->chart_area[3] - $this->chart_area[1];
list($r, $g, $b) = ColorSet('black');
$black = ImageColorAllocate($this->img, $r, $g, $b);
$xpos = $this->chart_area[0] + $width / 2;
$ypos = $this->chart_area[1] + $height / 2;
$durchmesser = min($width, $height) * 0.97;
$radius = $durchmesser / 2;
ImageArc($this->img, $xpos, $ypos, $durchmesser, $durchmesser, 0, 360, $black);
//ImageFillToBorder($this->img, $xpos, $ypos, $black, $black);
$helpcol = ImageColorAllocate($this->img, 12, 12, 12);
ImageArc($this->img, $xpos, $ypos, $durchmesser, $durchmesser, 0, 360, $helpcol);
$i = 0;
$total = 0;
foreach ($this->data_values as $row) {
$colcount = 0;
$i = 0;
foreach ($row as $v) {
if ($v != $row[0]) {
// sum up
$sumarr[$i] += $v;
$total += $v;
}
$i++;
}
}
$colcount = 0;
$kreis_start = $this->arc_start;
$umfang = $radius * 2 * pi();
$winkel = $kreis_start;
foreach ($sumarr as $val) {
if ($colcount >= count($this->bar_color)) {
$colcount = 0;
}
$prozent = number_format($val / $total * 100, 1, ',', '.') . '%';
$val = round($val / $total * 360);
$winkel += $val;
$farbwinkel = $winkel - $val / 2;
$val += $kreis_start;
$barcol = $this->bar_color[$colcount];
list($r, $g, $b) = ColorSet($barcol);
$barcol = ImageColorAllocate($this->img, $r, $g, $b);
//ImageArc($this->img, $xpos, $ypos, $durchmesser, $durchmesser, $kreis_start, $val, $black);
ImageArc($this->img, $xpos, $ypos, $durchmesser, $durchmesser, 0, 3560, $black);
$out_x = $radius * cos(deg2rad($winkel));
$out_y = -$radius * sin(deg2rad($winkel));
$halbradius = $radius / 2;
$farb_x = $xpos + $halbradius * cos(deg2rad($farbwinkel));
$farb_y = $ypos + -$halbradius * sin(deg2rad($farbwinkel));
$out_x = $xpos + $out_x;
$out_y = $ypos + $out_y;
ImageLine($this->img, $xpos, $ypos, $out_x, $out_y, $black);
//ImageLine($this->img, $xpos, $ypos, $farb_x, $farb_y, $black);
ImageFillToBorder($this->img, $farb_x, $farb_y, $black, $barcol);
ImageTTFText($this->img, $this->axis_font_size, 0, $farb_x, $farb_y, $black, $this->font, $prozent);
$kreis_start = $val;
$colcount++;
}
//ImageArc($this->img, $xpos, $ypos, $durchmesser, $durchmesser, 0, 360, $black);
}
示例9: array
$cas_textcolor = $cas_textcolorchoice[$cas_rand];
break;
default:
$cas_textcolor = array(255, 255, 255);
break;
}
}
// Start building the image
$cas_image = @imagecreate($cas_imgwidth, $cas_imgheight) or die("Cannot Initialize new GD image stream");
$cas_bgcolor = imagecolorallocate($cas_image, $cas_bgcolor[0], $cas_bgcolor[1], $cas_bgcolor[2]);
$cas_fontcolor = imagecolorallocate($cas_image, $cas_textcolor[0], $cas_textcolor[1], $cas_textcolor[2]);
// Add noice lines
if ($cas_noise_line) {
for ($i = 0; $i < $wordcount; $i++) {
$color_line = ImageColorAllocate($cas_image, mt_rand(155, 255), mt_rand(155, 255), mt_rand(155, 255));
ImageArc($cas_image, mt_rand(-5, $cas_imgwidth), mt_rand(-5, $cas_imgheight), mt_rand(20, 300), mt_rand(20, 200), 55, 44, $color_line);
}
}
// Add noice points
if ($cas_noise_point) {
for ($i = 0; $i < $wordcount * 50; $i++) {
$color_point = ImageColorAllocate($cas_image, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
ImageSetPixel($cas_image, mt_rand(0, $cas_imgwidth), mt_rand(0, $cas_imgheight), $color_point);
}
}
// Check for freetype lib, if not found default to ugly built in capability using imagechar (Lee's mod)
// Also check that the chosen TrueType font is available
if (function_exists('imagettftext') && file_exists($cas_font)) {
$cas_angle = 3;
// Degrees to tilt the text
$cas_offset = 5;
示例10: ImageRoundEdges
function ImageRoundEdges($image, $size, $args = array()){
if (!is_numeric($size)){
throw new Exception("Not a valid size: " . $size);
}
$width = ImageSX($image);
$height = ImageSY($image);
if ($args["border"]){
$bordercolor = ImageHTMLColor($image, $args["border"]);
$oldimage = $image;
$image = ImageCreateTrueColor($width, $height);
ImageFilledRectangle($image, 0, 0, $width, $height, $bordercolor);
ImageCopyResized($image, $oldimage, 1, 1, 0, 0, $width - 2, $height - 2, $width, $height);
}else{
$oldimage = $image;
$image = ImageCreateTrueColor($width, $height);
ImageCopyResized($image, $oldimage, 0, 0, 0, 0, $width, $height, $width, $height);
}
$transp = ImageColorTransparent($image);
if (!$transp or $transp == -1){
if ($args["htmltranscolor"]){
$transp = ImageHTMLColor($image, $args["htmltranscolor"]);
}else{
$transp = ImageHTMLColor($image, "#d91da2");
}
}
for($i = 1; $i < $size / 2; $i++){
//Upper left corner.
$center = $i - 2;
ImageArc($image, $center, $center, $size, $size, 180, 270, $white);
ImageArc($image, $center - 1, $center, $size, $size, 180, 270, $white);
ImageArc($image, $center, $center, $size, $size, 180, 270, $transp);
ImageArc($image, $center - 1, $center, $size, $size, 180, 270, $transp);
//Upper right corner.
$left = $width - $i + 2;
$top = $i - 2;
ImageArc($image, $left, $top, $size, $size, 270, 360, $transp);
ImageArc($image, $left, $top - 1, $size, $size, 270, 360, $transp);
//Lower left corner.
$left = $i - 2;
$top = $height - $i + 2;
ImageArc($image, $left, $top, $size, $size, 90, 180, $transp);
ImageArc($image, $left, $top - 1, $size, $size, 90, 180, $transp);
//Lower right corner.
$left = $width - $i + 2;
$top = $height - $i + 2;
ImageArc($image, $left, $top, $size, $size, 0, 90, $transp);
ImageArc($image, $left, $top - 1, $size, $size, 0, 90, $transp);
}
if ($args["border"]){
//Lower right corner.
$left = $width - $i + 2;
$top = $height - $i + 2;
ImageArc($image, $left, $top, $size, $size, 0, 90, $bordercolor);
//Lower left corn
$left = $i - 2;
$top = $height - $i + 2;
ImageArc($image, $left, $top, $size, $size, 90, 180, $bordercolor);
//Upper left corner.
$center = $i - 2;
ImageArc($image, $center, $center - 1, $size, $size, 180, 270, $bordercolor);
//Upper right corner.
$left = $width - $i + 2;
$top = $i - 2;
ImageArc($image, $left, $top - 1, $size, $size, 270, 360, $bordercolor);
}
ImageColorTransparent($image, $transp);
return $image;
}
示例11: show
public function show($callback = NULL)
{
Header('Content-type: image/gif');
/*
* 初始化
*/
$border = 0;
//是否要边框 1要:0不要
$how = $this->num;
//验证码位数
$w = $this->width;
//图片宽度
$h = $this->height;
//图片高度
$fontsize = 5;
//字体大小
$alpha = 'abcdefghijkmnopqrstuvwxyz';
//验证码内容1:字母
$number = '023456789';
//验证码内容2:数字
$randcode = '';
//验证码字符串初始化
srand((double) microtime() * 1000000);
//初始化随机数种子
$im = ImageCreate($w, $h);
//创建验证图片
/*
* 绘制基本框架
*/
$bgcolor = ImageColorAllocate($im, 255, 255, 255);
//设置背景颜色
ImageFill($im, 0, 0, $bgcolor);
//填充背景色
if ($border) {
$black = ImageColorAllocate($im, 0, 0, 0);
//设置边框颜色
ImageRectangle($im, 0, 0, $w - 1, $h - 1, $black);
//绘制边框
}
/*
* 逐位产生随机字符
*/
for ($i = 0; $i < $how; $i++) {
$alpha_or_number = mt_rand(0, 1);
//字母还是数字
$str = $alpha_or_number ? $alpha : $number;
$which = mt_rand(0, strlen($str) - 1);
//取哪个字符
$code = substr($str, $which, 1);
//取字符
$j = !$i ? 4 : $j + 15;
//绘字符位置
$color3 = ImageColorAllocate($im, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100));
//字符随即颜色
ImageChar($im, $fontsize, $j, 3, $code, $color3);
//绘字符
$randcode .= $code;
//逐位加入验证码字符串
}
/*
* 添加干扰
*/
for ($i = 0; $i < 5; $i++) {
$color1 = ImageColorAllocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
//干扰线颜色
ImageArc($im, mt_rand(-5, $w), mt_rand(-5, $h), mt_rand(20, 300), mt_rand(20, 200), 55, 44, $color1);
//干扰线
}
for ($i = 0; $i < $how * 15; $i++) {
$color2 = ImageColorAllocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
//干扰点颜色
ImageSetPixel($im, mt_rand(0, $w), mt_rand(0, $h), $color2);
//干扰点
}
//把验证码字符串写入session
//$_SESSION[$this->name]=$randcode;
// if (isset($this->output_conf)) {
// if (is_array($this->output_conf)) {
// $this->output_conf['verify_code'] = $randcode;
// } else {
// $this->output_conf->verify_code = $randcode;
// }
// }
// $this->CI->session->set_userdata('verify_code', $randcode);
if (isset($callback)) {
$callback($randcode);
}
/*绘图结束*/
Imagegif($im);
ImageDestroy($im);
/*绘图结束*/
return $randcode;
}
示例12: mixedLine
private function mixedLine()
{
for ($i = 0; $i < 5; $i++) {
$bordercolor = ImageColorAllocate($this->image, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
// 干擾線條顏色
ImageArc($this->image, mt_rand(-5, $this->width), mt_rand(-5, $this->height), mt_rand(20, 300), mt_rand(20, 200), 55, 44, $bordercolor);
// 寫入圖片
}
}
示例13: show
function show()
{
Header("Content-type: image/gif");
/*
* ��ʼ��
*/
$border = 0;
//�Ƿ�Ҫ�߿� 1Ҫ:0��Ҫ
$how = $this->num;
//��֤��λ��
$w = $this->width;
//ͼƬ���
$h = $this->height;
//ͼƬ�߶�
$fontsize = 5;
//�����С
$alpha = "abcdefghijkmnopqrstuvwxyz";
//��֤������1:��ĸ
$number = "023456789";
//��֤������2:����
$randcode = "";
//��֤���ַ�����ʼ��
srand((double) microtime() * 1000000);
//��ʼ�����������
$im = ImageCreate($w, $h);
//������֤ͼƬ
/*
* ���ƻ������
*/
$bgcolor = ImageColorAllocate($im, 255, 255, 255);
//���ñ�����ɫ
ImageFill($im, 0, 0, $bgcolor);
//��䱳��ɫ
if ($border) {
$black = ImageColorAllocate($im, 0, 0, 0);
//���ñ߿���ɫ
ImageRectangle($im, 0, 0, $w - 1, $h - 1, $black);
//���Ʊ߿�
}
/*
* ��λ��������ַ�
*/
for ($i = 0; $i < $how; $i++) {
$alpha_or_number = mt_rand(0, 1);
//��ĸ��������
$str = $alpha_or_number ? $alpha : $number;
$which = mt_rand(0, strlen($str) - 1);
//ȡ�ĸ��ַ�
$code = substr($str, $which, 1);
//ȡ�ַ�
$j = !$i ? 4 : $j + 15;
//���ַ�λ��
$color3 = ImageColorAllocate($im, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100));
//�ַ��漴��ɫ
ImageChar($im, $fontsize, $j, 3, $code, $color3);
//���ַ�
$randcode .= $code;
//��λ������֤���ַ���
}
/*
* ��Ӹ���
*/
for ($i = 0; $i < 5; $i++) {
$color1 = ImageColorAllocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
//��������ɫ
ImageArc($im, mt_rand(-5, $w), mt_rand(-5, $h), mt_rand(20, 300), mt_rand(20, 200), 55, 44, $color1);
//������
}
for ($i = 0; $i < $how * 15; $i++) {
$color2 = ImageColorAllocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
//���ŵ���ɫ
ImageSetPixel($im, mt_rand(0, $w), mt_rand(0, $h), $color2);
//���ŵ�
}
//����֤���ַ���д��session
//$this->session->set_userdata(array($this->name=>$randcode));
$_SESSION[$this->name] = $randcode;
/*��ͼ����*/
Imagegif($im);
ImageDestroy($im);
/*��ͼ����*/
}
示例14: elseif
$dybuf = 1;
} elseif ($dybuf <= 0) {
//ImageString($im,3,($ox-3),80,$data[$i],$tcolor);
$tfy = 80;
$dybuf = 98;
} else {
if ($data[$i] < $lo || $data[$i] > $hi) {
$tcolor = $red;
} else {
$tcolor = $black;
}
$fontsize = 2;
$tfx = $ox + 5;
$tfy = $tabhi - $dybuf - 5;
$dybuf = $tabhi - $dybuf;
# invert the values
}
ImageArc($im, $ox, $dybuf, 4, 4, 0, 360, $blue);
if ($ox1 || $oy1) {
ImageLine($im, $ox1, $oy1, $ox, $dybuf, $blue);
}
ImageString($im, $fontsize, $tfx, $tfy, $data[$i], $tcolor);
}
$ox1 = $ox;
$oy1 = $dybuf;
//$xlb=$ox2;$ylb=$oy2;
$ox += $tabcols;
}
header('Content-type: image/PNG');
ImagePNG($im);
ImageDestroy($im);
示例15: create_my_captcha
function create_my_captcha()
{
Header("Content-type: image/gif");
/*
* 初始化
*/
$border = 0;
//是否要边框 1要:0不要
$how = 4;
//验证码位数
$w = $how * 15;
//图片宽度
$h = 20;
//图片高度
$fontsize = 16;
//字体大小
$alpha = "abcdefghijkmnpqrstuvwxyzABCDEFGHIGKLMNPQRSTUVWXYZ";
//验证码内容1:字母
$number = "23456789";
//验证码内容2:数字
$randcode = "";
//验证码字符串初始化
srand((double) microtime() * 1000000);
//初始化随机数种子
$im = ImageCreate($w, $h);
//创建验证图片
/*
* 绘制基本框架
*/
$bgcolor = ImageColorAllocate($im, 255, 255, 255);
//设置背景颜色
ImageFill($im, 0, 0, $bgcolor);
//填充背景色
if ($border) {
$black = ImageColorAllocate($im, 0, 0, 0);
//设置边框颜色
ImageRectangle($im, 0, 0, $w - 1, $h - 1, $black);
//绘制边框
}
/*
* 逐位产生随机字符
*/
for ($i = 0; $i < $how; $i++) {
$alpha_or_number = mt_rand(0, 1);
//字母还是数字
$str = $alpha_or_number ? $alpha : $number;
$which = mt_rand(0, strlen($str) - 1);
//取哪个字符
$code = substr($str, $which, 1);
//取字符
$j = !$i ? 4 : $j + 15;
//绘字符位置
$color3 = ImageColorAllocate($im, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100));
//字符随即颜色
ImageChar($im, $fontsize, $j, 3, $code, $color3);
//绘字符
$randcode .= $code;
//逐位加入验证码字符串
}
/*
* 添加干扰
*/
for ($i = 0; $i < 2; $i++) {
$color1 = ImageColorAllocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
//干扰线颜色
ImageArc($im, mt_rand(-5, $w), mt_rand(-5, $h), mt_rand(20, 300), mt_rand(20, 200), 55, 44, $color1);
//干扰线
}
for ($i = 0; $i < $how * 7; $i++) {
$color2 = ImageColorAllocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
//干扰点颜色
ImageSetPixel($im, mt_rand(0, $w), mt_rand(0, $h), $color2);
//干扰点
}
//把验证码字符串写入session
$_SESSION['login_check_number'] = strtoupper($randcode);
/*绘图结束*/
Imagegif($im);
ImageDestroy($im);
/*绘图结束*/
}