本文整理汇总了PHP中imagesetstyle函数的典型用法代码示例。如果您正苦于以下问题:PHP imagesetstyle函数的具体用法?PHP imagesetstyle怎么用?PHP imagesetstyle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imagesetstyle函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
开发者ID:pl0o0f,项目名称:nedi-puppet,代码行数:29,代码来源:libgraph.php
示例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);
}
}
开发者ID:eXcomm,项目名称:3D-PHP-Class,代码行数:13,代码来源:Render.class.php
示例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);
}
}
开发者ID:BGCX262,项目名称:zym-svn-to-git,代码行数:57,代码来源:DrawPolygon.php
示例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);
}
开发者ID:qcww,项目名称:yh_cms,代码行数:51,代码来源:CaptchaSecurityImages.php
示例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);//释放图片所占内存
}
开发者ID:em-z,项目名称:Docs,代码行数:49,代码来源:captcha.php
示例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);
//释放图片所占内存
}
开发者ID:FRED5DON,项目名称:MemoServo,代码行数:44,代码来源:MateController.php
示例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);
//释放图片所占内存
}
开发者ID:shenerguang,项目名称:chatRoom_php,代码行数:40,代码来源:code.php
示例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);
}
开发者ID:miguelmeca,项目名称:wscat,代码行数:40,代码来源:Yz.php
示例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);
}
}
开发者ID:BackupTheBerlios,项目名称:nedi-svn,代码行数:22,代码来源:graph.php
示例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;
}
}
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:101,代码来源:class.cchart.php
示例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();
}
开发者ID:El-Loco-Pinguino,项目名称:FaitesUnVoeu_WF3,代码行数:13,代码来源:DashedlineStyle.php
示例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;
}
}
开发者ID:rolwi,项目名称:koala,代码行数:33,代码来源:asciisvgimg.php
示例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;
}
开发者ID:hcvcastro,项目名称:pxp,代码行数:30,代码来源:gd_image.inc.php
示例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);
}
}
开发者ID:sgrove,项目名称:cothinker,代码行数:40,代码来源:gd_adapter.cls.php
示例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);
}
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:48,代码来源:captcha_gd.php
示例16: ImageCreateFrombmp
function ImageCreateFrombmp($filename)
{
$buf = @file_get_contents($filename);
if (strlen($buf) < 54) {
return false;
}
$file_header = unpack("sbfType/LbfSize/sbfReserved1/sbfReserved2/LbfOffBits", substr($buf, 0, 14));
if ($file_header["bfType"] != 19778) {
return false;
}
$info_header = unpack("LbiSize/lbiWidth/lbiHeight/sbiPlanes/sbiBitCountLbiCompression/LbiSizeImage/lbiXPelsPerMeter/lbiYPelsPerMeter/LbiClrUsed/LbiClrImportant", substr($buf, 14, 40));
if ($info_header["biBitCountLbiCompression"] == 2) {
return false;
}
$line_len = round($info_header["biWidth"] * $info_header["biBitCountLbiCompression"] / 8);
$x = $line_len % 4;
if ($x > 0) {
$line_len += 4 - $x;
}
$img = imagecreatetruecolor($info_header["biWidth"], $info_header["biHeight"]);
switch ($info_header["biBitCountLbiCompression"]) {
case 4:
$colorset = unpack("L*", substr($buf, 54, 64));
for ($y = 0; $y < $info_header["biHeight"]; $y++) {
$colors = array();
$y_pos = $y * $line_len + $file_header["bfOffBits"];
for ($x = 0; $x < $info_header["biWidth"]; $x++) {
if ($x % 2) {
$colors[] = $colorset[(ord($buf[$y_pos + ($x + 1) / 2]) & 0xf) + 1];
} else {
$colors[] = $colorset[(ord($buf[$y_pos + $x / 2 + 1]) >> 4 & 0xf) + 1];
}
}
imagesetstyle($img, $colors);
imageline($img, 0, $info_header["biHeight"] - $y - 1, $info_header["biWidth"], $info_header["biHeight"] - $y - 1, IMG_COLOR_STYLED);
}
break;
case 8:
$colorset = unpack("L*", substr($buf, 54, 1024));
for ($y = 0; $y < $info_header["biHeight"]; $y++) {
$colors = array();
$y_pos = $y * $line_len + $file_header["bfOffBits"];
for ($x = 0; $x < $info_header["biWidth"]; $x++) {
$colors[] = $colorset[ord($buf[$y_pos + $x]) + 1];
}
imagesetstyle($img, $colors);
imageline($img, 0, $info_header["biHeight"] - $y - 1, $info_header["biWidth"], $info_header["biHeight"] - $y - 1, IMG_COLOR_STYLED);
}
break;
case 16:
for ($y = 0; $y < $info_header["biHeight"]; $y++) {
$colors = array();
$y_pos = $y * $line_len + $file_header["bfOffBits"];
for ($x = 0; $x < $info_header["biWidth"]; $x++) {
$i = $x * 2;
$color = ord($buf[$y_pos + $i]) | ord($buf[$y_pos + $i + 1]) << 8;
$colors[] = imagecolorallocate($img, ($color >> 10 & 0x1f) * 0xff / 0x1f, ($color >> 5 & 0x1f) * 0xff / 0x1f, ($color & 0x1f) * 0xff / 0x1f);
}
imagesetstyle($img, $colors);
imageline($img, 0, $info_header["biHeight"] - $y - 1, $info_header["biWidth"], $info_header["biHeight"] - $y - 1, IMG_COLOR_STYLED);
}
break;
case 24:
for ($y = 0; $y < $info_header["biHeight"]; $y++) {
$colors = array();
$y_pos = $y * $line_len + $file_header["bfOffBits"];
for ($x = 0; $x < $info_header["biWidth"]; $x++) {
$i = $x * 3;
$colors[] = imagecolorallocate($img, ord($buf[$y_pos + $i + 2]), ord($buf[$y_pos + $i + 1]), ord($buf[$y_pos + $i]));
}
imagesetstyle($img, $colors);
imageline($img, 0, $info_header["biHeight"] - $y - 1, $info_header["biWidth"], $info_header["biHeight"] - $y - 1, IMG_COLOR_STYLED);
}
break;
default:
return false;
break;
}
return $img;
}
开发者ID:xingskycn,项目名称:simple-php,代码行数:80,代码来源:Image.class.php
示例17: drawLine
/**
* Draw a line on image
*
* Currently used only for drawig borders/
* $begin and $end holds coordinates of begin and end points of line.
* $color can be:
* - integer - if line have to be solid
* - array - if line have to be an pattern ({@link http://php.net/imagesestyle})
*
* @param array $begin
* @param array $end
* @param mixed $color
* @param integer $thickness
*
* @return boolean
*
* @access public
*/
protected function drawLine(array $begin, array $end, $color, $thickness)
{
imagesetthickness($this->body, $thickness);
if (!is_array($color)) {
//solid
if (is_string($color)) {
$color = $this->color($color);
}
imageline($this->body, $begin[0], $begin[1], $end[0], $end[1], $color);
} else {
//pattern
imagesetstyle($this->body, $color);
imageline($this->body, $begin[0], $begin[1], $end[0], $end[1], IMG_COLOR_STYLED);
}
return true;
}
开发者ID:BackupTheBerlios,项目名称:core-svn,代码行数:34,代码来源:class_image.php
示例18: dashedLine
function dashedLine($image, $x1, $y1, $x2, $y2, $color)
{
// style for dashed lines
if (!is_array($color)) {
$style = array($color, $color, IMG_COLOR_TRANSPARENT, IMG_COLOR_TRANSPARENT);
} else {
$style = $color;
}
imagesetstyle($image, $style);
imageline($image, $x1, $y1, $x2, $y2, IMG_COLOR_STYLED);
}
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:11,代码来源:graphs.inc.php
示例19: SetDashedStyle
protected function SetDashedStyle($which_ndxcol, $use_style = TRUE)
{
if ($use_style) {
eval("\$style = {$this->default_dashed_style};");
// See SetDefaultDashedStyle() above
imagesetstyle($this->img, $style);
return IMG_COLOR_STYLED;
// Use this value as the color for drawing
}
return $which_ndxcol;
// Styles are off; use original color for drawing
}
开发者ID:danorama,项目名称:orsee,代码行数:12,代码来源:class.phplot.php
示例20: set
static function set(&$image, $value, $style = 'mix')
{
switch ($style) {
case 'border':
//画线粗细
return imagesetthickness($image, (int) $value);
case 'style':
//画线风格
return imagesetstyle($image, (array) $value);
case 'brush':
//画笔图像
return imagesetbrush($image, $value);
case 'pattern':
//填充的贴图 图案
return imagesettile($image, $value);
case 'alias':
//抗锯齿
return imageantialias($image, (bool) $value);
case 'alpha':
//alpha混色标志
return imagelayereffect($image, (int) $value);
case 'transparent':
//透明色
return imagecolortransparent($image, (int) $value);
case 'mix':
//混色模式
//混色模式
default:
return imagealphablending($image, (bool) $value);
}
}
开发者ID:mjiong,项目名称:framework,代码行数:31,代码来源:image.php
注:本文中的imagesetstyle函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论