本文整理汇总了PHP中ImageFillToBorder函数的典型用法代码示例。如果您正苦于以下问题:PHP ImageFillToBorder函数的具体用法?PHP ImageFillToBorder怎么用?PHP ImageFillToBorder使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ImageFillToBorder函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getShape
public function getShape()
{
$c = $this->_points[2];
// base
$b = $this->_points[1];
// sides
$a = $this->_points[0];
// calculate angle, cosine rule
$alpha = acos((pow($b, 2) + pow($c, 2) - pow($a, 2)) / (2 * $b * $c));
// pythag to calc height and y distance
$height = abs(sin($alpha)) * $b;
$width = abs(cos($alpha)) * $b;
$x = 0;
// start point
$y = 100;
$points = array($x, $y, $x + $c, $y, $x + $width, $y - $height);
// draw
$image = imagecreatetruecolor(100, 100);
// sets background to red
$white = ImageColorAllocate($image, 255, 255, 255);
ImageFillToBorder($image, 0, 0, $white, $white);
$blue = imagecolorallocate($image, 0, 0, 255);
imagefilledpolygon($image, $points, 3, $blue);
return $image;
}
示例2: 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);
}
示例3: 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);
}
示例4: draw_brush
function draw_brush($x, $y, $size, $type, $colour)
{
$x = round($x);
$y = round($y);
$half = round($size / 2);
switch ($type) {
case 'circle':
ImageArc($this->image, $x, $y, $size, $size, 0, 360, $this->colour[$colour]);
ImageFillToBorder($this->image, $x, $y, $this->colour[$colour], $this->colour[$colour]);
break;
case 'square':
ImageFilledRectangle($this->image, $x - $half, $y - $half, $x + $half, $y + $half, $this->colour[$colour]);
break;
case 'vertical':
ImageFilledRectangle($this->image, $x, $y - $half, $x + 1, $y + $half, $this->colour[$colour]);
break;
case 'horizontal':
ImageFilledRectangle($this->image, $x - $half, $y, $x + $half, $y + 1, $this->colour[$colour]);
break;
case 'slash':
ImageFilledPolygon($this->image, array($x + $half, $y - $half, $x + $half + 1, $y - $half, $x - $half + 1, $y + $half, $x - $half, $y + $half), 4, $this->colour[$colour]);
break;
case 'backslash':
ImageFilledPolygon($this->image, array($x - $half, $y - $half, $x - $half + 1, $y - $half, $x + $half + 1, $y + $half, $x + $half, $y + $half), 4, $this->colour[$colour]);
break;
default:
@eval($type);
// user can create own brush script.
}
}
示例5: round
$end_y = round(150 + $radius * sin($last_angle * pi() / 180));
ImageLine($im, 150, 150, $end_x, $end_y, $black);
}
$prev_angle = 0;
$pointer = 0;
for ($z = 0; $z < $countqw; $z++) {
$pointer = $prev_angle + $degrees[$z];
$this_angle = ($prev_angle + $pointer) / 2;
$prev_angle = $pointer;
$end_x = round(150 + $radius * cos($this_angle * pi() / 180));
$end_y = round(150 + $radius * sin($this_angle * pi() / 180));
$mid_x = round((150 + $end_x) / 2);
$mid_y = round((150 + $end_y) / 2);
$hexCodeSplit = explode(',', $hexCode[$z]);
$WedgeColor = ImageColorAllocate($im, $hexCodeSplit[0], $hexCodeSplit[1], $hexCodeSplit[2]);
ImageFillToBorder($im, $mid_x, $mid_y, $black, $WedgeColor);
}
ImageString($im, 3, 10, 10, "{$title}", $black);
$red = ImageColorAllocate($im, 255, 153, 153);
$blue = ImageColorAllocate($im, 0, 0, 255);
$adjPosition = 20;
for ($z = 0; $z < $degCount; $z++) {
$percent = $degrees[$z] / 360 * 100;
$percent = round($percent, 2);
$adjPosition = $adjPosition + 15;
$hexCodeSplit = explode(',', $hexCode[$z]);
$percentLen = strlen($percent);
if ($percentLen == '4') {
$percent = " " . "{$percent}";
}
if ($percentLen == '3') {
示例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: RoundedImageCorners
function RoundedImageCorners()
{
if (phpthumb_functions::gd_version() < 2) {
return false;
}
if (!empty($this->brx) && !empty($this->bry) && $this->bw == 0) {
$gdimg_cornermask = $this->ImageCreateFunction($this->thumbnail_width, $this->thumbnail_height);
$background_color_cornermask = phpthumb_functions::ImageHexColorAllocate($gdimg_cornermask, $this->config_background_hexcolor);
$border_color_cornermask = phpthumb_functions::ImageHexColorAllocate($gdimg_cornermask, $this->config_border_hexcolor);
// Top Left
ImageArc($gdimg_cornermask, $this->brx - 1, $this->bry - 1, $this->brx * 2, $this->bry * 2, 180, 270, $background_color_cornermask);
ImageFillToBorder($gdimg_cornermask, 0, 0, $background_color_cornermask, $background_color_cornermask);
// Top Right
ImageArc($gdimg_cornermask, $this->thumbnail_width - $this->brx, $this->bry - 1, $this->brx * 2, $this->bry * 2, 270, 360, $background_color_cornermask);
ImageFillToBorder($gdimg_cornermask, $this->thumbnail_width, 0, $background_color_cornermask, $background_color_cornermask);
// Bottom Right
ImageArc($gdimg_cornermask, $this->thumbnail_width - $this->brx, $this->thumbnail_height - $this->bry, $this->brx * 2, $this->bry * 2, 0, 90, $background_color_cornermask);
ImageFillToBorder($gdimg_cornermask, $this->thumbnail_width, $this->thumbnail_height, $background_color_cornermask, $background_color_cornermask);
// Bottom Left
ImageArc($gdimg_cornermask, $this->brx - 1, $this->thumbnail_height - $this->bry, $this->brx * 2, $this->bry * 2, 90, 180, $background_color_cornermask);
ImageFillToBorder($gdimg_cornermask, 0, $this->thumbnail_height, $background_color_cornermask, $background_color_cornermask);
$transparent_color_cornermask = ImageColorTransparent($gdimg_cornermask, ImageColorAt($gdimg_cornermask, round($this->thumbnail_width / 2), round($this->thumbnail_height / 2)));
ImageArc($gdimg_cornermask, $this->brx, $this->bry, $this->brx * 2, $this->bry * 2, 180, 270, $transparent_color_cornermask);
ImageArc($gdimg_cornermask, $this->thumbnail_width - $this->brx, $this->bry, $this->brx * 2, $this->bry * 2, 270, 360, $transparent_color_cornermask);
ImageArc($gdimg_cornermask, $this->thumbnail_width - $this->brx, $this->thumbnail_height - $this->bry, $this->brx * 2, $this->bry * 2, 0, 90, $transparent_color_cornermask);
ImageArc($gdimg_cornermask, $this->brx, $this->thumbnail_height - $this->bry, $this->brx * 2, $this->bry * 2, 90, 180, $transparent_color_cornermask);
ImageCopyMerge($this->gdimg_output, $gdimg_cornermask, 0, 0, 0, 0, $this->thumbnail_width, $this->thumbnail_height, 100);
// Make rounded corners transparent (optional)
if (!empty($this->bct)) {
if ($this->bct == 256) {
ImageTrueColorToPalette($this->gdimg_output, true, 256);
}
ImageColorTransparent($this->gdimg_output, ImageColorAt($this->gdimg_output, 0, 0));
}
}
return true;
}
示例8: ImageString
$weekday[2] = 'Tuesday';
$weekday[3] = 'Wednesday';
$weekday[4] = 'Thursday';
$weekday[5] = 'Friday';
$weekday[6] = 'Saturday';
for ($day = 0; $day < count($weekday); $day++) {
ImageString($im, 2, $x, $y, $weekday[$day], $black);
for ($i = 0; $i < 24 * 6; $i++) {
ImageRectangle($im, $x1 + $i * 4, $y, $x1 + ($i + 1) * 4, $y + 12, $plomo);
if ($i >= $initPeriod1 * 6 && $i < $endPeriod2 * 6 && ($i < $endPeriod1 * 6 || $i >= $initPeriod2 * 6)) {
$color = $orange;
} else {
$color = $white;
}
if (isset($noWorkingDays[$day]) && $noWorkingDays[$day]) {
$color = $white;
}
ImageFillToBorder($im, $x1 + $i * 4 + 1, $y + 1, $plomo, $color);
}
$y += 18;
}
$y = 20;
for ($i = 0; $i <= 24; $i++) {
ImageLine($im, $x1 + $i * 4 * 6, $y - 5, $x1 + $i * 4 * 6, $y - 5 + 18 * $cant, $gris);
if ($i < 24) {
ImageLine($im, $x2 + $i * 4 * 6, $y - 5, $x2 + $i * 4 * 6, $y - 5 + 18 * $cant, $plomo);
ImageString($im, 1, $x1 + $i * 4 * 6, $y - 10, $i, $black);
}
}
//ImageString($im, 2, 5, 5, $initPeriod1*6 . ", $endPeriod1, $initPeriod2, $endPeriod2 ", $black);
ImageJpeg($im);
示例9: popupimage
function popupimage($pf, $uid, $popupgoalname)
{
/*****************start********************/
$imageWidth = 78;
//image width
$imageHeight = 78;
//image height
$diameter = 78;
//pie diameter
$centerX = 39;
//pie center pixels x
$centerY = 39;
//pie center pixels y
$labelWidth = 5;
//label width, no need to change
/*************************End****************************/
$data = array($pf, 100 - $pf);
for ($i = 0; $i < count($data); $i++) {
$dataTotal += $data[$i];
}
$im = ImageCreate($imageWidth, $imageHeight);
$color[] = ImageColorAllocate($im, 39, 166, 194);
//red
$color[] = ImageColorAllocate($im, 255, 115, 30);
//yellow
$white = ImageColorAllocate($im, 255, 255, 255);
$black = ImageColorAllocate($im, 0, 0, 0);
$grey = ImageColorAllocate($im, 215, 215, 215);
ImageFill($im, 0, 0, $white);
$degree = 0;
for ($i = 0; $i < count($data); $i++) {
$startDegree = round($degree);
$degree += $data[$i] / $dataTotal * 360;
$endDegree = round($degree);
$currentColor = $color[$i % count($color)];
ImageArc($im, $centerX, $centerY, $diameter, $diameter, $startDegree, $endDegree, $currentColor);
list($arcX, $arcY) = $this->circlePoint($startDegree, $diameter);
ImageLine($im, $centerX, $centerY, floor($centerX + $arcX), floor($centerY + $arcY), $currentColor);
list($arcX, $arcY) = $this->circlePoint($endDegree, $diameter);
ImageLine($im, $centerX, $centerY, ceil($centerX + $arcX), ceil($centerY + $arcY), $currentColor);
$midPoint = round(($endDegree - $startDegree) / 2 + $startDegree);
list($arcX, $arcY) = $this->circlePoint($midPoint, $diameter / 1.5);
ImageFillToBorder($im, floor($centerX + $arcX), floor($centerY + $arcY), $currentColor, $currentColor);
if ($i == 0) {
ImageString($im, 5, floor($centerX + $arcX), floor($centerY + $arcY), intval(round($data[$i] / $dataTotal * 100)) . "%", $white);
}
}
$filename = $popupgoalname . $uid . ".png";
Header("Content-type: image/PNG");
ImagePNG($im, "htdocs/popupgoal/" . $filename);
return $filename;
}
示例10: 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);
}
}
}
}
示例11: ImageColorAllocate
//white bkgrnd
$blue = ImageColorAllocate($im, 0, 127, 255);
$purple = ImageColorAllocate($im, 186, 124, 237);
$light_violet = ImageColorAllocate($im, 243, 241, 254);
$black = ImageColorAllocate($im, 00, 00, 00);
$pink = ImageColorAllocate($im, 255, 206, 206);
$light_pink = ImageColorAllocate($im, 255, 243, 243);
$dark_pink = ImageColorAllocate($im, 238, 102, 102);
$red = ImageColorAllocate($im, 255, 0, 0);
$green = ImageColorAllocate($im, 0, 255, 0);
$yellow = ImageColorAllocate($im, 255, 255, 0);
/*calculate the divisions */
$hdiv = (int) $w / 42;
$vdiv = (int) $h / 81;
/* fill the form with color */
ImageFillToBorder($im, 2, 2, $blue, $light_pink);
$lab_x1 = (int) ($w - $label_w) / 2;
$lab_y1 = (int) ($label_h + 1);
ImageFilledRectangle($im, $lab_x1 - 7, 1, $lab_x1 + $label_w + 14, $lab_y1 + 14, $dark_pink);
/* Copy the patient label into the form */
ImageCopy($im, $label, $lab_x1 + 4, 8, 0, 0, $label_w, $label_h);
/* Write the info part */
ImageString($im, 5, $left_border, 15, $LDHospitalName, $dark_pink);
ImageString($im, 4, $left_border, 30, $LDCentralLab, $dark_pink);
/* Create the synchronizing blocks on the right edge of the form */
doSyncBlocks();
/* Create Room nr box */
ImageRectangle($im, 15, 80, 150, 115, $dark_pink);
ImageFilledRectangle($im, 16, 81, 149, 114, $ewhite);
ImageString($im, 1, 19, 83, $LDRoomNr, $purple);
ImageString($im, 4, 22, 90, $stored_request['room_nr'], $dark_pink);
示例12: pie
function pie($var)
{
$val = explode(",", $var["values"]);
$desc = explode(",", $var["labels"]);
$sum = array_sum($val);
$count = count($val);
$width = 200;
$padding = 15;
$max_width = 400;
$height = $width * 0.5;
$text_height = $count * 20;
if ($height < $text_height) {
$height = $text_height;
if ($height > $max_width) {
$center_y = $height / 2 + $padding;
$height = $max_width;
}
$width = $height * (1 + (1 - ($height - $width / 2) / ($max_width - $width / 2)));
} else {
$text_height = $height;
}
$think = ($width - $height) * 30 / $width;
$center_x = $width / 2 + $padding + 0.5;
$center_y = $text_height / 2 + $padding + 0.5;
$img = imagecreate($width + $padding * 2 + 300, $text_height + $think + $padding * 2);
$bg = ImageColorAllocate($img, 255, 255, 255);
ImageColorTransparent($img, $bg);
$white = ImageColorAllocate($img, 255, 255, 255);
$black = ImageColorAllocate($img, 0, 0, 0);
$blue = ImageColorAllocate($img, 0, 255, 0);
ImageArc($img, $center_x, $center_y, $width, $height, 180, 360, $white);
ImageArc($img, $center_x, $center_y + $think, $width, $height, 0, 180, $white);
ImageLine($img, $center_x - $width / 2, $center_y, $center_x - $width / 2, $center_y + $think, $white);
ImageLine($img, $center_x + $width / 2, $center_y, $center_x + $width / 2, $center_y + $think, $white);
$i = 0;
$c = 0;
ImageLine($img, $center_x, $center_y, $center_x + $width / 2, $center_y, $black);
$p_c = array();
$p_x = array();
$p_y = array();
$p_a = array();
foreach ($val as $v) {
$p = $v / $sum;
$t = $p * pi() + $c;
$c += $p * pi() * 2;
$y1 = sin($c) * $height / 2 + $center_y;
$x1 = cos($c) * $width / 2 + $center_x;
$r = 255;
$g = 80;
$b = 80;
$a = ++$i / $count;
getColor($a, $r, $g, $b);
$x = cos($t) * $width / 3.5 + $center_x;
$y = sin($t) * $height / 3.5 + $center_y;
$item = array();
$item["r"] = $r;
$item["g"] = $g;
$item["b"] = $b;
$item["x"] = $x1;
$item["y"] = $y1;
array_push($p_c, $item);
array_push($p_x, $x);
array_push($p_y, $y);
array_push($p_a, round($p * 100, 2));
if ($p > 0.01) {
$color = ImageColorAllocate($img, round($r * 0.7), round($g * 0.7), round($b * 0.7));
//if($aaaaa<10)
ImageFill($img, $x, $y, $white);
//if($aaaaa<10)
ImageFill($img, $x, $y, $color);
if ($i != $count) {
ImageSetPixel($img, $center_x + 1, $center_y, $white);
ImageLine($img, $center_x, $center_y, $x1, $y1, $white);
if ($y1 > $center_y) {
ImageLine($img, $x1, $y1, $x1, $y1 + $think - 1, $white);
}
} else {
ImageLine($img, $center_x, $center_y, $x1, $y1, $color);
}
}
}
ImageArc($img, $center_x, $center_y, $width, $height, 180, 360, $white);
ImageArc($img, $center_x, $center_y, $width, $height, 0, 180, $white);
ImageFillToBorder($img, $center_x, $center_y, $white, $white);
ImageLine($img, $center_x, $center_y, $center_x + $width / 2, $center_y, $black);
foreach ($p_c as $key => $item) {
$x = $p_x[$key];
$y = $p_y[$key];
if ($p_a[$key] > 1) {
$color = ImageColorAllocate($img, $item['r'], $item['g'], $item['b']);
ImageFill($img, $x, $y, $white);
ImageFill($img, $x, $y, $color);
if ($key != $count - 1) {
ImageSetPixel($img, $center_x + 1, $center_y, $white);
ImageLine($img, $center_x, $center_y, $item['x'], $item['y'], $white);
} else {
ImageLine($img, $center_x, $center_y, $item['x'], $item['y'], $color);
}
}
}
//.........这里部分代码省略.........
示例13: render
//.........这里部分代码省略.........
$radius = round($imgsize / 2);
$originx = $radius + $side_margin;
$originy = $radius + $top_margin;
// draw a circle
ImageArc($im, $originx, $originy, $radius * 2, $radius * 2, 0, 360, $dk_border);
// fill circle with color
ImageFill($im, $originx, $originy, $lt_color);
// GD-2 version of the above two calls. Damn PHP.
// ImageFilledArc($im, $originx, $originy, $radius*2, $radius*2, 0, 360, $dk_border, IMG_ARC_PIE);
if ($chartOptions['12oclock'] !== FALSE) {
// draw a wedge
$last_angle = deg2rad(-90);
// Draw line at 0 degrees if we have more than one item.
if ($TotalArrayValues > 1) {
ImageLine($im, $originx, $originy, $originx, $originy - $radius + 1, $dk_border);
}
} else {
$last_angle = deg2rad(0);
if ($TotalArrayValues > 1) {
ImageLine($im, $originx, $originy, $originx + $radius - 1, $originy, $dk_border);
}
}
if ($chartOptions['striped'] !== FALSE) {
// Draw every other pie wedge a different colour.
$striped = TRUE;
}
$ix = 0;
foreach ($data as $key => $value) {
$angle = deg2rad($value * 3.6) + $last_angle;
$x2 = ($radius - 1) * cos($angle) + $originx;
$y2 = ($radius - 1) * sin($angle) + $originy;
if ($ix != $TotalArrayValues - 1) {
// don't draw wedge-line for 100%
ImageLine($im, $originx, $originy, $x2, $y2, $dk_border);
}
$mid_angle = ($angle - $last_angle) / 2;
if ($value > $threshold) {
// caption if over $threshold
// Fill every other wedge with a different colour:
if ($ix % 2 && $striped) {
ImageFillToBorder($im, $radius * 0.9 * cos($mid_angle + $last_angle) + $originx, $radius * 0.9 * sin($mid_angle + $last_angle) + $originy, $dk_border, $dk_color);
}
$x1 = $radius / 2 * cos($mid_angle + $last_angle) + $originx;
$y1 = $radius / 2 * sin($mid_angle + $last_angle) + $originy;
$x2 = $radius * cos($mid_angle + $last_angle) + $originx;
$y2 = $radius * sin($mid_angle + $last_angle) + $originy;
ImageArc($im, $x1, $y1, $imgsize / 25, $imgsize / 25, 0, 360, $captions_color);
// display caption
ImageLine($im, $x1, $y1, $x2, $y2, $captions_color);
$text = $key . " " . round($value) . "%";
// show percent
if ($x1 > $originx) {
ImageLine($im, $x2, $y2, $x2 + $side_margin, $y2, $captions_color);
// caption on right side
if ($y2 > $originy) {
// Bottom half
ImageString($im, $fontsize, $x2, $y2, $text, $text_color);
} else {
// Should use font height here:
ImageString($im, $fontsize, $x2, $y2 - 15, $text, $text_color);
}
} else {
ImageLine($im, $x2, $y2, $x2 - $side_margin, $y2, $captions_color);
// caption on left side
if ($y2 > $originy) {
// Bottom half
ImageString($im, $fontsize, $x2 - $side_margin, $y2, $text, $text_color);
} else {
// Should use font height here:
ImageString($im, $fontsize, $x2 - $side_margin, $y2 - 15, $text, $text_color);
}
}
}
$last_angle = $angle;
$ix++;
}
}
}
header("Pragma: no-cache");
header("Expires: 0");
switch ($imgType) {
case 'jpeg':
case 'jpg':
Header("Content-Type: image/jpeg");
ImageJPEG($im);
break;
case 'gif':
//not all sites support GIF!
Header("Content-Type: image/gif");
ImageGIF($im);
break;
case 'png':
default:
Header("Content-Type: image/png");
ImagePNG($im);
// send image as PNG to browser
}
// destroy image when done
ImageDestroy($im);
}
示例14: DrawDot
function DrawDot($x_world, $y_world, $dot_type, $color)
{
$half_point = $this->point_size / 2;
$x1 = $this->xtr($x_world) - $half_point;
$x2 = $this->xtr($x_world) + $half_point;
$y1 = $this->ytr($y_world) - $half_point;
$y2 = $this->ytr($y_world) + $half_point;
switch ($dot_type) {
case "halfline":
ImageFilledRectangle($this->img, $x1, $this->ytr($y_world), $this->xtr($x_world), $this->ytr($y_world), $color);
break;
case "line":
ImageFilledRectangle($this->img, $x1, $this->ytr($y_world), $x2, $this->ytr($y_world), $color);
break;
case "rect":
ImageFilledRectangle($this->img, $x1, $y1, $x2, $y2, $color);
break;
case "circle":
ImageArc($this->img, $x1 + $half_point, $y1 + $half_point, $this->point_size, $this->point_size, 0, 360, $color);
break;
case "dot":
ImageArc($this->img, $x1 + $half_point, $y1 + $half_point, $this->point_size, $this->point_size, 0, 360, $color);
ImageFillToBorder($this->img, $x1 + $half_point, $y1 + $half_point, $color, $color);
break;
case "diamond":
$arrpoints = array($x1, $y1 + $half_point, $x1 + $half_point, $y1, $x2, $y1 + $half_point, $x1 + $half_point, $y2);
ImageFilledPolygon($this->img, $arrpoints, 4, $color);
break;
case "triangle":
$arrpoints = array($x1, $y1 + $half_point, $x2, $y1 + $half_point, $x1 + $half_point, $y2);
ImageFilledPolygon($this->img, $arrpoints, 3, $color);
break;
default:
ImageFilledRectangle($this->img, $x1, $y1, $x2, $y2, $color);
break;
}
return true;
}
示例15: array
return;
}
}
$data = array();
global $t;
$count = 0;
$link = baselink();
$result = $coddb->sql_query($query);
// Do not show the graph on an empty result
if (mysql_num_rows($result) == 0) {
header("Content-type: image/png");
$width = 20;
$height = 20;
$im = ImageCreateTrueColor($width, $height);
$grey = ImageColorAllocate($im, 204, 204, 204);
ImageFillToBorder($im, 0, 0, $grey, $grey);
ImagePNG($im);
ImageDestroy($im);
return;
}
$d = array();
$max = 31;
$idx = 1;
$suma = 0;
while ($row = $coddb->sql_fetchrow($result)) {
$start = $row['came'];
$end = $row['gone'];
$d1 = date("Y-m-d", $start);
$d2 = date("Y-m-d", $end);
if (count($data) and $data[count($data) - 1][1] > $d1) {
$diff = floor(($data[count($data) - 1][4] - $start) / (60 * 60 * 24));