本文整理汇总了PHP中imageLine函数的典型用法代码示例。如果您正苦于以下问题:PHP imageLine函数的具体用法?PHP imageLine怎么用?PHP imageLine使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imageLine函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: drawRhythm
function drawRhythm($daysAlive, $period, $color)
{
global $daysToShow, $image, $diagramWidth, $diagramHeight;
// get day on which to center
$centerDay = $daysAlive - ($daysToShow / 2);
// calculate diagram parameters
$plotScale = ($diagramHeight - 25) / 2;
$plotCenter = ($diagramHeight - 25) / 2;
// draw the curve
for($x = 0; $x <= $daysToShow; $x++)
{
// calculate phase of curve at this day, then Y value
// within diagram
$phase = (($centerDay + $x) % $period) / $period * 2 * pi();
$y = 1 - sin($phase) * (float)$plotScale + (float)$plotCenter;
// draw line from last point to current point
if($x > 0)
imageLine($image, $oldX, $oldY,
$x * $diagramWidth / $daysToShow, $y, $color);
// save current X/Y coordinates as start point for next line
$oldX = $x * $diagramWidth / $daysToShow;
$oldY = $y;
}
}
示例2: imagesmoothcircle
/**
* Credits goes to an anonymous at http://usphp.com/manual/ro/function.imageantialias.php
*/
function imagesmoothcircle(&$img, $cx, $cy, $cr, $color)
{
$ir = $cr;
$ix = 0;
$iy = $ir;
$ig = 2 * $ir - 3;
$idgr = -6;
$idgd = 4 * $ir - 10;
$fill = imageColorExactAlpha($img, $color['R'], $color['G'], $color['B'], 0);
imageLine($img, $cx + $cr - 1, $cy, $cx, $cy, $fill);
imageLine($img, $cx - $cr + 1, $cy, $cx - 1, $cy, $fill);
imageLine($img, $cx, $cy + $cr - 1, $cx, $cy + 1, $fill);
imageLine($img, $cx, $cy - $cr + 1, $cx, $cy - 1, $fill);
$draw = imageColorExactAlpha($img, $color['R'], $color['G'], $color['B'], 42);
imageSetPixel($img, $cx + $cr, $cy, $draw);
imageSetPixel($img, $cx - $cr, $cy, $draw);
imageSetPixel($img, $cx, $cy + $cr, $draw);
imageSetPixel($img, $cx, $cy - $cr, $draw);
while ($ix <= $iy - 2) {
if ($ig < 0) {
$ig += $idgd;
$idgd -= 8;
$iy--;
} else {
$ig += $idgr;
$idgd -= 4;
}
$idgr -= 4;
$ix++;
imageLine($img, $cx + $ix, $cy + $iy - 1, $cx + $ix, $cy + $ix, $fill);
imageLine($img, $cx + $ix, $cy - $iy + 1, $cx + $ix, $cy - $ix, $fill);
imageLine($img, $cx - $ix, $cy + $iy - 1, $cx - $ix, $cy + $ix, $fill);
imageLine($img, $cx - $ix, $cy - $iy + 1, $cx - $ix, $cy - $ix, $fill);
imageLine($img, $cx + $iy - 1, $cy + $ix, $cx + $ix, $cy + $ix, $fill);
imageLine($img, $cx + $iy - 1, $cy - $ix, $cx + $ix, $cy - $ix, $fill);
imageLine($img, $cx - $iy + 1, $cy + $ix, $cx - $ix, $cy + $ix, $fill);
imageLine($img, $cx - $iy + 1, $cy - $ix, $cx - $ix, $cy - $ix, $fill);
$filled = 0;
for ($xx = $ix - 0.45; $xx < $ix + 0.5; $xx += 0.2) {
for ($yy = $iy - 0.45; $yy < $iy + 0.5; $yy += 0.2) {
if (sqrt(pow($xx, 2) + pow($yy, 2)) < $cr) {
$filled += 4;
}
}
}
$draw = imageColorExactAlpha($img, $color['R'], $color['G'], $color['B'], 100 - $filled);
imageSetPixel($img, $cx + $ix, $cy + $iy, $draw);
imageSetPixel($img, $cx + $ix, $cy - $iy, $draw);
imageSetPixel($img, $cx - $ix, $cy + $iy, $draw);
imageSetPixel($img, $cx - $ix, $cy - $iy, $draw);
imageSetPixel($img, $cx + $iy, $cy + $ix, $draw);
imageSetPixel($img, $cx + $iy, $cy - $ix, $draw);
imageSetPixel($img, $cx - $iy, $cy + $ix, $draw);
imageSetPixel($img, $cx - $iy, $cy - $ix, $draw);
}
}
示例3: drawFunction
function drawFunction($function, $dx = 0.1)
{
$xold = $x = $this->x0;
eval("\$yold=" . $function . ";");
for ($x += $dx; $x <= $this->x1; $x += $dx) {
eval("\$y = " . $function . ";");
imageLine($this->img, $this->posX0 + $xold * $this->scale, $this->posY0 - $yold * $this->scale, $this->posX0 + $x * $this->scale, $this->posY0 - $y * $this->scale, $this->grn);
$xold = $x;
$yold = $y;
}
}
示例4: imageSmoothArcDrawSegment
function imageSmoothArcDrawSegment(&$img, $cx, $cy, $a, $b, $color, $start, $stop, $seg)
{
// Originally written from scratch by Ulrich Mierendorff, 06/2006
// Rewritten and improved, 04/2007, 07/2007
// Optimized circle version: 03/2008
// Please do not use THIS function directly. Scroll down to imageSmoothArc(...).
$fillColor = imageColorExactAlpha($img, $color[0], $color[1], $color[2], $color[3]);
switch ($seg) {
case 0:
$xp = +1;
$yp = -1;
$xa = 1;
$ya = -1;
break;
case 1:
$xp = -1;
$yp = -1;
$xa = 0;
$ya = -1;
break;
case 2:
$xp = -1;
$yp = +1;
$xa = 0;
$ya = 0;
break;
case 3:
$xp = +1;
$yp = +1;
$xa = 1;
$ya = 0;
break;
}
for ($x = 0; $x <= $a; $x += 1) {
$y = $b * sqrt(1 - $x * $x / ($a * $a));
$error = $y - (int) $y;
$y = (int) $y;
$diffColor = imageColorExactAlpha($img, $color[0], $color[1], $color[2], 127 - (127 - $color[3]) * $error);
imageSetPixel($img, $cx + $xp * $x + $xa, $cy + $yp * ($y + 1) + $ya, $diffColor);
imageLine($img, $cx + $xp * $x + $xa, $cy + $yp * $y + $ya, $cx + $xp * $x + $xa, $cy + $ya, $fillColor);
}
for ($y = 0; $y < $b; $y += 1) {
$x = $a * sqrt(1 - $y * $y / ($b * $b));
$error = $x - (int) $x;
$x = (int) $x;
$diffColor = imageColorExactAlpha($img, $color[0], $color[1], $color[2], 127 - (127 - $color[3]) * $error);
imageSetPixel($img, $cx + $xp * ($x + 1) + $xa, $cy + $yp * $y + $ya, $diffColor);
}
}
示例5: getPNG
public function getPNG()
{
// создаем картинку
$image = imageCreate($this->width + $this->widthLegend, $this->height);
$backColor = imageColorAllocate($image, $this->colorBG >> 16, ($this->colorBG >> 8) % 256, $this->colorBG % 256);
$centerColor = imageColorAllocate($image, $this->colorCenter >> 16, ($this->colorCenter >> 8) % 256, $this->colorCenter % 256);
$pointsColor = imageColorAllocate($image, $this->colorPoints >> 16, ($this->colorPoints >> 8) % 256, $this->colorPoints % 256);
$legendColor = imageColorAllocate($image, $this->colorLegend >> 16, ($this->colorLegend >> 8) % 256, $this->colorLegend % 256);
// background
imageFilledRectangle($image, 0, 0, $this->width, $this->height, $backColor);
imageRectangle($image, $this->width, 0, $this->widthLegend + $this->width - 1, $this->height - 1, $legendColor);
// добавляем масштаб в легенду
imageLine($image, $this->width + 10, $this->height - $this->fontSize * 2 - 1, $this->width + 10, $this->height - $this->fontSize * 2 + 1, $legendColor);
imageLine($image, $this->width + 10, $this->height - $this->fontSize * 2, $this->width + 20, $this->height - $this->fontSize * 2, $legendColor);
imageLine($image, $this->width + 20, $this->height - $this->fontSize * 2 - 1, $this->width + 20, $this->height - $this->fontSize * 2 + 1, $legendColor);
imageTTFText($image, $this->fontSize, 0, $this->width + $this->fontSize + 20, $this->height - $this->fontSize * 1.5, $legendColor, $this->pathToFont, "{$this->metersIn10Pix} {$this->metersLabel}");
// center
imageFilledEllipse($image, $this->centerWidth, $this->centerHeight, $this->sizePoints, $this->sizePoints, $centerColor);
imageTTFText($image, $this->fontSize, 0, $this->centerWidth, $this->centerHeight + $this->fontSize + $this->sizePoints, $centerColor, $this->pathToFont, "0");
imageTTFText($image, $this->fontSize, 0, $this->width + $this->fontSize, $this->fontSize * 2, $legendColor, $this->pathToFont, "0 - {$this->centerLabel}");
// points
$i = 1;
foreach ($this->pointsBased as $v) {
$angle = $v->getPoint()->getAzimuth() - 90;
// угол для тригонометрии
$pointWidth = $this->centerWidth + $this->k * ($v->getPoint()->getDistance() * cos(deg2rad($angle)));
$pointHeight = $this->centerHeight + $this->k * ($v->getPoint()->getDistance() * sin(deg2rad($angle)));
// рисуем точку
imageEllipse($image, $pointWidth, $pointHeight, $this->sizePoints, $this->sizePoints, $pointsColor);
// подпись
imageTTFText($image, $this->fontSize, 0, $pointWidth, $pointHeight + $this->fontSize + $this->sizePoints, $pointsColor, $this->pathToFont, $i);
// в легенду
imageTTFText($image, $this->fontSize, 0, $this->width + $this->fontSize, $this->fontSize * 2 * ($i + 1), $legendColor, $this->pathToFont, "{$i} - " . $v->getTitle());
$i++;
}
ob_start();
imagePng($image);
$str = ob_get_clean();
return $str;
}
示例6: imageSmoothArcDrawSegment
//.........这里部分代码省略.........
$ya = 0;
} else {
$xp = -1;
$yp = +1;
$xa = 0;
$ya = +1;
}
if ($stop < ($i + 1) * (M_PI / 2) && $x <= $xStop) {
$diffColor1 = imageColorExactAlpha($img, $color[0], $color[1], $color[2], 127 - (127 - $color[3]) * $error1);
$y1 = $_y1;
if ($aaStopX) {
imageSetPixel($img, $cx + $xp * $x + $xa, $cy + $yp * ($y1 + 1) + $ya, $diffColor1);
}
} else {
$y = $b * sqrt(1 - $x * $x / ($a * $a));
$error = $y - (int) $y;
$y = (int) $y;
$diffColor = imageColorExactAlpha($img, $color[0], $color[1], $color[2], 127 - (127 - $color[3]) * $error);
$y1 = $y;
if ($x < $aaAngleX) {
imageSetPixel($img, $cx + $xp * $x + $xa, $cy + $yp * ($y1 + 1) + $ya, $diffColor);
}
}
if ($start > $i * M_PI / 2 && $x <= $xStart) {
$diffColor2 = imageColorExactAlpha($img, $color[0], $color[1], $color[2], 127 - (127 - $color[3]) * $error2);
$y2 = $_y2;
if ($aaStartX) {
imageSetPixel($img, $cx + $xp * $x + $xa, $cy + $yp * ($y2 - 1) + $ya, $diffColor2);
}
} else {
$y2 = 0;
}
if ($y2 <= $y1) {
imageLine($img, $cx + $xp * $x + $xa, $cy + $yp * $y1 + $ya, $cx + $xp * $x + $xa, $cy + $yp * $y2 + $ya, $fillColor);
}
}
}
if ($seg == 1 || $seg == 3) {
$i = $seg;
if (!($stop < ($i + 1) * M_PI / 2 && $x > $xStop)) {
if ($i == 1) {
$xp = -1;
$yp = -1;
$xa = 0;
$ya = 0;
} else {
$xp = +1;
$yp = +1;
$xa = 1;
$ya = 1;
}
if ($start > $i * M_PI / 2 && $x < $xStart) {
$diffColor2 = imageColorExactAlpha($img, $color[0], $color[1], $color[2], 127 - (127 - $color[3]) * $error2);
$y1 = $_y2;
if ($aaStartX) {
imageSetPixel($img, $cx + $xp * $x + $xa, $cy + $yp * ($y1 + 1) + $ya, $diffColor2);
}
} else {
$y = $b * sqrt(1 - $x * $x / ($a * $a));
$error = $y - (int) $y;
$y = (int) $y;
$diffColor = imageColorExactAlpha($img, $color[0], $color[1], $color[2], 127 - (127 - $color[3]) * $error);
$y1 = $y;
if ($x < $aaAngleX) {
imageSetPixel($img, $cx + $xp * $x + $xa, $cy + $yp * ($y1 + 1) + $ya, $diffColor);
}
示例7: drawRoundedRectangle
/**
* Draws a rectangle with rounded corners on the image
* @param Point $leftTop Point of the upper left corner
* @param Dimension $dimension Dimension of the rectangle
* @param integer $cornerSize The number of pixels which should be round of
* @param Color $color
* @param integer $width
* @return null
*/
public function drawRoundedRectangle(Point $leftTop, Dimension $dimension, $cornerSize, $color)
{
$color = $this->allocateColor($color);
$x = $leftTop->getX();
$y = $leftTop->getY();
$width = $dimension->getWidth();
$height = $dimension->getHeight();
$cornerWidth = $cornerSize * 2;
$innerWidth = $width - $cornerWidth;
$innerHeight = $height - $cornerWidth;
// left top
imageArc($this->resource, $x + $cornerSize, $y + $cornerSize, $cornerWidth, $cornerWidth, 180, 270, $color);
// top
imageLine($this->resource, $x + $cornerSize, $y, $x + $width - $cornerSize, $y, $color);
// right top
imageArc($this->resource, $x + $width - $cornerSize, $y + $cornerSize, $cornerWidth, $cornerWidth, 270, 360, $color);
// center
imageLine($this->resource, $x, $y + $cornerSize, $x, $y + $height - $cornerSize, $color);
imageLine($this->resource, $x + $width, $y + $cornerSize, $x + $width, $y + $height - $cornerSize, $color);
// left down
imageArc($this->resource, $x + $cornerSize, $y + $height - $cornerSize, $cornerWidth, $cornerWidth, 90, 180, $color);
// down
imageLine($this->resource, $x + $cornerSize, $y + $height, $x + $width - $cornerSize, $y + $height, $color);
// right down
imageArc($this->resource, $x + $width - $cornerSize, $y + $height - $cornerSize, $cornerWidth, $cornerWidth, 0, 90, $color);
}
示例8: makeCharter
function makeCharter($competitor_name, $competitor_points, $class_id, $path, $print_with_results, $charter_type, $year)
{
$this->load->model('settings_model');
$print_settings = $this->settings_model->getPrintSettings();
foreach ($print_settings as $setting_key => $print_setting) {
//schaut ob es überhaupt mit der pixelverschiebung zu tun hat:
if ($setting_key != str_replace("axis", "", $setting_key)) {
${$setting_key} = $print_setting['setting_value'];
}
}
$total_points = $competitor_points['total_points'];
$textnr = 4;
$width = 420;
$height = 595;
if ($charter_type == 'honor') {
$width = 850;
$move_x_axis = 529 + $move_x_axis;
$move_y_axis = 112 + $move_y_axis;
}
$im = imagecreate($width, $height);
//Dicke der Linien festlegen
imagesetthickness($im, 50);
//Breite und Höhe des $im Objekts
$image_height = ImageSY($im);
$image_width = ImageSX($im);
//Farben
$black = ImageColorAllocate($im, 0, 0, 0);
//Schriften (arial)
$font = '/libs/fonts/Arial.ttf';
#!!!!!!!!!!!!!!!!!!!!!!!!!!
$font_height = ImageFontHeight(2);
$font_width = ImageFontWidth(2);
$length = $font_width * strlen($competitor_name);
//Mitte des Bildes
$image_center_x = $image_width / 2 - $length / 2;
$image_center_y = $image_height / 2 - $font_height / 2;
//Transparenten Hintergrund erstellen
$im = imagecreatetruecolor($width, $height);
imagesavealpha($im, true);
imagealphablending($im, false);
$background = imagecolorallocatealpha($im, 255, 255, 255, 127);
imagefilledrectangle($im, 0, 0, $width, $height, $background);
imagealphablending($im, true);
//"Drucke" die Jahreszahl
$x_year = 317 + $move_x_axis;
$y_year = 161 + $move_y_axis;
imagettftext($im, 7, 0, $x_year, $y_year, $black, $font, $year);
//"Drucke" den Competitor Name
$x_competitor_name = $image_center_x + $move_x_axis;
$y_competitor_name = 356 + $move_y_axis;
if ($charter_type == 'honor') {
$x_competitor_name = $x_competitor_name - 190;
}
imagettftext($im, 15, 0, $x_competitor_name, $y_competitor_name, $black, $font, $competitor_name);
//"Drucke" die Gesamtpunktzahl
$x_competitor_points = 190 + $move_x_axis;
$y_competitor_points = 295 + $move_y_axis;
imagettftext($im, 15, 0, $x_competitor_points, $y_competitor_points, $black, $font, $total_points);
//sport_section_2
$x_sport_section_2_1 = 203 + $move_x_axis;
$x_sport_section_2_2 = 267 + $move_x_axis;
$y_sport_section_2 = 218 + $move_y_axis;
imageLine($im, $x_sport_section_2_1, $y_sport_section_2, $x_sport_section_2_2, $y_sport_section_2, $black);
//sport_section_3
$x_sport_section_3_1 = 203 + $move_x_axis;
$x_sport_section_3_2 = 267 + $move_x_axis;
$y_sport_section_3 = 247 + $move_y_axis;
imageLine($im, $x_sport_section_3_1, $y_sport_section_3, $x_sport_section_3_2, $y_sport_section_3, $black);
//druck auch die Ergebnisse
if ($print_with_results) {
//hier können dann die Ergebnisse rein
}
//wandelt leerzeichen und Umlaute um, schreibt alles klein
$upas = array("ä" => "ae", "ü" => "ue", "ö" => "oe", "Ä" => "Ae", "Ü" => "Ue", "Ö" => "Oe");
$file_name = str_replace(' ', '_', $competitor_name);
$file_name = strtr($file_name, $upas);
$file_name = strtolower($file_name);
$charter_path = './output/' . $path . '/' . $class_id . '_' . $file_name . '.png';
ImagePNG($im, $charter_path);
}
示例9: log10
//$count=$count/1000*50;//lin
$count = log10($count + 1.0) * ($va / log10(2000));
if ($count > $max2) {
$max2 = $count;
}
if ($count > 0) {
imageLine($image, $i, $j * $va + $vs - $count, $i, $j * $va + $vs, $green);
}
$j++;
}
//while
$i++;
$i++;
}
//for $mo
imageLine($image, $i, $vs - $va * 2, $i, $diagramHeight - 1, $black);
}
//for $y
$j = 0;
foreach ($cats as $cat) {
imageFilledRectangle($image, 1, $j * $va + $vs - ($va - 1), $hs - 1, $j * $va + $vs - ($va - 11), $colorBackgr);
imageString($image, 3, 2, $j * $va + $vs - $va, "{$cats[$j]}", $black);
$j++;
}
pg_close($dbconn);
echo "max records/month= {$max} max2 pixels= {$max2}<br>\n";
//create an interlaced image for better loadingin the browser
imageInterlace($image, 1);
//mark background coloras being transparent
//imageColorTransparent($image,$colorBackgr);
imagePNG($image, "{$secdir}/hec.png");
示例10: imageCreateTrueColor
/* Создание изображения */
// $i = imageCreate(500, 300);
$i = imageCreateTrueColor(500, 300);
/* Подготовка к работе */
imageAntiAlias($i, true);
$red = imageColorAllocate($i, 255, 0, 0);
$white = imageColorAllocate($i, 0xff, 0xff, 0xff);
$black = imageColorAllocate($i, 0, 0, 0);
$green = imageColorAllocate($i, 0, 255, 0);
$blue = imageColorAllocate($i, 0, 0, 255);
$grey = imageColorAllocate($i, 192, 192, 192);
imageFill($i, 0, 0, $grey);
/* Рисуем примитивы */
imageSetPixel($i, 10, 10, $black);
imageLine($i, 20, 20, 280, 180, $red);
imageRectangle($i, 20, 20, 280, 180, $blue);
//array of dots
$points = [120, 120, 100, 200, 300, 200];
imagePolygon($i, $points, 3, $green);
imageEllipse($i, 200, 150, 300, 200, $red);
// imageArc($i, 210, 160, 300, 200, 0, 90, $black);
imageFilledArc($i, 200, 150, 300, 200, 0, 40, $red, IMG_ARC_PIE);
/* Рисуем текст */
imageString($i, 5, 150, 200, 'php7', $black);
imageCharUp($i, 3, 200, 200, 'PHP5', $blue);
imageTtfText($i, 30, 10, 300, 150, $green, 'arial.ttf', 'PHP7');
/* Отдаем изображение */
// header("Content-type: image/gif");
// imageGif($i);
header("Content-type: image/png");
示例11: imageLine
}
$xline = $xline + $grid_spacing;
imageLine($img, $xline, 0, $xline, $img_height, $color);
}
// Y Axis
for ($y = 0; $y < $grid_y_inc; $y++) {
if ($img_grid_random_color) {
$r = rand($txt_rgb_min, $txt_rgb_max);
$g = rand($txt_rgb_min, $txt_rgb_max);
$b = rand($txt_rgb_min, $txt_rgb_max);
$color = imageColorAllocate($img, $r, $g, $b);
} else {
$color = $black;
}
$yline = $yline + $grid_spacing;
imageLine($img, 0, $yline, $img_width, $yline, $color);
}
}
// Border
if ($img_use_border) {
imageRectangle($img, 0, 0, $img_width - 1, $img_height - 1, $black);
}
$string_len = strlen($string);
$position = $txt_horizontal_pos;
// Looping through each letter
for ($i = 0; $i < $string_len; $i++) {
$c = $string[$i];
// Angle
if ($txt_use_angles) {
$angle = rand($txt_letter_angle_min, $txt_letter_angle_max);
} else {
示例12: confirmImage
/**
* Функция генерирует и выводит хидер PNG и изображение с кодом подтверждения (код берется из массива полей)
* Возвращает результат выполнения imagePNG
* @return bool
*/
function confirmImage() {
$width = ajaxform::$captcha[width];
$height = ajaxform::$captcha[height];
$multi = 4;
$xwidth = $width * $multi;
$xheight = $height * $multi;
$code = $this->fields[confirm][value];
$im = imageCreateTrueColor($xwidth, $xheight);
$w = imageColorAllocate($im, 255, 255, 255);
$b = imageColorAllocate($im, 000, 000, 000);
$g = imageColorAllocate($im, 100, 100, 100);
imageFill($im, 1, 1, $w);
$w = imageColorTransparent($im, $w);
$r = mt_rand(0, $xheight);
for ($x = 0; $x < $xwidth + $xheight; $x += 4 * $multi) {
for ($i = 0; $i < $multi; $i++)
imageLine($im, $x + $i, 0, $x + $i - $xheight, $xheight + $r, $g);
}
$arr = preg_split('//', $code, -1, PREG_SPLIT_NO_EMPTY);
for ($i = 0; $i < count($arr); $i++) {
$x = ($xwidth * 0.04) + (floor(($xwidth * 0.97) * 0.167)) * $i; // разрядка
$y = ($xheight * 0.8);
$s = ($xheight * 0.5) * (96 / 72); // 96 — res
$a = mt_rand(-20, 20);
imageTTFText($im, $s, $a, $x, $y, $b, $_SERVER[DOCUMENT_ROOT] . "/lib/core/classes/form_ajax/consolas.ttf", $arr[$i]); //
}
$temp = imageCreateTrueColor($xwidth, $xheight);
$w = imageColorAllocate($temp, 255, 255, 255);
imageFill($temp, 1, 1, $w);
$w = imageColorTransparent($temp, $w);
$phase = rand(-M_PI, M_PI);
$frq = 2 * M_PI / $xheight;
$amp = $xwidth * 0.02;
for ($y = 0; $y < $xheight; $y++) {
$dstx = $amp + sin($y * $frq + $phase) * $amp;
imagecopy($temp, $im, $dstx, $y, 0, $y, $xwidth, 1);
//imagesetpixel($im, $dstx, $y, $b);
}
$res = imageCreateTrueColor($width, $height);
$w = imageColorAllocate($res, 255, 255, 255);
imageFill($res, 1, 1, $w);
$w = imageColorTransparent($res, $w);
imageCopyResampled($res, $temp, 0, 0, 0, 0, $width, $height, $xwidth, $xheight);
imageTrueColorToPalette($res, true, 256);
header("CONTENT-TYPE: IMAGE/PNG");
return imagePNG($res);
}
示例13: 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;
// note: though gradients on the chart looks ok, the formula used is completely incorrect
// if you plan to fix something here, it would be better to start from scratch
$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;
}
}
示例14: renderGeometry
function renderGeometry($pointArrayQuery, $geometry, $brush, $r, $b, $g)
{
$this->renderGeometryArray[] = array($this->convertpointarray($pointArrayQuery), $geometry, $brush, $r, $b, $g);
global $render_im;
$imgName = "render.png";
if (!$render_im[$this->controlId]) {
$render_im[$this->controlId] = imagecreate($this->width, $this->height);
}
$background_color = imagecolorallocate($render_im[$this->controlId], 255, 255, 255);
$NewPointArray = explode("|", $pointArrayQuery);
$line_color = imagecolorallocate($render_im[$this->controlId], 34, 255, 91);
$brush_im = imagecreate($brush, $brush);
$brush_color = imagecolorallocate($brush_im, $r, $b, $g);
imageLine($brush_im, 8, 0, 8, 16, $brush_color);
imageLine($brush_im, 0, 8, 16, 8, $brush_color);
imagesetbrush($render_im[$this->controlId], $brush_im);
$geometry = strtoupper($geometry);
if ($geometry == "MULTIPOINT") {
$geometry = "POINT";
}
if ($geometry == "MULTILINE" || $geometry == "MULTILINESTRING" || $geometry == "LINESTRING") {
$geometry = "LINE";
}
if ($geometry == "MULTIPOLYGON") {
$geometry = "LINE";
}
//echo "<script>alert('$geometry')</script>";
switch ($geometry) {
case "POINT":
for ($i = 0; $i < sizeof($NewPointArray); $i++) {
$pixCoord = explode(",", $NewPointArray[$i]);
$marker_im = imagecreate(11, 11);
$background_color = imagecolorallocate($marker_im, 255, 255, 255);
$line_color = imagecolorallocate($marker_im, $r, $b, $g);
imageLine($marker_im, 5, 0, 5, 11, $line_color);
imageLine($marker_im, 0, 5, 11, 5, $line_color);
imagecopy($render_im[$this->controlId], $marker_im, $pixCoord[0] - 5, $pixCoord[1] - 5, 0, 0, 11, 11);
imagedestroy($marker_im);
}
break;
case "LINE":
// echo "<script>alert('line')</script>";
for ($i = 0; $i < sizeof($NewPointArray); $i++) {
for ($u = 0; $u < 2; $u++) {
$pixCoord[$u] = explode(",", $NewPointArray[$i + $u]);
}
if ($pixCoord[1][0]) {
imageLine($render_im[$this->controlId], $pixCoord[0][0], $pixCoord[0][1], $pixCoord[1][0], $pixCoord[1][1], IMG_COLOR_BRUSHED);
}
// echo "<script>alert('".$pixCoord[1][0]."','".$pixCoord[1][1]."');</script>";
}
break;
case "POLYGON":
//echo "<script>alert('polygon')</script>";
$pointArrayQuery = str_replace("|", ",", $pointArrayQuery);
$array = explode(",", $pointArrayQuery);
@imagepolygon($render_im[$this->controlId], $array, sizeof($NewPointArray), IMG_COLOR_BRUSHED);
break;
}
//$test=imagepng($render_im[$this -> controlId], "render.png");
//echo "<script>alert('render=$test')</script>";
imagedestroy($brush_im);
}
示例15: buildLegRight
public function buildLegRight()
{
imageLine($this->img, 170, 190, 170, 250, 5);
}