本文整理汇总了PHP中imagesetstyle函数的典型用法代码示例。如果您正苦于以下问题:PHP imagesetstyle函数的具体用法?PHP imagesetstyle怎么用?PHP imagesetstyle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imagesetstyle函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: drawGrid
function drawGrid()
{
$this->x0 = -$x1;
$this->y0 = -$y1;
$this->x1 = $x1;
$this->y1 = $y1;
$this->posX0 = $width / 2;
$this->posY0 = $height / 2;
$this->scale = (double) ($width - 20) / ($this->x1 - $this->x0);
imageLine($this->img, $this->posX0 + $this->x0 * $this->scale - 2, $this->posY0, $this->posX0 + $this->x1 * $this->scale + 2, $this->posY0, $this->blk);
imageLine($this->img, $this->posX0, $this->posY0 - $this->y0 * $this->scale + 2, $this->posX0, $this->posY0 - $this->y1 * $this->scale - 2, $this->blk);
imagesetstyle($this->img, array($this->gry, $this->wte, $this->wte, $this->wte, $this->wte));
for ($x = 1; $x <= $this->x1; $x += 1) {
imageline($this->img, $this->posX0 + $x * $this->scale, 0, $this->posX0 + $x * $this->scale, $this->posY0 * 2, IMG_COLOR_STYLED);
imageline($this->img, $this->posX0 - $x * $this->scale, 0, $this->posX0 - $x * $this->scale, $this->posY0 * 2, IMG_COLOR_STYLED);
imageLine($this->img, $this->posX0 + $x * $this->scale, $this->posY0 - 3, $this->posX0 + $x * $this->scale, $this->posY0 + 3, $this->blk);
imageLine($this->img, $this->posX0 - $x * $this->scale, $this->posY0 - 3, $this->posX0 - $x * $this->scale, $this->posY0 + 3, $this->blk);
imagestring($this->img, 2, $this->posX0 + $x * $this->scale, $this->posY0 + 4, $x, $this->blu);
imagestring($this->img, 2, $this->posX0 - $x * $this->scale, $this->posY0 + 4, "-{$x}", $this->blu);
}
for ($y = 1; $y <= $this->y1; $y += 1) {
imageline($this->img, 0, $this->posY0 + $y * $this->scale, $this->posX0 * 2, $this->posY0 + $y * $this->scale, IMG_COLOR_STYLED);
imageline($this->img, 0, $this->posY0 - $y * $this->scale, $this->posX0 * 2, $this->posY0 - $y * $this->scale, IMG_COLOR_STYLED);
imageLine($this->img, $this->posX0 - 3, $this->posY0 - $y * $this->scale, $this->posX0 + 3, $this->posY0 - $y * $this->scale, $this->blk);
imageLine($this->img, $this->posX0 - 3, $this->posY0 + $y * $this->scale, $this->posX0 + 3, $this->posY0 + $y * $this->scale, $this->blk);
imagestring($this->img, 2, $this->posX0 + 4, $this->posY0 - $y * $this->scale, $y, $this->blu);
imagestring($this->img, 2, $this->posX0 + 4, $this->posY0 + $y * $this->scale, "-{$y}", $this->blu);
}
}
示例2: _render_edge
private function _render_edge($mesh)
{
$style = array();
foreach ($mesh as $value) {
$style = range($value->getA()->getColor()->toPngColor($this->_img), $value->getB()->getColor()->toPngColor($this->_img), 0xf1);
imagesetstyle($this->_img, $style);
imageline($this->_img, -$value->getA()->getX() + $this->_width / 2, -$value->getA()->getY() + $this->_height / 2, -$value->getB()->getX() + $this->_width / 2, -$value->getB()->getY() + $this->_height / 2, IMG_COLOR_STYLED);
imagesetstyle($this->_img, $style);
imageline($this->_img, -$value->getA()->getX() + $this->_width / 2, -$value->getA()->getY() + $this->_height / 2, -$value->getC()->getX() + $this->_width / 2, -$value->getC()->getY() + $this->_height / 2, IMG_COLOR_STYLED);
imagesetstyle($this->_img, $style);
imageline($this->_img, -$value->getC()->getX() + $this->_width / 2, -$value->getC()->getY() + $this->_height / 2, -$value->getB()->getX() + $this->_width / 2, -$value->getB()->getY() + $this->_height / 2, IMG_COLOR_STYLED);
}
}
示例3: perform
/**
* Draws a polygon on the handle
*
* @param GD-object $handle The handle on which the polygon is drawn
* @param Zend_Image_Action_DrawPolygon $polygonObject The object that with all info
*/
public function perform(Zend_Image_Adapter_Gd $adapter, Zend_Image_Action_DrawPolygon $polygonObject) { // As of ZF2.0 / PHP5.3, this can be made static.
$handle = $adapter->getHandle();
$points = $this->_parsePoints($polygonObject->getPoints());
if(($pattern = $polygonObject->getStrokeDashPattern())!== null) {
$color = imagecolorallocate($handle, 0, 255, 0);
$array = array();
foreach($pattern as $amountOfPixels) {
$array = array_merge($array, array_fill(0, $amountOfPixels, $color));
$array = array_merge($array, array_fill(0, $polygonObject->getStrokeDashOffset(), IMG_COLOR_TRANSPARENT));
}
if(count($array) > 0) {
imagesetstyle($handle, $array);
}
}
if($polygonObject->isFilled()) {
//@TODO: extract this to Zend_Image_Adapter_Gd_Action_ActionAbstract ?
$color = $polygonObject->getFillColor()->getRgb();
$colorRes = imagecolorallocatealpha($handle,
$color['red'],
$color['green'],
$color['blue'],
$polygonObject->getFillAlpha());
imagefilledpolygon($handle, $points, count($points)/2, $colorRes);
}
$points = $polygonObject->getPoints();
$start = current($points);;
$line = new Zend_Image_Action_DrawLine();
while(current($points)!==false) {
$from = current($points);
$to = next($points);
if($to===false) {
if(!$polygonObject->isClosed()) {
break;
} else {
$to = $start;
}
}
$line->from($from);
$line->to($to);
$line->perform($adapter);
}
}
示例4: CaptchaImages
function CaptchaImages($code, $width = 145, $height = 35)
{
/* select the type of font, must be used in directoy in which script is being called into */
$this->font = dirname(__FILE__) . '/CALIBRI.TTF';
$font_size = $height * 0.6;
$image = @imagecreate($width, $height) or die('Cannot initialize new GD image stream');
/* set the colours */
$bgR = mt_rand(0, 255);
$bgG = mt_rand(0, 255);
$bgB = mt_rand(0, 255);
$background_color = imagecolorallocate($image, $bgR, $bgG, $bgB);
$noise_color = imagecolorallocate($image, abs(100 - $bgR), abs(100 - $bgG), abs(100 - $bgB));
$text_color = imagecolorallocate($image, abs(255 - $bgR), abs(255 - $bgG), abs(255 - $bgB));
/* generate random dots in background */
for ($i = 0; $i < $width * $height / 3; $i++) {
imagefilledellipse($image, mt_rand(0, $width), mt_rand(0, $height), 1, 1, $noise_color);
}
/* generate random lines in background */
for ($i = 0; $i < $width * $height / 150; $i++) {
imageline($image, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), $noise_color);
}
/* set random colors */
$w = imagecolorallocate($image, abs(100 - $bgR), abs(100 - $bgG), abs(100 - $bgB));
$r = imagecolorallocate($image, abs(100 - $bgR), abs(100 - $bgG), abs(100 - $bgB));
/* Draw a dashed line, 5 red pixels, 5 white pixels */
$style = array($r, $r, $r, $r, $r, $w, $w, $w, $w, $w);
imagesetstyle($image, $style);
imageline($image, 0, 0, $width, $height, IMG_COLOR_STYLED);
imageline($image, $width, 0, 0, $height, IMG_COLOR_STYLED);
/* create random polygon points */
$values = array(mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $height), mt_rand(0, $width));
/* create Random Colors then set it to $clr */
$r = abs(100 - mt_rand(0, 255));
$g = abs(100 - mt_rand(0, 255));
$b = abs(100 - mt_rand(0, 255));
$clr = imagecolorallocate($image, $r, $g, $b);
/* create filled polygon with random points */
imagefilledpolygon($image, $values, 6, $clr);
$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');
/* pretty it */
imageantialias($image, 100);
imagealphablending($image, 1);
imagelayereffect($image, IMG_EFFECT_OVERLAY);
/* output captcha image to browser */
header('Content-Type: image/jpeg');
imagejpeg($image);
imagedestroy($image);
}
示例5: getCode
function getCode($num,$w,$h) {
$code = "";
$w = 80;
$h = 30;
$num = 5;
for ($i = 0; $i < $num; $i++) {
$code .= rand(0, 9);
}
//4位验证码也可以用rand(1000,9999)直接生成
//将生成的验证码写入session,备验证时用
$_SESSION["helloweba_num"] = $code;
//创建图片,定义颜色值
header("Content-type: image/PNG");
$im = imagecreate($w, $h);
$nums = imagecolorallocate($im, 0, 255, 144);
$bg = imagecolorallocate($im, 0, 100, 200);
$bgcolor = imagecolorallocate($im, 255, 255, 255);
//填充背景
imagefill($im, 0, 0, $bg);
//画边框
imagerectangle($im, 0, 0, $w-1, $h-1, $nums);
//随机绘制两条虚线,起干扰作用
$style = array ($nums,$nums,$nums,$nums,$nums,
$bg,$bg,$bg,$bg,$bg
);
imagesetstyle($im, $style);
$y1 = rand(0, $h);
$y2 = rand(0, $h);
$y3 = rand(0, $h);
$y4 = rand(0, $h);
imageline($im, 0, $y1, $w, $y3, IMG_COLOR_STYLED);
imageline($im, 0, $y2, $w, $y4, IMG_COLOR_STYLED);
//在画布上随机生成大量黑点,起干扰作用;
for ($i = 0; $i < 80; $i++) {
imagesetpixel($im, rand(0, $w), rand(0, $h), $nums);
}
//将数字随机显示在画布上,字符的水平间距和位置都按一定波动范围随机生成
$strx = rand(0, 35); //左右
for ($i = 0; $i < $num; $i++) {
$strpos = rand(1, 10);
imagestring($im, 5, $strx, $strpos, substr($code, $i, 1), $nums);
$strx += rand(8, 10);
}
imagepng($im);//输出图片
imagedestroy($im);//释放图片所占内存
}
示例6: getCode
public static function getCode($code_key = "code_key", $num = 5, $w = 80, $h = 36)
{
$code = "";
for ($i = 0; $i < $num; $i++) {
$code .= rand(0, 9);
}
//4位验证码也可以用rand(1000,9999)直接生成
//将生成的验证码写入session,备验证时用
$_SESSION[$code_key] = $code;
//创建图片,定义颜色值
header("Content-type:image/PNG");
$im = imagecreate($w, $h);
$black = imagecolorallocate($im, 0, 0, 0);
$gray = imagecolorallocate($im, 200, 200, 200);
$bgcolor = imagecolorallocate($im, 255, 255, 255);
//填充背景
imagefill($im, 0, 0, $gray);
//画边框
imagerectangle($im, 0, 0, $w - 1, $h - 1, $black);
//随机绘制两条虚线,起干扰作用
$style = array($black, $black, $black, $black, $black, $gray, $gray, $gray, $gray, $gray);
imagesetstyle($im, $style);
$y1 = rand(0, $h);
$y2 = rand(0, $h);
$y3 = rand(0, $h);
$y4 = rand(0, $h);
imageline($im, 0, $y1, $w, $y3, IMG_COLOR_STYLED);
imageline($im, 0, $y2, $w, $y4, IMG_COLOR_STYLED);
//在画布上随机生成大量黑点,起干扰作用;
for ($i = 0; $i < 80; $i++) {
imagesetpixel($im, rand(0, $w), rand(0, $h), $black);
}
//将数字随机显示在画布上,字符的水平间距和位置都按一定波动范围随机生成
$strx = rand(3, 8);
for ($i = 0; $i < $num; $i++) {
$strpos = rand(1, 6);
imagestring($im, 5, $strx, $strpos, substr($code, $i, 1), $black);
$strx += rand(8, 12);
}
imagepng($im);
//输出图片
imagedestroy($im);
//释放图片所占内存
}
示例7: getCode
function getCode($num, $w, $h)
{
$code = "";
for ($i = 0; $i < $num; $i++) {
$code .= rand(0, 9);
}
$_SESSION["code_num"] = $code;
header("Content-type: image/PNG");
$im = imagecreate($w, $h);
$black = imagecolorallocate($im, 0, 0, 0);
$gray = imagecolorallocate($im, 200, 200, 200);
$bgcolor = imagecolorallocate($im, 255, 255, 255);
imagefill($im, 0, 0, $gray);
//画边框
imagerectangle($im, 0, 0, $w - 1, $h - 1, $black);
//随机绘制两条虚线,起干扰作用
$style = array($black, $black, $black, $black, $black, $gray, $gray, $gray, $gray, $gray);
imagesetstyle($im, $style);
$y1 = rand(0, $h);
$y2 = rand(0, $h);
$y3 = rand(0, $h);
$y4 = rand(0, $h);
imageline($im, 0, $y1, $w, $y3, IMG_COLOR_STYLED);
imageline($im, 0, $y2, $w, $y4, IMG_COLOR_STYLED);
//在画布上随机生成大量黑点,起干扰作用;
for ($i = 0; $i < 80; $i++) {
imagesetpixel($im, rand(0, $w), rand(0, $h), $black);
}
//将数字随机显示在画布上,字符的水平间距和位置都按一定波动范围随机生成
$strx = rand(3, 8);
for ($i = 0; $i < $num; $i++) {
$strpos = rand(1, 6);
imagestring($im, 5, $strx, $strpos, substr($code, $i, 1), $black);
$strx += rand(8, 12);
}
imagepng($im);
//输出图片
imagedestroy($im);
//释放图片所占内存
}
示例8: initialize
public function initialize()
{
$CI =& get_instance();
$num = "";
for ($i = 0; $i < 4; $i++) {
$num .= rand(0, 9);
}
//4位验证码也可以用rand(1000,9999)直接生成
//将生成的验证码写入session,备验证页面使用
$CI->session->set_userdata('Checknum', $num);
//创建图片,定义颜色值
Header("Content-type: image/PNG");
srand((double) microtime() * 1000000);
$im = imagecreate(60, 20);
$black = ImageColorAllocate($im, 0, 0, 0);
$gray = ImageColorAllocate($im, 200, 200, 200);
imagefill($im, 0, 0, $gray);
//随机绘制两条虚线,起干扰作用
$style = array($black, $black, $black, $black, $black, $gray, $gray, $gray, $gray, $gray);
imagesetstyle($im, $style);
$y1 = rand(0, 20);
$y2 = rand(0, 20);
$y3 = rand(0, 20);
$y4 = rand(0, 20);
imageline($im, 0, $y1, 60, $y3, IMG_COLOR_STYLED);
imageline($im, 0, $y2, 60, $y4, IMG_COLOR_STYLED);
//在画布上随机生成大量黑点,起干扰作用;
for ($i = 0; $i < 80; $i++) {
imagesetpixel($im, rand(0, 60), rand(0, 20), $black);
}
//将四个数字随机显示在画布上,字符的水平间距和位置都按一定波动范围随机生成
$strx = rand(3, 8);
for ($i = 0; $i < 4; $i++) {
$strpos = rand(1, 6);
imagestring($im, 5, $strx, $strpos, substr($num, $i, 1), $black);
$strx += rand(8, 12);
}
ImagePNG($im);
ImageDestroy($im);
}
示例9: drawAxes
function drawAxes()
{
imagesetstyle($this->img, array($this->gry, $this->wte, $this->wte, $this->wte, $this->wte));
imageLine($this->img, $this->posX0 + $this->x0 * $this->scale - 2, $this->posY0, $this->posX0 + $this->x1 * $this->scale + 2, $this->posY0, $this->blk);
imageLine($this->img, $this->posX0, $this->posY0 - $this->y0 * $this->scale + 2, $this->posX0, $this->posY0 - $this->y1 * $this->scale - 2, $this->blk);
for ($x = 1; $x <= $this->x1; $x += 1) {
imageline($this->img, $this->posX0 + $x * $this->scale, 0, $this->posX0 + $x * $this->scale, $this->posY0 * 2, IMG_COLOR_STYLED);
imageline($this->img, $this->posX0 - $x * $this->scale, 0, $this->posX0 - $x * $this->scale, $this->posY0 * 2, IMG_COLOR_STYLED);
imageLine($this->img, $this->posX0 + $x * $this->scale, $this->posY0 - 3, $this->posX0 + $x * $this->scale, $this->posY0 + 3, $this->blk);
imageLine($this->img, $this->posX0 - $x * $this->scale, $this->posY0 - 3, $this->posX0 - $x * $this->scale, $this->posY0 + 3, $this->blk);
imagestring($this->img, 2, $this->posX0 + $x * $this->scale, $this->posY0 + 4, $x, $this->blu);
imagestring($this->img, 2, $this->posX0 - $x * $this->scale, $this->posY0 + 4, "-{$x}", $this->blu);
}
for ($y = 1; $y <= $this->y1; $y += 1) {
imageline($this->img, 0, $this->posY0 + $y * $this->scale, $this->posX0 * 2, $this->posY0 + $y * $this->scale, IMG_COLOR_STYLED);
imageline($this->img, 0, $this->posY0 - $y * $this->scale, $this->posX0 * 2, $this->posY0 - $y * $this->scale, IMG_COLOR_STYLED);
imageLine($this->img, $this->posX0 - 3, $this->posY0 - $y * $this->scale, $this->posX0 + 3, $this->posY0 - $y * $this->scale, $this->blk);
imageLine($this->img, $this->posX0 - 3, $this->posY0 + $y * $this->scale, $this->posX0 + 3, $this->posY0 + $y * $this->scale, $this->blk);
imagestring($this->img, 2, $this->posX0 + 4, $this->posY0 - $y * $this->scale, $y, $this->blu);
imagestring($this->img, 2, $this->posX0 + 4, $this->posY0 + $y * $this->scale, "-{$y}", $this->blu);
}
}
示例10: drawElement
//.........这里部分代码省略.........
$y1_shift = $zero - $shift_from / $unit2px;
$y2_shift = $zero - $shift_to / $unit2px;
//*/
if (!$this->limitToBounds($y1, $y2, $this->shiftY, $this->sizeY, $drawtype)) {
return true;
}
if (!$this->limitToBounds($y1_shift, $y2_shift, $this->shiftY, $this->sizeY, $drawtype)) {
return true;
}
// draw main line
switch ($drawtype) {
case GRAPH_ITEM_DRAWTYPE_BOLD_LINE:
if ($calc_fnc == CALC_FNC_ALL) {
imagefilledpolygon($this->im, $a, 4, $minmax_color);
if (!$y1x || !$y2x) {
imageline($this->im, $x1 + 1, $y1max, $x2 + 1, $y2max, $max_color);
imageline($this->im, $x1, $y1max, $x2, $y2max, $max_color);
}
if (!$y1n || !$y2n) {
imageline($this->im, $x1 - 1, $y1min, $x2 - 1, $y2min, $min_color);
imageline($this->im, $x1, $y1min, $x2, $y2min, $min_color);
}
}
imageline($this->im, $x1, $y1 + 1, $x2, $y2 + 1, $avg_color);
imageline($this->im, $x1, $y1, $x2, $y2, $avg_color);
break;
case GRAPH_ITEM_DRAWTYPE_LINE:
if ($calc_fnc == CALC_FNC_ALL) {
imagefilledpolygon($this->im, $a, 4, $minmax_color);
if (!$y1x || !$y2x) {
imageline($this->im, $x1, $y1max, $x2, $y2max, $max_color);
}
if (!$y1n || !$y2n) {
imageline($this->im, $x1, $y1min, $x2, $y2min, $min_color);
}
}
imageline($this->im, $x1, $y1, $x2, $y2, $avg_color);
break;
case GRAPH_ITEM_DRAWTYPE_FILLED_REGION:
//--
$a[0] = $x1;
$a[1] = $y1;
$a[2] = $x1;
$a[3] = $y1_shift;
$a[4] = $x2;
$a[5] = $y2_shift;
$a[6] = $x2;
$a[7] = $y2;
imagefilledpolygon($this->im, $a, 4, $avg_color);
break;
case GRAPH_ITEM_DRAWTYPE_DOT:
imagefilledrectangle($this->im, $x1 - 1, $y1 - 1, $x1, $y1, $avg_color);
break;
case GRAPH_ITEM_DRAWTYPE_BOLD_DOT:
imagefilledrectangle($this->im, $x2 - 1, $y2 - 1, $x2 + 1, $y2 + 1, $avg_color);
break;
case GRAPH_ITEM_DRAWTYPE_DASHED_LINE:
if (function_exists('imagesetstyle')) {
// Use imagesetstyle+imageline instead of bugged imagedashedline
$style = array($avg_color, $avg_color, IMG_COLOR_TRANSPARENT, IMG_COLOR_TRANSPARENT);
imagesetstyle($this->im, $style);
imageline($this->im, $x1, $y1, $x2, $y2, IMG_COLOR_STYLED);
} else {
imagedashedline($this->im, $x1, $y1, $x2, $y2, $avg_color);
}
break;
case GRAPH_ITEM_DRAWTYPE_GRADIENT_LINE:
ImageLine($this->im, $x1, $y1, $x2, $y2, $avg_color);
//draw the initial line
ImageLine($this->im, $x1, $y1 - 1, $x2, $y2 - 1, $avg_color);
$bitmask = 255;
$blue = $avg_color & $bitmask;
// $blue_diff = 255 - $blue;
$bitmask = $bitmask << 8;
$green = ($avg_color & $bitmask) >> 8;
// $green_diff = 255 - $green;
$bitmask = $bitmask << 8;
$red = ($avg_color & $bitmask) >> 16;
// $red_diff = 255 - $red;
$maxAlpha = 110;
$startAlpha = 50;
$alphaRatio = $maxAlpha / ($this->sizeY - $startAlpha);
$diffX = $x1 - $x2;
for ($i = 0; $i <= $diffX; $i++) {
$Yincr = $diffX > 0 ? abs($y2 - $y1) / $diffX : 0;
$gy = $y1 > $y2 ? $y2 + $Yincr * $i : $y2 - $Yincr * $i;
$steps = $this->sizeY + $this->shiftY - $gy + 1;
for ($j = 0; $j < $steps; $j++) {
if ($gy + $j < $this->shiftY + $startAlpha) {
$alpha = 0;
} else {
$alpha = 127 - abs(127 - $alphaRatio * ($gy + $j - $this->shiftY - $startAlpha));
}
$color = imagecolorexactalpha($this->im, $red, $green, $blue, $alpha);
imagesetpixel($this->im, $x2 + $i, $gy + $j, $color);
}
}
break;
}
}
示例11: apply
/**
* {@inheritdoc}
*/
public function apply(CanvasInterface $canvas, AbstractStyledDrawable $drawable)
{
$fv = $drawable->getColor()->getValue();
$sv = $this->getSecondColor()->getValue();
$style = array_merge(array_fill(0, $this->getFirstColorShowTime(), $fv), array_fill(0, $this->getSecondColorShowTime(), $sv));
if (false == @imagesetstyle($canvas->getHandler(), $style)) {
throw new DrawableException('Could Not Apply The DashedLine Style');
}
return new StyledColor();
}
示例12: ASsetdash
function ASsetdash()
{
if (func_num_args() > 0) {
$dash = func_get_arg(0);
$this->curdash = $dash;
} else {
$dash = $this->curdash;
}
if ($dash == 'none' || !preg_match('/\\d/', $dash)) {
$this->isdashed = false;
} else {
$dash = preg_replace('/\\s+/', ',', $dash);
$darr = explode(',', $dash);
$style = array();
$alt = 0;
$doagain = count($darr) % 2;
//do twice if odd number
while ($doagain > -1) {
for ($i = 0; $i < count($darr); $i++) {
if ($alt == 0) {
$color = $this->stroke;
} else {
$color = 'white';
}
$style = array_pad($style, count($style) + $darr[$i], $this->{$color});
$alt = 1 - $alt;
}
$doagain--;
}
imagesetstyle($this->img, $style);
$this->isdashed = true;
}
}
示例13: DashedLineForGrid
function DashedLineForGrid($x1, $y1, $x2, $y2, $dash_length = 1, $dash_space = 4)
{
if ($this->line_weight <= 0) {
return;
}
// Add error check to make sure anti-alias is not enabled.
// Dashed line does not work with anti-alias enabled. This
// is a limitation in GD.
if ($this->use_anti_aliasing) {
// JpGraphError::RaiseL(25129); // Anti-alias can not be used with dashed lines. Please disable anti-alias or use solid lines.
}
$x1 = round($x1);
$x2 = round($x2);
$y1 = round($y1);
$y2 = round($y2);
/*
$dash_length *= $this->scale;
$dash_space *= $this->scale;
*/
$dash_length = 2;
$dash_length = 4;
imagesetthickness($this->img, 1);
$style = array_fill(0, $dash_length, $this->current_color);
//hexdec('CCCCCC'));
$style = array_pad($style, $dash_space, IMG_COLOR_TRANSPARENT);
imagesetstyle($this->img, $style);
imageline($this->img, $x1, $y1, $x2, $y2, IMG_COLOR_STYLED);
$this->lastx = $x2;
$this->lasty = $y2;
}
示例14: circle
/**
* Draws a circle at $x,$y with radius $r
*
* See {@link Style::munge_color()} for the format of the color array.
* See {@link Cpdf::setLineStyle()} for a description of the $style
* parameter (aka dash)
*
* @param float $x
* @param float $y
* @param float $r
* @param array $color
* @param float $width
* @param array $style
* @param bool $fill Fills the circle if true
*/
function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false)
{
// Scale by the AA factor
$x *= $this->_aa_factor;
$y *= $this->_aa_factor;
$r *= $this->_aa_factor;
$c = $this->_allocate_color($color);
// Convert the style array if required
if (!is_null($style) && !$fill) {
$gd_style = array();
foreach ($style as $length) {
for ($i = 0; $i < $length; $i++) {
$gd_style[] = $c;
}
}
imagesetstyle($this->_img, $gd_style);
$c = IMG_COLOR_STYLED;
}
imagesetthickness($this->_img, $width);
if ($fill) {
imagefilledellipse($this->_img, $x, $y, $r, $r, $c);
} else {
imageellipse($this->_img, $x, $y, $r, $r, $c);
}
}
示例15: noise_line
/**
* Noise line
*/
function noise_line($img, $min_x, $min_y, $max_x, $max_y, $bg, $font, $non_font)
{
imagesetthickness($img, 2);
$x1 = $min_x;
$x2 = $max_x;
$y1 = $min_y;
$y2 = $min_y;
do
{
$line = array_merge(
array_fill(0, mt_rand(30, 60), $non_font[array_rand($non_font)]),
array_fill(0, mt_rand(30, 60), $bg)
);
imagesetstyle($img, $line);
imageline($img, $x1, $y1, $x2, $y2, IMG_COLOR_STYLED);
$y1 += mt_rand(12, 35);
$y2 += mt_rand(12, 35);
}
while ($y1 < $max_y && $y2 < $max_y);
$x1 = $min_x;
$x2 = $min_x;
$y1 = $min_y;
$y2 = $max_y;
do
{
$line = array_merge(
array_fill(0, mt_rand(30, 60), $non_font[array_rand($non_font)]),
array_fill(0, mt_rand(30, 60), $bg)
);
imagesetstyle($img, $line);
imageline($img, $x1, $y1, $x2, $y2, IMG_COLOR_STYLED);
$x1 += mt_rand(20, 35);
$x2 += mt_rand(20, 35);
}
while ($x1 < $max_x && $x2 < $max_x);
imagesetthickness($img, 1);
}