Ejemplo n.º 1
0
function draw_clusters($tset, $clusters, $centroids = null, $lines = False, $w = 300, $h = 200)
{
    if (!function_exists('imagecreate')) {
        return null;
    }
    $im = imagecreatetruecolor($w, $h);
    $white = imagecolorallocate($im, 255, 255, 255);
    $colors = array();
    $NC = count($clusters);
    for ($i = 1; $i <= $NC; $i++) {
        list($r, $g, $b) = getColor($i / $NC);
        $colors[] = imagecolorallocate($im, $r, $g, $b);
    }
    imagefill($im, 0, 0, $white);
    foreach ($clusters as $cid => $cluster) {
        foreach ($cluster as $idx) {
            $data = $tset[$idx]->getDocumentData();
            imagesetpixel($im, $data['x'], $data['y'], $colors[$cid]);
        }
        if (is_array($centroids)) {
            $x = $centroids[$cid]['x'];
            $y = $centroids[$cid]['y'];
            if ($lines) {
                // draw line
                // for cosine similarity
                //imagesetthickness($im,5);
                //imageline($im,0,0,$x*400,$y*400,$colors[$cid]);
            } else {
                // draw circle for euclidean
                imagefilledarc($im, $x, $y, 10, 10, 0, 360, $colors[$cid], 0);
            }
        }
    }
    return $im;
}
Ejemplo n.º 2
0
 public static function fill_arc($im, $centerX, $centerY, $diameter, $start, $end, $color1, $color2, $text = '', $placeindex = 0)
 {
     $r = $diameter / 2;
     $w = deg2rad((360 + $start + ($end - $start) / 2) % 360);
     if (function_exists("imagefilledarc")) {
         // exists only if GD 2.0.1 is avaliable
         imagefilledarc($im, $centerX + 1, $centerY + 1, $diameter, $diameter, $start, $end, $color1, IMG_ARC_PIE);
         imagefilledarc($im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color2, IMG_ARC_PIE);
         imagefilledarc($im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color1, IMG_ARC_NOFILL | IMG_ARC_EDGED);
     } else {
         imagearc($im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color2);
         imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($start)) * $r, $centerY + sin(deg2rad($start)) * $r, $color2);
         imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($start + 1)) * $r, $centerY + sin(deg2rad($start)) * $r, $color2);
         imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($end - 1)) * $r, $centerY + sin(deg2rad($end)) * $r, $color2);
         imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($end)) * $r, $centerY + sin(deg2rad($end)) * $r, $color2);
         imagefill($im, $centerX + $r * cos($w) / 2, $centerY + $r * sin($w) / 2, $color2);
     }
     if ($text) {
         if ($placeindex > 0) {
             imageline($im, $centerX + $r * cos($w) / 2, $centerY + $r * sin($w) / 2, $diameter, $placeindex * 12, $color1);
             imagestring($im, 4, $diameter, $placeindex * 12, $text, $color1);
         } else {
             imagestring($im, 4, $centerX + $r * cos($w) / 2, $centerY + $r * sin($w) / 2, $text, $color1);
         }
     }
 }
Ejemplo n.º 3
0
function piechart($w, $h, $chart, $file)
{
    $im = imagecreate($w, $h);
    $bgnd = imagecolorallocate($im, 204, 204, 204);
    $black = imagecolorallocate($im, 0, 0, 0);
    $sum = 0;
    for ($i = 0; $i < count($chart); $i += 4) {
        $sum += $chart[$i];
    }
    if ($sum > 0) {
        $sum2 = 0;
        for ($i = 0; $i < count($chart); $i += 4) {
            if ($chart[$i] > 0) {
                $clr = imagecolorallocate($im, 255 * $chart[$i + 1], 255 * $chart[$i + 2], 255 * $chart[$i + 3]);
                imagefilledarc($im, 0.5 * imagesx($im), 0.9 * imagesy($im), 0.8 * imagesx($im), -1.6 * imagesy($im), 180 * (1 - ($sum2 + $chart[$i]) / $sum), 180 * (1 - $sum2 / $sum), $clr, IMG_ARC_PIE);
                imagefilledarc($im, 0.5 * imagesx($im), 0.9 * imagesy($im), 0.8 * imagesx($im), -1.6 * imagesy($im), 180 * (1 - ($sum2 + $chart[$i]) / $sum), 180 * (1 - $sum2 / $sum), $black, IMG_ARC_NOFILL | IMG_ARC_EDGED);
                $sum2 += $chart[$i];
            }
        }
        imagefilledarc($im, 0.5 * imagesx($im), 0.9 * imagesy($im), 0.2 * imagesx($im), -0.4 * imagesy($im), 0, 180, $bgnd, IMG_ARC_PIE);
        imagefilledarc($im, 0.5 * imagesx($im), 0.9 * imagesy($im), 0.2 * imagesx($im), -0.4 * imagesy($im), 0, 180, $black, IMG_ARC_NOFILL);
    }
    imagepng($im, $file);
    imagedestroy($im);
}
Ejemplo n.º 4
0
/**
 * GD Rectangle Function
 *
 * @param class $siggen
 * @param array $data
 * 		int x
 * 		int y
 * 		int x2
 * 		int y2
 * 		bool filled
 * 		int radius
 * 		string color
 * 		int alpha
 *
 * @return bool
 */
function gd_rectangle($siggen, $data)
{
    // Get our color index
    $color = $this->set_color($data['color'], $data['alpha']);
    // Make sure radius is a positive number
    $data['radius'] = abs($data['radius']);
    // Only do this "massive" drawing if we have rounded corners
    if ($data['radius'] > 0) {
        if ($data['filled'] == 1) {
            imagefilledrectangle($siggen->im, $data['x'] + $data['radius'], $data['y'], $data['x2'] - $data['radius'], $data['y2'], $color);
            imagefilledrectangle($siggen->im, $data['x'], $data['y'] + $data['radius'], $data['x'] + $data['radius'] - 1, $data['y2'] - $data['radius'], $color);
            imagefilledrectangle($siggen->im, $data['x2'] - $data['radius'] + 1, $data['y'] + $data['radius'], $data['x2'], $data['y2'] - $data['radius'], $color);
            imagefilledarc($siggen->im, $data['x'] + $data['radius'], $data['y'] + $data['radius'], $data['radius'] * 2, $data['radius'] * 2, 180, 270, $color, IMG_ARC_PIE);
            imagefilledarc($siggen->im, $data['x2'] - $data['radius'], $data['y'] + $data['radius'], $data['radius'] * 2, $data['radius'] * 2, 270, 360, $color, IMG_ARC_PIE);
            imagefilledarc($siggen->im, $data['x'] + $data['radius'], $data['y2'] - $data['radius'], $data['radius'] * 2, $data['radius'] * 2, 90, 180, $color, IMG_ARC_PIE);
            imagefilledarc($siggen->im, $data['x2'] - $data['radius'], $data['y2'] - $data['radius'], $data['radius'] * 2, $data['radius'] * 2, 360, 90, $color, IMG_ARC_PIE);
        } else {
            imageline($siggen->im, $data['x'] + $data['radius'], $data['y'], $data['x2'] - $data['radius'], $data['y'], $color);
            imageline($siggen->im, $data['x'] + $data['radius'], $data['y2'], $data['x2'] - $data['radius'], $data['y2'], $color);
            imageline($siggen->im, $data['x'], $data['y'] + $data['radius'], $data['x'], $data['y2'] - $data['radius'], $color);
            imageline($siggen->im, $data['x2'], $data['y'] + $data['radius'], $data['x2'], $data['y2'] - $data['radius'], $color);
            imagearc($siggen->im, $data['x'] + $data['radius'], $data['y'] + $data['radius'], $data['radius'] * 2, $data['radius'] * 2, 180, 270, $color);
            imagearc($siggen->im, $data['x2'] - $data['radius'], $data['y'] + $data['radius'], $data['radius'] * 2, $data['radius'] * 2, 270, 360, $color);
            imagearc($siggen->im, $data['x'] + $data['radius'], $data['y2'] - $data['radius'], $data['radius'] * 2, $data['radius'] * 2, 90, 180, $color);
            imagearc($siggen->im, $data['x2'] - $data['radius'], $data['y2'] - $data['radius'], $data['radius'] * 2, $data['radius'] * 2, 360, 90, $color);
        }
    } else {
        if ($data['filled'] == 1) {
            imagefilledrectangle($siggen->im, $data['x'], $data['y'], $data['x2'], $data['y2'], $color);
        } else {
            imagerectangle($siggen->im, $data['x'], $data['y'], $data['x2'], $data['y2'], $color);
        }
    }
    return TRUE;
}
Ejemplo n.º 5
0
function check($len = 4)
{
    session_start();
    header('content-type:image/png');
    $fs = ['/a.ttf', '/b.ttf', '/f.ttf'];
    $font = dirname(__FILE__) . $fs[mt_rand(0, 1)];
    $w = 35 * $len;
    $h = 50;
    $i = imagecreatetruecolor($w, $h);
    $c = imagecolorallocatealpha($i, 0, 0, 0, 127);
    //imagecolortransparent($i,$c);
    //imagefill($i,0,0,$c);
    imagefilledrectangle($i, 0, 0, $w, $h, gc($i, 'ffffff', mt_rand(0, 2)));
    $sss = '';
    for ($j = 0; $j < $len; $j++) {
        $st = gs(1);
        $sss .= $st;
        imagettftext($i, mt_rand(15, 25), mt_rand(-30, 30), $j * 35 + 10, mt_rand(28, 38), gc($i), $font, $st);
    }
    $_SESSION['code'] = $sss;
    imagesetthickness($i, mt_rand(2, 8));
    for ($j = 0; $j < mt_rand(5, 10); $j++) {
        imagefilledarc($i, mt_rand(0, $w), mt_rand(0, $h), mt_rand(0, $w), mt_rand(0, $h), mt_rand(0, 360), mt_rand(0, 360), gc($i, 'rand', mt_rand(100, 120)), IMG_ARC_NOFILL);
    }
    for ($j = 0; $j < 10; $j++) {
        imagettftext($i, mt_rand(10, 15), mt_rand(-5, 5), mt_rand(0, $w), mt_rand(0, $h), gc($i, 'rand', mt_rand(100, 120)), $font, gs(1));
    }
    imagepng($i);
    imagedestroy($i);
}
 public function drawPieChart($height = 450, $width = 640, $data_array = array('Score A' => 50, 'Score B' => 90))
 {
     $font = '../Controller/GeosansLight.ttf';
     /** set front */
     $this->image = imagecreate($width, $height);
     $piewidth = $width * 0.7;
     /* pie area */
     $x = round($piewidth / 2);
     $y = round($height / 2);
     $total = array_sum($data_array);
     $angle_start = 0;
     $ylegend = 2;
     imagefilledrectangle($this->image, 0, 0, $width, $piewidth, imagecolorallocate($this->image, 255, 255, 255));
     foreach ($data_array as $label => $value) {
         $angle_done = $value / $total * 360;
         /** angle calculated for 360 degrees */
         $perc = round($value / $total * 100, 1);
         /** percentage calculated */
         $color = imagecolorallocate($this->image, rand(100, 255), rand(100, 255), rand(100, 255));
         imagefilledarc($this->image, $x, $y, $piewidth, $height, $angle_start, $angle_done += $angle_start, $color, IMG_ARC_PIE);
         $xtext = $x + cos(deg2rad(($angle_start + $angle_done) / 2)) * ($piewidth / 4);
         $ytext = $y + sin(deg2rad(($angle_start + $angle_done) / 2)) * ($height / 4);
         imagettftext($this->image, 16, 0, $xtext, $ytext, imagecolorallocate($this->image, 0, 0, 0), $font, "{$perc} %");
         imagefilledrectangle($this->image, $piewidth + 2, $ylegend, $piewidth + 20, $ylegend += 20, $color);
         imagettftext($this->image, 18, 0, $piewidth + 22, $ylegend, imagecolorallocate($this->image, 0, 0, 0), $font, $label);
         $ylegend += 4;
         $angle_start = $angle_done;
     }
 }
Ejemplo n.º 7
0
 /**
  * Draws this object onto an image
  *
  * @param   img.Image image
  * @return  var
  */
 public function draw($image)
 {
     if (FALSE !== $this->fill) {
         return imagefilledarc($image->handle, $this->cx, $this->cy, $this->w, $this->h, $this->s, $this->e, $this->col->handle, $this->fill);
     } else {
         return imagearc($image->handle, $this->cx, $this->cy, $this->w, $this->h, $this->s, $this->e, $this->col->handle);
     }
 }
Ejemplo n.º 8
0
	function draw_data($x,$y,$rad,$color, $isCore = false)
	{
		global $im,$x0,$y0,$black, $maxX, $maxY;
		
		//рисуем точку
		imagefilledarc($im,$x0 + $x,$maxY-$y,$rad,$rad,0,360,$color,IMG_ARC_PIE);
		if ($isCore) imagearc($im,$x0 + $x,$maxY-$y,$rad,$rad,0,360,$black);
	}
function imagefilledroundedrectangle($image, $x1, $y1, $x2, $y2, $radius, $color)
{
    imagefilledrectangle($image, $x1, $y1 + $radius, $x2, $y2 - $radius, $color);
    imagefilledrectangle($image, $x1 + $radius, $y1, $x2 - $radius, $y2, $color);
    imagefilledarc($image, $x1 + $radius, $y1 + $radius, $radius * 2, $radius * 2, 0, 360, $color, IMG_ARC_PIE);
    imagefilledarc($image, $x2 - $radius, $y1 + $radius, $radius * 2, $radius * 2, 0, 360, $color, IMG_ARC_PIE);
    imagefilledarc($image, $x1 + $radius, $y2 - $radius, $radius * 2, $radius * 2, 0, 360, $color, IMG_ARC_PIE);
    imagefilledarc($image, $x2 - $radius, $y2 - $radius, $radius * 2, $radius * 2, 0, 360, $color, IMG_ARC_PIE);
}
Ejemplo n.º 10
0
 function draw($rows, $width = 150, $height = 150, $thick = 15, $fname = '/upload/draw.png')
 {
     global $PRJ_DIR;
     $this->width = $width;
     $this->height = $height;
     $this->thick = $thick;
     $this->width4 = $width * 4;
     $this->height4 = $height * 4;
     $this->thick4 = $thick * 4;
     $this->fname = $fname;
     $image = imagecreatetruecolor($this->width4, $this->height4);
     // allocate some colors
     $cred = hexdec(substr($this->bgcolor, 0, 2));
     $cgreen = hexdec(substr($this->bgcolor, 2, 2));
     $cblue = hexdec(substr($this->bgcolor, 4, 2));
     $bg = imagecolorallocate($image, $cred, $cgreen, $cblue);
     $colors = array();
     $total = 0;
     foreach ($rows as $value) {
         $total += $value[0];
         $value[1] = str_replace('#', '', $value[1]);
         $cred = hexdec(substr($value[1], 0, 2));
         $cgreen = hexdec(substr($value[1], 2, 2));
         $cblue = hexdec(substr($value[1], 4, 2));
         $colors[] = array('c' => imagecolorallocate($image, $cred, $cgreen, $cblue), 'd' => imagecolorallocate($image, $cred ? $cred - 25 : 0, $cgreen ? $cgreen - 25 : 0, $cblue ? $cblue - 25 : 0), 'h' => $value[1]);
     }
     imagefill($image, 0, 0, $bg);
     // make the 3D effect
     for ($i = $this->height4 / 2 + $this->thick4; $i > $this->height4 / 2; $i--) {
         $j = 0;
         $z1 = 0;
         if ($rows) {
             foreach ($rows as $value) {
                 $z2 = $z1 + 360 / ($total / $value[0]);
                 imagefilledarc($image, $this->width4 / 2, $i, $this->width4, $this->height4 / 2, $z1, $z2, $colors[$j]['d'], IMG_ARC_PIE);
                 $z1 = $z2;
                 $j++;
             }
         }
     }
     $j = 0;
     $z1 = 0;
     foreach ($rows as $value) {
         $z2 = $z1 + 360 / ($total / $value[0]);
         imagefilledarc($image, $this->width4 / 2, $this->height4 / 2, $this->width4, $this->height4 / 2, $z1, $z2, $colors[$j]['c'], IMG_ARC_PIE);
         $colorback[] = $colors[$j]['h'];
         $z1 = $z2;
         $j++;
     }
     $imd = imagecreatetruecolor($this->width, $this->height);
     imagecopyresampled($imd, $image, 0, 0, 0, 0, $this->width, $this->height, $this->width4, $this->height4);
     imagedestroy($image);
     imagepng($imd, $PRJ_DIR . $this->fname);
     imagedestroy($imd);
     return $colorback;
 }
function createPie($pValues = "")
{
    $values = array("2010" => 1950, "2011" => 750, "2012" => 2100, "2013" => 580, "2014" => 5000, "2015" => 5000, "2016" => 5000, "2017" => 5000);
    if ($pValues) {
        $values = $pValues;
    }
    $total = count($values);
    $data = $total == 0 ? array(360) : array_values($values);
    $keys = $total == 0 ? array("") : array_keys($values);
    $radius = 30;
    $imgx = 1400 + $radius;
    $imgy = 600 + $radius;
    $cx = 430 + $radius;
    $cy = 200 + $radius;
    $sx = 800;
    $sy = 400;
    $sz = 150;
    $data_sum = array_sum($data);
    $angle_sum = array(-1 => 0, 360);
    $typo = "font/CooperBlackStd.otf";
    $im = imagecreatetruecolor($imgx, $imgy);
    imagesavealpha($im, true);
    $trans_color = imagecolorallocatealpha($im, 0, 0, 0, 127);
    imagefill($im, 0, 0, $trans_color);
    imagecolorallocate($im, 255, 255, 255);
    $color = array(array(220, 20, 60), array(77, 33, 114), array(249, 141, 53), array(158, 37, 59), array(1, 128, 128), array(28, 94, 160), array(206, 16, 118), array(43, 67, 86), array(155, 108, 166), array(83, 69, 62));
    shuffle($color);
    shuffle($color);
    shuffle($color);
    $colors = array(imagecolorallocate($im, $color[0][0], $color[0][1], $color[0][2]));
    $colord = array(imagecolorallocate($im, $color[0][0] / 1.5, $color[0][1] / 1.5, $color[0][2] / 1.5));
    $factorx = array();
    $factory = array();
    for ($i = 0; $i < $total; $i++) {
        $angle[$i] = $data[$i] / $data_sum * 360;
        $angle_sum[$i] = array_sum($angle);
        $colors[$i] = imagecolorallocate($im, $color[$i][0], $color[$i][1], $color[$i][2]);
        $colord[$i] = imagecolorallocate($im, $color[$i][0] / 1.5, $color[$i][1] / 1.5, $color[$i][2] / 1.5);
        $factorx[$i] = cos(deg2rad(($angle_sum[$i - 1] + $angle_sum[$i]) / 2));
        $factory[$i] = sin(deg2rad(($angle_sum[$i - 1] + $angle_sum[$i]) / 2));
    }
    for ($z = 1; $z <= $sz; $z++) {
        for ($i = 0; $i < $total; $i++) {
            imagefilledarc($im, $cx + $factorx[$i] * $radius, $cy + $sz - $z + $factory[$i] * $radius, $sx, $sy, $angle_sum[$i - 1], $angle_sum[$i], $colord[$i], IMG_ARC_PIE);
        }
    }
    for ($i = 0; $i < $total; $i++) {
        imagefilledarc($im, $cx + $factorx[$i] * $radius, $cy + $factory[$i] * $radius, $sx, $sy, $angle_sum[$i - 1], $angle_sum[$i], $colors[$i], IMG_ARC_PIE);
        imagefilledrectangle($im, 900, 50 + $i * 30 * 2, 950, 100 + $i * 30 * 2, $colors[$i]);
        imagettftext($im, 30, 0, 970, 90 + $i * 30 * 2, imagecolorallocate($im, 0, 0, 0), $typo, $keys[$i]);
        imagettftext($im, 30, 0, $cx + $factorx[$i] * ($sx / 4) - 40, $cy + $factory[$i] * ($sy / 4) + 10, imagecolorallocate($im, 0, 0, 0), $typo, $data[$i]);
    }
    header('Content-type: image/png');
    imagepng($im);
    imagedestroy($im);
}
Ejemplo n.º 12
0
 public function arc(Point $center, $width, $height, $start, $end, $style = NULL, $filled = FALSE, Color $color = NULL)
 {
     if (!$center->isInImage($this)) {
         throw new IllegalArgumentException();
     }
     if ($filled == TRUE && $style == NULL) {
         throw new IllegalArgumentException();
     }
     $filled == TRUE ? imagefilledarc($this->imageResource, $center->getX(), $center->getY(), $width, $height, $start, $end, $this->prepareColor($color), $style) : imagearc($this->imageResource, $center->getX(), $center->getY(), $width, $height, $start, $end, $this->prepareColor($color));
 }
Ejemplo n.º 13
0
 private function _get_lt_rounder_corner()
 {
     $radius = $this->_radius;
     $img = imagecreatetruecolor($radius, $radius);
     $bgcolor = imagecolorallocate($img, $this->_r, $this->_g, $this->_b);
     $fgcolor = imagecolorallocate($img, 0, 0, 0);
     imagefill($img, 0, 0, $bgcolor);
     imagefilledarc($img, $radius, $radius, $radius * 2, $radius * 2, 180, 270, $fgcolor, IMG_ARC_PIE);
     imagecolortransparent($img, $fgcolor);
     return $img;
 }
Ejemplo n.º 14
0
 /**
  * Draws an arc on the handle
  *
  * @param GD-object $handle The handle on which the ellipse is drawn
  * @param Zend_Image_Action_DrawEllipse $ellipseObject The object that with all info
  */
 public function perform(Zend_Image_Adapter_Gd $adapter, Zend_Image_Action_DrawArc $arcObject)
 {
     $color = $arcObject->getFillColor()->getRgb();
     $colorAlphaAlloc = imagecolorallocatealpha($adapter->getHandle(), $color['red'], $color['green'], $color['blue'], 127 - $arcObject->getFillAlpha() * 1.27);
     if (!$arcObject->isFilled()) {
         $style = IMG_ARC_NOFILL + IMG_ARC_EDGED;
     } else {
         $style = IMG_ARC_PIE;
     }
     $location = $arcObject->getLocation($adapter);
     imagefilledarc($adapter->getHandle(), $location->getX(), $location->getY(), $arcObject->getWidth(), $arcObject->getHeight(), $arcObject->getCutoutStart() - 90, $arcObject->getCutoutEnd() - 90, $colorAlphaAlloc, $style);
 }
Ejemplo n.º 15
0
function drawpie($img, $arr, $x, $y, $r)
{
    $sum = array_sum($arr);
    $now = 0;
    foreach ($arr as $v) {
        $arc = $v / $sum * 360 + $now;
        $arc %= 360;
        $col = imagecolorallocate($img, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
        imagefilledarc($img, $x, $y, $r, $r, $now, $arc, $col, 0 + 4);
        $now = $arc;
    }
}
Ejemplo n.º 16
0
 function drawPie($centerX, $centerY, $radius, $begin, $end, $style)
 {
     $radius = $radius * 2;
     if ($begin != 0 || $end != 360) {
         $tmp = -$begin;
         $begin = -$end;
         $end = $tmp;
     }
     $this->_convertPosition($centerX, $centerY);
     $radius = $radius * min($this->width, $this->height);
     imagefilledarc($this->gd, $centerX, $centerY, $radius, $radius, $begin, $end, $style['fill'], IMG_ARC_PIE);
     imagesetthickness($this->gd, $style['line-width']);
     imagefilledarc($this->gd, $centerX, $centerY, $radius, $radius, $begin, $end, $style['line'], IMG_ARC_NOFILL | IMG_ARC_EDGED);
 }
Ejemplo n.º 17
0
 public function DrawPie($name = "")
 {
     $this->SetImgName($name);
     $this->side = $this->width;
     if ($this->side > 0 && !empty($this->data)) {
         $pie_core = $this->side / 2;
         $fts_max = 0;
         foreach (array_keys($this->data) as $item) {
             $chk_itm = $item . ' ' . max($this->data) . ' 00.00%';
             $fts_box = imagettfbbox($this->size, 0, $this->font, $chk_itm);
             $chk_len = $fts_box[4] - $fts_box[6];
             if ($chk_len > $fts_max) {
                 $fts_max = $chk_len;
             }
         }
         $pie_cAdd = 48 + $fts_max;
         $this->image = @imagecreate($this->side + $pie_cAdd, $this->side + 1);
         if ($this->image) {
             $this->SetDftColor();
             $dat_sum = array_sum($this->data);
             $arc_beg = array(-180, -90, 0, 90, 180);
             $arc_beg = $arc_beg[array_rand($arc_beg)];
             $fts_add = $this->fontA * 2;
             $ftx_beg = $this->side + 28;
             $fty_beg = 2;
             $ftx_add = 20;
             $fty_add = 20;
             $fts_cor = imagecolorallocate($this->image, 0, 0, 0);
             $fty_chk = $fty_add * count($this->data);
             while ($fty_chk > $this->side + 2) {
                 $fty_chk = --$fty_add * count($this->data);
             }
             foreach ($this->data as $item => $data) {
                 $rnd_cor = $this->GetRndColor();
                 $arc_pct = number_format($data * 100 / $dat_sum, 2);
                 $arc_end = $data * 360 / $dat_sum + $arc_beg;
                 $item = iconv('utf-8', 'utf-8//ignore', (string) $item);
                 imagefilledarc($this->image, $pie_core, $pie_core, $this->side, $this->side, $arc_beg, $arc_end, $rnd_cor, IMG_ARC_PIE);
                 imagefilledrectangle($this->image, $ftx_beg, $fty_beg, $ftx_beg + 12, $fty_beg + 10, $rnd_cor);
                 imagettftext($this->image, $this->size, 0, $ftx_beg + $ftx_add, $fty_beg + $this->fontA, $fts_cor, $this->font, $item . ' ' . $data . ' ' . $arc_pct . '%');
                 $fty_beg += $fty_add;
                 $arc_beg = $arc_end;
             }
             $this->Output();
         }
     } else {
         exit('画布边长设置不正确或统计数据为空!');
     }
 }
 public function generate(Blackboard $bb, $outfile)
 {
     $raw = file_get_contents($this->paths->getBlackboards() . "/{$bb->id}.json");
     $data = Json::decode($raw, Json::FORCE_ARRAY);
     $min = ['width' => PHP_INT_MAX, 'height' => PHP_INT_MAX];
     $max = ['width' => 0, 'height' => 0];
     foreach ($data['data'] as $row) {
         if ($row['type'] !== 'beginStroke' && $row['type'] !== 'strokeTo') {
             continue;
         }
         $min['width'] = min($min['width'], $row['loc']['x']);
         $min['height'] = min($min['height'], $row['loc']['y']);
         $max['width'] = max($max['width'], $row['loc']['x']);
         $max['height'] = max($max['height'], $row['loc']['y']);
     }
     $margin = 20;
     $min['width'] -= $margin;
     $min['height'] -= $margin;
     $max['width'] += $margin;
     $max['height'] += $margin;
     $ratio = 2;
     $canvas = imagecreatetruecolor(($max['width'] - $min['width']) * $ratio, ($max['height'] - $min['height']) * $ratio);
     if (function_exists('imageantialias')) {
         // this function is not in php5-gd and requires recompiling php
         imageantialias($canvas, TRUE);
     }
     $last = NULL;
     foreach ($data['data'] as $row) {
         if ($row['type'] === 'beginStroke') {
             $last = $row['loc'];
         } else {
             if ($row['type'] === 'strokeTo') {
                 $c = $row['color'];
                 $color = imagecolorallocate($canvas, $c['r'], $c['g'], $c['b']);
                 $this->imagelinethick($canvas, ($last['x'] - $min['width']) * $ratio, ($last['y'] - $min['height']) * $ratio, ($row['loc']['x'] - $min['width']) * $ratio, ($row['loc']['y'] - $min['height']) * $ratio, $color, 3);
                 $last = $row['loc'];
             } else {
                 if ($row['type'] === 'erase') {
                     $color = imagecolorallocate($canvas, 0, 0, 0);
                     $radius = 11 * $ratio;
                     $x = ($row['loc']['x'] - $min['width']) * $ratio;
                     $y = ($row['loc']['y'] - $min['height']) * $ratio;
                     imagefilledarc($canvas, $x, $y, $radius, $radius, 0, 360, $color, IMG_ARC_PIE);
                 }
             }
         }
     }
     imagepng($canvas, $outfile, 9);
 }
Ejemplo n.º 19
0
 private function _get_lt_rounder_corner()
 {
     $radius = $this->_radius;
     //$radius=20;
     $img = imagecreatetruecolor($radius, $radius);
     $bgcolor = imagecolorallocate($img, $this->_r, $this->_g, $this->_b);
     $fgcolor = imagecolorallocate($img, 0, 0, 0);
     imagefill($img, 0, 0, $bgcolor);
     imagefilledarc($img, $radius, $radius, $radius * 2, $radius * 2, 180, 270, $fgcolor, IMG_ARC_PIE);
     //imagefilledarc在指定的 image 上画一椭圆弧且填充。
     imagecolortransparent($img, $fgcolor);
     //imagecolortransparent() 将 image 图像中的透明色设定为 color。
     //image 是 imagecreatetruecolor() 返回的图像标识符,
     //color 是 imagecolorallocate() 返回的颜色标识符。
     //imagejpeg($img);
     return $img;
 }
Ejemplo n.º 20
0
 public function graphData($data, $colors)
 {
     // allocate black for slice outline
     $black = imagecolorallocate($this->image, 0x0, 0x0, 0x0);
     // sum of all values
     $sum = array_sum($data);
     // starting angle of pie slice
     $start = -90;
     for ($i = 0; $i < count($data); $i++) {
         $color = imagecolorallocate($this->image, $colors[$i]['r'], $colors[$i]['g'], $colors[$i]['b']);
         // stop angle of pie slice
         $stop = 100 * $data[$i] / $sum * 3.6 + $start;
         // draw arc twice - once for filled area and again for outline
         imagefilledarc($this->image, $this->center, $this->center, $this->width, $this->width, $start, $stop, $color, IMG_ARC_PIE);
         imagefilledarc($this->image, $this->center, $this->center, $this->width, $this->width, $start, $stop, $black, IMG_ARC_NOFILL | IMG_ARC_EDGED);
         // increment to next starting point
         $start = $stop;
     }
 }
Ejemplo n.º 21
0
 private function drawDisc($img)
 {
     $i = 0;
     $oldAngle = 0;
     $percentTotal = 0;
     foreach ($this->percent as $a) {
         list($percent, $point, $color) = $a;
         // If value is null, don't draw this arc
         if ($percent <= 0) {
             continue;
         }
         $percentTotal += $percent;
         $newAngle = $percentTotal * 360 / 100;
         // imagefilledarc doesn't like null values (#1)
         if ($newAngle - $oldAngle >= 1) {
             imagefilledarc($img, $this->pieCenterX, $this->pieCenterY, $this->pieWidth, $this->pieHeight, $oldAngle, $newAngle, imagecolorallocate($img, $color['red'], $color['green'], $color['blue']), IMG_ARC_PIE);
         }
         $oldAngle = $newAngle;
         $i++;
     }
 }
Ejemplo n.º 22
0
 static function fill($res, $color, $arr, $name = "fill")
 {
     $key = array_keys(self::$element);
     if ($name == $key[6]) {
         return imagefill($res, $arr[0], $arr[1], $color);
     }
     if ($name == $key[2]) {
         return imagefilledarc($res, $arr[0], $arr[1], $arr[2], $arr[3], $arr[4], $arr[5], $color, $arr[6]);
     }
     if ($name == $key[3] || $name == $key[4]) {
         $act = 'imagefilled' . $name;
         return $act($res, $arr[0], $arr[1], $arr[2], $arr[3], $color);
     }
     if ($name == $key[5]) {
         return imagefilledpolygon($res, $arr, end($arr), $color);
     }
     if ($name == $key[7]) {
         return imagefilltoborder($res, $arr[0], $arr[1], end($arr), $color);
     }
     return 'method error';
 }
Ejemplo n.º 23
0
 static function fill(&$image, $color, $param, $name = 'rectangle')
 {
     switch ($name) {
         case 'fill':
             //填充
             return imagefill($image, $param[0], $param[1], $color);
         case 'arc':
             //弧形填充
             return imagefilledarc($image, $param[0], $param[1], $param[2], $param[3], $param[4], $param[5], $color, $param[6]);
         case 'polygon':
             //填充多边形
             return imagefilledpolygon($image, $param, count($param) / 2, $color);
         case 'border':
             //区域填充到指定颜色的边界为止
             return imagefilltoborder($image, $param[0], $param[1], $param[2], $color);
         default:
             //填充椭圆、矩形
             $fill = 'imagefilled' . $name;
             //ellipse,rectangle
             return $fill($image, $param[0], $param[1], $param[2], $param[3], $color);
     }
 }
Ejemplo n.º 24
0
 static function fill(&$image, $color, $param, $name = "fill")
 {
     //填充
     if ($name == 'fill') {
         return imagefill($image, $param[0], $param[1], $color);
     }
     //弧形填充
     if ($name == 'arc') {
         return imagefilledarc($image, $param[0], $param[1], $param[2], $param[3], $param[4], $param[5], $color, $param[6]);
     }
     //填充椭圆、矩形
     if ($name == 'ellipse' || $name == 'rectangle') {
         $fill = 'imagefilled' . $name;
         return $fill($image, $param[0], $param[1], $param[2], $param[3], $color);
     }
     //填充多边形
     if ($name == 'polygon') {
         return imagefilledpolygon($image, $param, count($param) / 2, $color);
     }
     //区域填充到指定颜色的边界为止
     if ($name == 'border') {
         return imagefilltoborder($image, $param[0], $param[1], $param[2], $color);
     }
 }
Ejemplo n.º 25
0
 function CakeSlice($xc, $yc, $w, $h, $s, $e, $fillcolor = "", $arccolor = "")
 {
     $s = round($s);
     $e = round($e);
     $w = round($w);
     $h = round($h);
     $xc = round($xc);
     $yc = round($yc);
     $this->PushColor($fillcolor);
     $this->FilledArc($xc, $yc, 2 * $w, 2 * $h, $s, $e);
     $this->PopColor();
     if ($arccolor != "") {
         $this->PushColor($arccolor);
         // We add 2 pixels to make the Arc() better aligned with
         // the filled arc.
         if ($GLOBALS['gd2']) {
             imagefilledarc($this->img, $xc, $yc, 2 * $w, 2 * $h, $s, $e, $this->current_color_name, IMG_ARC_NOFILL | IMG_ARC_EDGED);
         } else {
             $this->Arc($xc, $yc, 2 * $w + 2, 2 * $h + 2, $s, $e);
             $xx = $w * cos(2 * M_PI - $s * M_PI / 180) + $xc;
             $yy = $yc - $h * sin(2 * M_PI - $s * M_PI / 180);
             $this->Line($xc, $yc, $xx, $yy);
             $xx = $w * cos(2 * M_PI - $e * M_PI / 180) + $xc;
             $yy = $yc - $h * sin(2 * M_PI - $e * M_PI / 180);
             $this->Line($xc, $yc, $xx, $yy);
         }
         $this->PopColor();
     }
 }
Ejemplo n.º 26
0
 /**
  * Draw a 2D disc
  *
  * @access	private
  * @param	integer		center coordinate (y)
  * @param	array		colors for each portion
  * @param	bitfield	drawing mode
  */
 function drawDisc($cy, $colorArray, $mode)
 {
     $i = 0;
     $angle1 = 0;
     $percentTotal = 0;
     foreach ($this->percent as $a) {
         list($percent, $point) = $a;
         $color = $colorArray[$i % count($colorArray)];
         $percentTotal += $percent;
         $angle2 = $percentTotal * 360 / 100;
         imagefilledarc($this->img, $this->pieCenterX, $cy, $this->pieWidth, $this->pieHeight, $angle1, $angle2, $color->getColor($this->img), $mode);
         $angle1 = $angle2;
         $i++;
     }
 }
Ejemplo n.º 27
0
<?php

header("content-type: image/png");
$w = $_GET["w"];
$d = $_GET["d"];
$l = $_GET["l"];
$tot = $w + $d + $l;
$wdeg = 360 * $w / $tot;
$ddeg = 360 * $d / $tot;
$ldeg = 360 - $wdeg - $ddeg;
$image = imagecreatetruecolor(106, 106);
$bground = imagecolorallocate($image, 255, 255, 0xd3);
$red = imagecolorallocate($image, 255, 0, 0);
$green = imagecolorallocate($image, 0, 255, 0);
$blue = imagecolorallocate($image, 0, 0, 255);
imagefill($image, 0, 0, $bground);
if ($wdeg > 0) {
    imagefilledarc($image, 53, 53, 100, 100, 0, $wdeg, $green, IMG_ARC_PIE);
}
if ($ddeg > 0) {
    imagefilledarc($image, 53, 53, 100, 100, $wdeg, $wdeg + $ddeg, $blue, IMG_ARC_PIE);
}
if ($ldeg > 0) {
    imagefilledarc($image, 53, 53, 100, 100, $wdeg + $ddeg, 360, $red, IMG_ARC_PIE);
}
imagepng($image);
imagedestroy($image);
Ejemplo n.º 28
0
 function CakeSlice($xc, $yc, $w, $h, $s, $e, $fillcolor = "", $arccolor = "")
 {
     $s = round($s);
     $e = round($e);
     $w = round($w);
     $h = round($h);
     $xc = round($xc);
     $yc = round($yc);
     if ($s == $e) {
         // A full circle. We draw this a plain circle
         $this->PushColor($fillcolor);
         imagefilledellipse($this->img, $xc, $yc, 2 * $w, 2 * $h, $this->current_color);
         $this->PopColor();
         $this->PushColor($arccolor);
         imageellipse($this->img, $xc, $yc, 2 * $w, 2 * $h, $this->current_color);
         $this->Line($xc, $yc, cos($s * M_PI / 180) * $w + $xc, $yc + sin($s * M_PI / 180) * $h);
         $this->PopColor();
     } else {
         $this->PushColor($fillcolor);
         $this->FilledArc($xc, $yc, 2 * $w, 2 * $h, $s, $e);
         $this->PopColor();
         if ($arccolor != "") {
             $this->PushColor($arccolor);
             // We add 2 pixels to make the Arc() better aligned with the filled arc.
             imagefilledarc($this->img, $xc, $yc, 2 * $w, 2 * $h, $s, $e, $this->current_color, IMG_ARC_NOFILL | IMG_ARC_EDGED);
             // Workaround for bug in 4.4.7 which will not draw a correct 360
             // degree slice with any other angles than 0,360. Unfortunately we cannot just
             // adjust the angles since the interior ar edge is drawn correct but not the surrounding
             // circle. This workaround can only be used with perfect circle shaped arcs
             if (PHP_VERSION === '4.4.7' && (360 - abs($s - $e) < 0.01 && $w == $h)) {
                 $this->Circle($xc, $yc, $w);
             }
             $this->PopColor();
         }
     }
 }
Ejemplo n.º 29
0
 /**
  * Generate Funnel Chart
  *
  * @return	@e void
  */
 protected function _drawFunnel()
 {
     //-----------------------------------------
     // Draw Axes
     //-----------------------------------------
     $numcats = count($this->data['xaxis']);
     for ($i = $numcats - 1; $i >= 0; $i--) {
         $labels[$i] = $this->data['xaxis'][$numcats - 1 - $i];
     }
     $this->y_axis = array('type' => 'labels', 'labels' => $labels);
     $this->_drawAxes();
     //-----------------------------------------
     // Allocate text and shadow cols
     //-----------------------------------------
     $textcolor = imagecolorallocate($this->image, hexdec(substr($this->options['titlecolor'], 1, 2)), hexdec(substr($this->options['titlecolor'], 3, 2)), hexdec(substr($this->options['titlecolor'], 5, 2)));
     $shadowcolor = imagecolorallocate($this->image, hexdec(substr($this->options['titleshadow'], 1, 2)), hexdec(substr($this->options['titleshadow'], 3, 2)), hexdec(substr($this->options['titleshadow'], 5, 2)));
     //-----------------------------------------
     // Calculate bar display variables
     //-----------------------------------------
     $numbars = count($this->data['yaxis'][0]['data']);
     $maxvalue = $this->_getMax($this->data['yaxis'][0]['data']);
     $stepheight = floor(($this->grapharea['y1'] - $this->grapharea['y0']) / $numbars);
     $numticks = $this->options['numticks'] > $maxvalue ? floor($maxvalue) : $this->options['numticks'];
     $step = floor($maxvalue / $numticks);
     $steps = ceil($maxvalue / $step);
     $stepwidth = ($this->grapharea['x1'] - $this->grapharea['x0']) / $steps;
     $xmid = $this->grapharea['x0'] + floor(($this->grapharea['x1'] - $this->grapharea['x0']) / 2);
     // Get the colors
     for ($i = $numcats - 1; $i >= 0; $i--) {
         if (!isset($this->color[$i])) {
             $this->color[$i] = explode(",", $this->_getSliceColor());
         }
     }
     for ($i = 0; $i < $numcats; $i++) {
         $value = $this->data['yaxis'][0]['data'][$numcats - 1 - $i];
         $x0 = $xmid - round($value * $stepwidth / $step / 2, 0);
         $x2 = $xmid + round($value * $stepwidth / $step / 2, 0);
         $y1 = $this->grapharea['y1'] - $i * $stepheight - 1;
         if (isset($this->data['yaxis'][0]['data'][$numcats - 2 - $i])) {
             $nextval = $this->data['yaxis'][0]['data'][$numcats - 2 - $i];
         } else {
             $nextval = $maxvalue;
         }
         $x1 = $xmid - round($nextval * $stepwidth / $step / 2, 0);
         $x3 = $xmid + round($nextval * $stepwidth / $step / 2, 0);
         $y0 = $y1 - $stepheight + 1;
         $linecolor = ImageColorAllocate($this->image, $this->color[$i][0], $this->color[$i][1], $this->color[$i][2]);
         if ($this->options['style3D'] != 1) {
             // 2D style
             $points = array($x0, $y1, $x1, $y0, $x3, $y0, $x2, $y1);
             imagefilledpolygon($this->image, $points, 4, $linecolor);
         } else {
             //3D Style
             for ($j = 0; $j < $stepheight; $j++) {
                 $width = $x2 - $x0 + round($j * ($x3 - $x1 - ($x2 - $x0)) / $stepheight, 0);
                 $height = floor(($value + $j * ($nextval - $value) / $stepheight) / $maxvalue * 40);
                 $x = $xmid + 20;
                 $y = $y1 - 20 - $j;
                 imagefilledarc($this->image, $x, $y, $width, $height, 0, 180, $linecolor, IMG_ARC_PIE);
             }
         }
         //-----------------------------------------
         // Datalabels
         //-----------------------------------------
         if ($this->options['showdatalabels']) {
             $textcolor = ImageColorAllocate($this->image, hexdec(substr($this->options['textcolor'], 1, 2)), hexdec(substr($this->options['textcolor'], 3, 2)), hexdec(substr($this->options['textcolor'], 5, 2)));
             $shadowcolor = imagecolorallocate($this->image, $this->color[$i][0] - 50 < 0 ? 0 : $this->color[$i][0] - 50, $this->color[$i][1] - 50 < 0 ? 0 : $this->color[$i][1] - 50, $this->color[$i][2] - 50 < 0 ? 0 : $this->color[$i][2] - 50);
             if ($nextval == 0) {
                 $label = $value . ' (100%)';
             } else {
                 $label = $value . ' (' . round($value / $nextval * 100, 1) . '%)';
             }
             if ($this->use_ttf) {
                 $txtsize = imagettfbbox('10', 0, $this->options['font'], $label);
                 $textx = $xmid - round(($txtsize[2] - $txtsize[0]) / 2, 0);
                 $texty = $y0 + floor($stepheight / 2) + floor(($txtsize[1] - $txtsize[5]) / 2);
                 if ($this->options['style3D']) {
                     $correction = floor(($nextval - ($nextval - $value) / 2) / $maxvalue * 20);
                     $textx = $textx + 20 - $correction;
                     $texty = $texty - 20 + $correction;
                 }
                 imagettftext($this->image, "10", 0, $textx - 1, $texty - 1, $shadowcolor, $this->options['font'], $label);
                 imagettftext($this->image, "10", 0, $textx + 1, $texty + 1, $shadowcolor, $this->options['font'], $label);
                 imagettftext($this->image, "10", 0, $textx + 2, $texty + 2, $shadowcolor, $this->options['font'], $label);
                 imagettftext($this->image, "10", 0, $textx, $texty, $textcolor, $this->options['font'], $label);
             } else {
                 $textx = $xmid - round(imagefontwidth($this->fontsize) * strlen($label) / 2, 0);
                 $texty = $textx < $this->grapharea['x0'] + 2 ? $this->grapharea['x0'] + 2 : $textx;
                 $texty = $y0 + +floor($stepheight / 2) - floor(imagefontheight($this->fontsize) / 2);
                 if ($this->options['style3D']) {
                     $correction = floor(($nextval - ($nextval - $value) / 2) / $maxvalue * 20);
                     $textx = $textx + 20 - $correction;
                     $texty = $texty - 20 + $correction;
                 }
                 $shadowcolor = imagecolorallocate($this->image, $this->color[$i][0] - 50 < 0 ? 0 : $this->color[$i][0] - 50, $this->color[$i][1] - 50 < 0 ? 0 : $this->color[$i][1] - 50, $this->color[$i][2] - 50 < 0 ? 0 : $this->color[$i][2] - 50);
                 imagestring($this->image, $this->fontsize, $textx - 1, $texty - 1, $label, $shadowcolor);
                 imagestring($this->image, $this->fontsize, $textx + 1, $texty + 1, $label, $shadowcolor);
                 imagestring($this->image, $this->fontsize, $textx + 2, $texty + 2, $label, $shadowcolor);
                 imagestring($this->image, $this->fontsize, $textx, $texty, $label, $textcolor);
             }
             imagecolordeallocate($this->image, $shadowcolor);
             imagecolordeallocate($this->image, $textcolor);
         }
     }
     if ($this->options['style3D']) {
         $insidecolor = imagecolorallocate($this->image, $this->color[$numcats - 1][0] - 50 < 0 ? 0 : $this->color[$numcats - 1][0] - 50, $this->color[$numcats - 1][1] - 50 < 0 ? 0 : $this->color[$numcats - 1][1] - 50, $this->color[$numcats - 1][2] - 50 < 0 ? 0 : $this->color[$numcats - 1][2] - 50);
         imagefilledarc($this->image, $xmid + 20, $y0 - 20, $x3 - $x1, 40, 0, 360, $insidecolor, IMG_ARC_PIE);
         $linecolor = ImageColorAllocate($this->image, $this->color[$numcats - 1][0], $this->color[$numcats - 1][1], $this->color[$numcats - 1][2]);
         imagearc($this->image, $xmid + 20, $y0 - 20, $x3 - $x1, 40, 0, 360, $linecolor);
     }
     return true;
 }
Ejemplo n.º 30
0
    imagefilledarc($img, $centerx, $centery, $outerdia, $outerdia, 360 + $warnp, 0, $oYellow, IMG_ARC_EDGED);
}
// Critical
if ($crit && $critp <= -1) {
    // The "360 +" fix has been worked out by hipska. Thanks for that!
    imagefilledarc($img, $centerx, $centery, $outerdia, $outerdia, 360 + $critp, 0, $oRed, IMG_ARC_EDGED);
}
// Borders
imagearc($img, $centerx, $centery + 1, $outerdia + 2, $outerdia + 2, 180, 0, $oBlack);
imagefilledarc($img, $centerx, $centery, $outerdia / 10, $outerdia / 10, 180, 0, $oBlue, IMG_ARC_EDGED);
//===================
// Create tacho line.
//===================
$diffy = sin(deg2rad(-$p + 360)) * (($outerdia + 10) / 2);
$diffx = cos(deg2rad(-$p + 360)) * (($outerdia + 10) / 2);
imagefilledarc($img, $centerx - $diffx, $centery + $diffy, $outerdia + 10, $outerdia + 10, $p - 1, $p + 1, $oBlue, IMG_ARC_EDGED);
//===================
// Labels
//===================
// Speedometer labels
imageline($img, $centerx - $outerdia / 2 - 5, $centery + 1, $centerx + $outerdia / 2 + 5, $centery + 1, $oBlack);
imagestring($img, 1, $centerx - $outerdia / 2 - 15, $centery - 6, $min, $oBlack);
imagestring($img, 1, $centerx + $outerdia / 2 + 8, $centery - 6, $max, $oBlack);
$count = 1;
$iOffsetX = -10;
for ($degrees = 45; $degrees < 180; $degrees = $degrees + 45) {
    $bediffy = sin(deg2rad(-$degrees + 360)) * (($outerdia + 10) / 2);
    $bediffx = cos(deg2rad(-$degrees + 360)) * (($outerdia + 10) / 2);
    $bediffy1 = sin(deg2rad(-$degrees + 360)) * (($outerdia - 10) / 2);
    $bediffx1 = cos(deg2rad(-$degrees + 360)) * (($outerdia - 10) / 2);
    imageline($img, $centerx - $bediffx, $centery + $bediffy, $centerx - $bediffx1, $centery + $bediffy1, $oBlack);