当前位置: 首页>>代码示例>>PHP>>正文


PHP ImageFilledArc函数代码示例

本文整理汇总了PHP中ImageFilledArc函数的典型用法代码示例。如果您正苦于以下问题:PHP ImageFilledArc函数的具体用法?PHP ImageFilledArc怎么用?PHP ImageFilledArc使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ImageFilledArc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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);
            }
        }
    }
}
开发者ID:Geraldofilho1993,项目名称:financ,代码行数:32,代码来源:phPie.php

示例2: generate

 public function generate($f_image, $n_image)
 {
     ImageFilledArc($f_image, $this->_width, $this->_height, $this->_width * 2, $this->_height * 2, 0, 300, $this->_completeColorAllocate, IMG_ARC_PIE);
     ImageFilledArc($f_image, $this->_width, $this->_height, $this->_width * 2, $this->_height * 2, 300, 360, $this->_incompleteColorAllocate, IMG_ARC_PIE);
     imageantialias($n_image, true);
     imagecopyresampled($n_image, $f_image, 0, 0, 0, 0, $this->_width, $this->_height, $this->_width * 2, $this->_height * 2);
     return $this;
 }
开发者ID:besters,项目名称:My-Base,代码行数:8,代码来源:Pie.php

示例3: GetSignatureImage

function GetSignatureImage($signData)
{
    $base64DecData = base64_decode($signData);
    if (1 == 1) {
        $exploded_sign = explode(';', $base64DecData);
        $explode_firstRow = explode(',', $exploded_sign[0]);
        if (count($explode_firstRow) == 8) {
            // process ahead if there are enough data in first input
            $SignBackGround = Html2RGB($explode_firstRow[1]);
            $SignWidth = $explode_firstRow[3];
            $SignHeight = $explode_firstRow[4];
            $SignTransparent = strtoupper($explode_firstRow[5]);
            $SignPoints = (int) $explode_firstRow[6];
            $SignControl = $explode_firstRow[7];
            $im = imagecreatetruecolor($SignWidth, $SignHeight);
            $colBack = imagecolorallocate($im, $SignBackGround[0], $SignBackGround[1], $SignBackGround[2]);
            imagefill($im, 0, 0, $colBack);
            if ($SignTransparent == "TRUE") {
                imagecolortransparent($im, $colBack);
            }
            // Now get rest of points
            for ($counter = 1; $counter < count($exploded_sign); $counter++) {
                if (strlen($exploded_sign[$counter]) > 0) {
                    // Keep processing points
                    $exploded_PointData = explode(" ", trim($exploded_sign[$counter]));
                    $exploded_FirstPointData = explode(',', $exploded_PointData[0]);
                    $SignThick = $exploded_FirstPointData[0];
                    $SignPenColor = Html2RGB($exploded_FirstPointData[1]);
                    $penColor = imagecolorallocate($im, $SignPenColor[0], $SignPenColor[1], $SignPenColor[2]);
                    // Now run loop for rest of the points
                    if (count($exploded_PointData) == 2) {
                        $coXY = explode(',', trim($exploded_PointData[1]));
                        ImageFilledArc($im, $coXY[0], $coXY[1], 2 * $SignThick, 2 * $SignThick, 0, 360, $penColor, IMG_ARC_PIE);
                    } else {
                        for ($Incounter = 1; $Incounter < count($exploded_PointData) - 1; $Incounter++) {
                            $coXY = explode(',', trim($exploded_PointData[$Incounter]));
                            $coXY2 = explode(',', trim($exploded_PointData[$Incounter + 1]));
                            imgdrawLine($im, $coXY[0], $coXY[1], $coXY2[0], $coXY2[1], $penColor, $SignThick);
                            imgdrawLine($im, $coXY[0], $coXY[1], $coXY2[0], $coXY2[1], $penColor, $SignThick + 1);
                        }
                    }
                }
            }
            return $im;
        }
    }
    return null;
}
开发者ID:macconsultinggroup,项目名称:WordPress,代码行数:48,代码来源:license.php

示例4: GetSignatureImage

function GetSignatureImage($spqwzr_11)
{
    $enaysr_12 = base64_decode($spqwzr_11);
    if (1 == 1) {
        $jibrxv_13 = explode(base64_decode('Ow=='), $enaysr_12);
        $ahpyui_14 = explode(base64_decode('LA=='), $jibrxv_13[0]);
        if (count($ahpyui_14) == 8) {
            $qdfrcu_3 = Html2RGB($ahpyui_14[1]);
            $igkrwu_0 = $ahpyui_14[3];
            $rhncls_1 = $ahpyui_14[4];
            $qpgifq_5 = strtoupper($ahpyui_14[5]);
            $ijcski_6 = (int) $ahpyui_14[6];
            $uyagdp_7 = $ahpyui_14[7];
            $yjyqwd_10 = imagecreatetruecolor($igkrwu_0, $rhncls_1);
            $pshzfj_15 = imagecolorallocate($yjyqwd_10, $qdfrcu_3[0], $qdfrcu_3[1], $qdfrcu_3[2]);
            imagefill($yjyqwd_10, 0, 0, $pshzfj_15);
            if ($qpgifq_5 == base64_decode('VFJVRQ==')) {
                imagecolortransparent($yjyqwd_10, $pshzfj_15);
            }
            for ($zumudw_16 = 1; $zumudw_16 < count($jibrxv_13); $zumudw_16++) {
                if (strlen($jibrxv_13[$zumudw_16]) > 0) {
                    $dmqeif_17 = explode(base64_decode('IA=='), trim($jibrxv_13[$zumudw_16]));
                    $bkgzoa_18 = explode(base64_decode('LA=='), $dmqeif_17[0]);
                    $hzwrws_2 = $bkgzoa_18[0];
                    $uooxsm_4 = Html2RGB($bkgzoa_18[1]);
                    $vuinxy_19 = imagecolorallocate($yjyqwd_10, $uooxsm_4[0], $uooxsm_4[1], $uooxsm_4[2]);
                    if (count($dmqeif_17) == 2) {
                        $umkucn_20 = explode(base64_decode('LA=='), trim($dmqeif_17[1]));
                        ImageFilledArc($yjyqwd_10, $umkucn_20[0], $umkucn_20[1], 2 * $hzwrws_2, 2 * $hzwrws_2, 0, 360, $vuinxy_19, IMG_ARC_PIE);
                    } else {
                        for ($puihwm_21 = 1; $puihwm_21 < count($dmqeif_17) - 1; $puihwm_21++) {
                            $umkucn_20 = explode(base64_decode('LA=='), trim($dmqeif_17[$puihwm_21]));
                            $kkgkso_22 = explode(base64_decode('LA=='), trim($dmqeif_17[$puihwm_21 + 1]));
                            imgdrawLine($yjyqwd_10, $umkucn_20[0], $umkucn_20[1], $kkgkso_22[0], $kkgkso_22[1], $vuinxy_19, $hzwrws_2);
                            imgdrawLine($yjyqwd_10, $umkucn_20[0], $umkucn_20[1], $kkgkso_22[0], $kkgkso_22[1], $vuinxy_19, $hzwrws_2 + 1);
                        }
                    }
                }
            }
            return $yjyqwd_10;
        }
    }
    return null;
}
开发者ID:wp-premium,项目名称:gravityformssignature,代码行数:44,代码来源:license.php

示例5: showPieGraph

 public function showPieGraph()
 {
     $myImage = ImageCreate(300, 300);
     $white = ImageColorAllocate($myImage, 255, 255, 255);
     $red = ImageColorAllocate($myImage, 255, 0, 0);
     $green = ImageColorAllocate($myImage, 0, 255, 0);
     $blue = ImageColorAllocate($myImage, 0, 0, 255);
     $lt_red = ImageColorAllocate($myImage, 255, 150, 150);
     $lt_green = ImageColorAllocate($myImage, 150, 255, 150);
     $lt_blue = ImageColorAllocate($myImage, 150, 150, 255);
     for ($i = 120; $i > 100; $i--) {
         ImageFilledArc($myImage, 100, $i, 200, 150, 0, 90, $lt_red, IMG_ARC_PIE);
         ImageFilledArc($myImage, 100, $i, 200, 150, 90, 360, $lt_blue, IMG_ARC_PIE);
         //  ImageFilledArc ($myImage, 100, $i, 200, 150, 180, 360, $lt_blue, IMG_ARC_PIE);
     }
     ImageFilledArc($myImage, 100, 100, 200, 150, 0, 90, $red, IMG_ARC_PIE);
     ImageFilledArc($myImage, 100, 100, 200, 150, 90, 360, $blue, IMG_ARC_PIE);
     //ImageFilledArc($myImage, 100, 100, 200, 150, 180, 360 , $blue, IMG_ARC_PIE);
     header("Content-type: image/png");
     ImagePNG($myImage);
     ImageDestroy($myImage);
 }
开发者ID:rickyx12,项目名称:mendero,代码行数:22,代码来源:myDatabase1.php

示例6: draw

 function draw()
 {
     $black = ImageColorAllocate($this->draw->res, 0, 0, 0);
     // Получим размеры изображения
     $W = $this->draw->sX();
     $H = $this->draw->sY();
     $this->draw->antialias(TRUE);
     // Вывод легенды #####################################
     // Посчитаем количество пунктов,от этого зависит высота легенды
     $this->legend_count = sizeof($this->legend);
     // Посчитаем максимальную длину пункта,от этого зависит ширина легенды
     $max_length = 0;
     foreach ($this->legend as $v) {
         if ($max_length < strlen($v)) {
             $max_length = strlen($v);
         }
     }
     // Номер шрифта,котором мы будем выводить легенду
     $FONT = 2;
     $font_w = ImageFontWidth($FONT);
     $font_h = ImageFontHeight($FONT);
     // Вывод прямоугольника - границы легенды ----------------------------
     $l_width = $font_w * $max_length + $font_h + 10 + 5 + 10;
     $l_height = $font_h * $this->legend_count + 10 + 10;
     // Получим координаты верхнего левого угла прямоугольника - границы легенды
     $l_x1 = $W - 100 - $l_width;
     $l_y1 = ($H - $l_height) / 2;
     // Выводя прямоугольника - границы легенды
     ImageRectangle($this->draw->res, $l_x1, $l_y1, $l_x1 + $l_width, $l_y1 + $l_height, $black);
     // Вывод текст легенды и цветных квадратиков
     $text_x = $l_x1 + 10 + 5 + $font_h;
     $square_x = $l_x1 + 10;
     $y = $l_y1 + 10;
     $i = 0;
     foreach ($this->legend as $v) {
         $dy = $y + $i * $font_h;
         $this->draw->ttftext($v, $black, CORE_PATH . 'fonts/TAHOMA.TTF', 8, $text_x, $dy + 11);
         ImageFilledRectangle($this->draw->res, $square_x + 1, $dy + 1, $square_x + $font_h - 1, $dy + $font_h - 1, $this->draw->hex2color($this->colors[$i]));
         ImageRectangle($this->draw->res, $square_x + 1, $dy + 1, $square_x + $font_h - 1, $dy + $font_h - 1, $black);
         $i++;
     }
     // Вывод круговой диаграммы ----------------------------------------
     $sv = sizeof($this->values);
     if (sizeof($this->values) == 1) {
         $this->values[] = 9.999999999999999E-12;
         ++$sv;
     }
     $total = array_sum($this->values);
     $anglesum = $angle = array(0);
     $i = 1;
     // Расчет углов
     while ($i < $sv) {
         $part = $this->values[$i - 1] / $total;
         $angle[$i] = floor($part * 360);
         $anglesum[$i] = array_sum($angle);
         $i++;
     }
     $anglesum[] = $anglesum[0];
     // Расчет диаметра
     $diametr = $l_x1 - 10 - 10;
     // Расчет координат центра эллипса
     $circle_x = $diametr / 2 + 10;
     $circle_y = $H / 2 - 10;
     // Поправка диаметра,если эллипс не помещается по высоте
     if ($diametr > $H * 2 - 10 - 10) {
         $diametr = $H * 2 - 20 - 20 - 40;
     }
     // Вывод тени
     for ($j = 20; $j > 0; $j--) {
         for ($i = 0; $i < sizeof($anglesum) - 1; $i++) {
             ImageFilledArc($this->draw->res, $circle_x, $circle_y + $j, $diametr, $diametr / 2, $anglesum[$i], $anglesum[$i + 1], $this->draw->hex2color($this->shadows[$i]), IMG_ARC_PIE);
         }
     }
     // Вывод круговой диаграммы
     for ($i = 0; $i < sizeof($anglesum) - 1; $i++) {
         ImageFilledArc($this->draw->res, $circle_x, $circle_y, $diametr, $diametr / 2, $anglesum[$i], $anglesum[$i + 1], $this->draw->hex2color($this->colors[$i]), IMG_ARC_PIE);
     }
 }
开发者ID:kakserpom,项目名称:WakePHP,代码行数:78,代码来源:ImageDrawDiagramm.php

示例7: display

	/**
	*Display the graph
  *this is the final function to be called to display the graph.
	*/
    function display()
    {
		$this->init();
		
        $this->pie = @ImageCreateTrueColor($this->init_img_width, $this->init_img_height);

        $colBG = ImageColorAllocate($this->pie, $this->pie_color_bg[0], $this->pie_color_bg[1], $this->pie_color_bg[2]);
        ImageFill($this->pie, 0, 0, $colBG);

        // Do the 3d effect
		$this->start_3d = $this->cy + $this->init_3d_height;

		for($i=$this->start_3d;$i > $this->cy; $i--)
		{
			reset($this->pie_data);
			$c=0;
			foreach($this->pie_data as $k => $data)
			{
				$col = $this->get_color($k, "3d");
				ImageFilledArc($this->pie, 
							   $this->cx, $i, 
							   $this->init_width, $this->init_height,  
							   $data[0], $data[1], 
							   $col, IMG_ARC_NOFILL);
				$c++;
			}
		}
		// Now do the graph
		reset($this->pie_data);
		$c=0;
		foreach($this->pie_data as $k => $data)
		{
			$col = $this->get_color($k, "normal");
			ImageFilledArc($this->pie, 
						   $this->cx, $this->cy, 
						   $this->init_width, $this->init_height,  
						   $data[0], $data[1], 
						   $col, IMG_ARC_PIE);
			$c++;
		}
		
		// The Legends
		$cellpadding=5;
		$max_str=0;
		$items=0;
		foreach($this->legends as $k => $legend)
		{
			if(strlen($legend) > $max_str)
			{
				$max_str = strlen($legend);
			}
			$items++;
		}
		$box_with   = ImageFontHeight(2)-5;
		$box_height = ImageFontHeight(2)-5;

		$leg_height = ((ImageFontHeight(2)+2) * $items)   + ($cellpadding * 2);
		$leg_width  = (ImageFontWidth(2)  * ($max_str+7)) + ($cellpadding * 2) +($box_with * 2);

		$leg_img = ImageCreateTrueColor($leg_width, $leg_height);
		ImageFill($leg_img, 0, 0, $colBG);
		
		// text color
		$colTEXT   = ImageColorAllocate($leg_img, $this->pie_color_text[0], $this->pie_color_text[1], $this->pie_color_text[2]);
		// text / legends backgroundcolor
		$colTEXTBG = ImageColorAllocate($leg_img, $this->pie_color_text_bg[0], $this->pie_color_text_bg[1], $this->pie_color_text_bg[2]);
		// border color for the legends
		$colTEXTBO = ImageColorAllocate($leg_img, $this->pie_color_border[0], $this->pie_color_border[1], $this->pie_color_border[2]);

		// the table + border for the legend
		ImageFilledRectangle($leg_img, 0, 0, $leg_width, $leg_height, $colTEXTBG);
		ImageRectangle($leg_img, 0, 0, $leg_width-1, $leg_height-1, $colTEXTBO);

		reset($this->data);
		$c=0;
		$lx = $box_with + $cellpadding*2;
		$ly = $cellpadding;
		foreach($this->data as $k => $data)
		{
			// legend text item
			$percent = round($data/$this->total*100, 2);
			$text = $this->legends[$k]." ".$percent."%";
			$col = $this->get_color($k, "normal");

			ImageFilledRectangle($leg_img, $cellpadding, $ly+2, $cellpadding+$box_with, $ly+$box_height+2, $col);
			ImageRectangle($leg_img, $cellpadding, $ly+2, $cellpadding+$box_with, $ly+$box_height+2, $colTEXTBO);
			ImageString($leg_img, 2, $lx, $ly, $text, $colTEXT);
			$ly += (2 + ImageFontHeight(2));
			$c++;
		}
		// final setups an image creation
		$pie_width = ImageSX($this->pie);
		$pie_height = ImageSY($this->pie);
		if($this->img_height < $leg_height)
		{
			$this->img_height = $leg_height;
//.........这里部分代码省略.........
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:101,代码来源:PieChart.php

示例8: database1

$month = $_GET['month'];
$day = $_GET['day'];
$year = $_GET['year'];
$month1 = $_GET['month1'];
$day1 = $_GET['day1'];
$year1 = $_GET['year1'];
$ro = new database1();
$totalPx = $ro->getTotalPx($month, $day, $year, $month1, $day1, $year1, "OPD") + $ro->getTotalPx($month, $day, $year, $month1, $day1, $year1, "IPD");
$opd1 = $ro->getTotalPx($month, $day, $year, $month1, $day1, $year1, "OPD") / $totalPx;
$ipd1 = $ro->getTotalPx($month, $day, $year, $month1, $day1, $year1, "IPD") / $totalPx;
$opd2 = $opd1 * 360;
$ipd2 = $ipd1 * 360;
$myImage = ImageCreate(250, 200);
$white = ImageColorAllocate($myImage, 255, 255, 255);
$red = ImageColorAllocate($myImage, 255, 0, 0);
$green = ImageColorAllocate($myImage, 0, 255, 0);
$blue = ImageColorAllocate($myImage, 0, 0, 255);
$lt_red = ImageColorAllocate($myImage, 255, 150, 150);
$lt_green = ImageColorAllocate($myImage, 150, 255, 150);
$lt_blue = ImageColorAllocate($myImage, 150, 150, 255);
for ($i = 120; $i > 100; $i--) {
    ImageFilledArc($myImage, 100, $i, 200, 120, 0, $opd2, $lt_red, IMG_ARC_PIE);
    ImageFilledArc($myImage, 100, $i, 200, 120, $ipd2, 360, $lt_blue, IMG_ARC_PIE);
    //  ImageFilledArc ($myImage, 100, $i, 200, 150, 180, 360, $lt_blue, IMG_ARC_PIE);
}
ImageFilledArc($myImage, 100, 100, 200, 120, 0, $opd2, $red, IMG_ARC_PIE);
ImageFilledArc($myImage, 100, 100, 200, 120, $ipd2, 360, $blue, IMG_ARC_PIE);
//ImageFilledArc($myImage, 100, 100, 200, 150, 180, 360 , $blue, IMG_ARC_PIE);
header("Content-type: image/png");
ImagePNG($myImage);
ImageDestroy($myImage);
开发者ID:rickyx12,项目名称:protacio,代码行数:31,代码来源:censusPie.php

示例9: generateChart


//.........这里部分代码省略.........
                 }
                 // Draw out the font for the label
                 $mPlaceX = $width + $max_text_height + $mSpaceSize + $max_percent_width + $mSpaceSize;
                 imagettftext($this->chartImage->img, $this->fontLabel->fontSize, 0, $mPlaceX, $label_place + 10, chartColorHex($this->chartImage->img, $this->fontLabel->textColor), $this->fontLabel->textFont, $label_output);
                 // Bump down to the next line based on the font height
                 $label_place = $label_place + $max_text_height + 5;
                 // 15;
             }
         }
         $centerX = round($width / 2);
         $centerY = round(($this->chartImage->imgHeight - $this->chartImage->shadowDrop) / 2);
         $diameterX = $width - 4;
         $diameterY = $this->chartImage->imgHeight - $this->chartImage->shadowDrop - 4;
         reset($this->values);
         $data_sum = array_sum($this->values);
         $start = 270;
         $counter = 0;
         $value_counter = 0;
         // Determine the slices
         for ($i = 0; $i < count($this->values); $i++) {
             // Get each value set for the list
             list($key, $value) = each($this->values);
             $counter += $value;
             $end = ceil($counter / $data_sum * 360) + 270;
             $slice[] = array($start, $end, $shadow_color[$value_counter % count($shadow_color)], $fill_color[$value_counter % count($fill_color)]);
             $start = $end;
             $value_counter++;
         }
         // Draw the shadow
         for ($i = $centerY + $this->chartImage->shadowDrop; $i > $centerY; $i--) {
             // How many pixels deep?
             for ($j = 0; $j < count($slice); $j++) {
                 if ($slice[$j][0] != $slice[$j][1]) {
                     ImageFilledArc($this->chartImage->img, $centerX, $i, $diameterX, $diameterY, $slice[$j][0], $slice[$j][1], $slice[$j][2], IMG_ARC_PIE);
                 }
             }
         }
         // Draw each slice
         for ($j = 0; $j < count($slice); $j++) {
             if ($slice[$j][0] != $slice[$j][1]) {
                 ImageFilledArc($this->chartImage->img, $centerX, $centerY, $diameterX, $diameterY, $slice[$j][0], $slice[$j][1], $slice[$j][3], IMG_ARC_PIE);
             }
         }
     } else {
         ////////////////////////
         // Bar Chart
         ////////////////////////
         // Max value is required to adjust the scale
         $max_value = max($this->values);
         // Find the size of graph by substracting the size of borders
         $graph_width = $this->chartImage->imgWidth - $this->marginSize * 2;
         $graph_height = $this->chartImage->imgHeight - $this->marginSize * 2;
         $total_bars = count($this->values);
         $gap = ($graph_width - $total_bars * $this->barWidth) / ($total_bars + 1);
         // Determine the size of the on the X Axis Labels
         reset($this->values);
         for ($i = 0; $i < count($this->values); $i++) {
             // Get each value set for the list
             list($key, $this->value) = each($this->values);
             // Display off the page somewhere, and then capture
             $text_details = imagettftext($this->chartImage->img, $this->fontLabel->fontSize, $this->fontLabel->fontAngle, -10000, -10000, chartColorHex($this->chartImage->img, $this->fontLabel->textColor), $this->fontLabel->textFont, $key);
             //echo ('<br />');
             //print_r($text_details);
             // Height of Key
             // -- This is odd, because the location is on the corner points of the text ... NOT the rectangle in which the text prints
             // -- So, we need to find the worst circumstance
开发者ID:roncemer,项目名称:pfmgr2,代码行数:67,代码来源:Chart.class.php

示例10: DrawPieChart


//.........这里部分代码省略.........
         //    plot_area_width = avail_width + 2 * (LR_marg + label_width + safe_margin)
         //        Where LR_marg = max(safe_margin, avail_width * label_scale_position - avail_width/2)
         //    plot_area_height = avail_height + 2 * (TB_marg + label_height + safe_margin + shading)
         //        Where TB_marg = max(safe_margin, avail_height * label_scale_position - avail_height/2)
         //        Note shading is on bottom only, but since center is fixed, it is counted on top too.
         // Note (avail_width * label_scale_position) is the distance from the pie center to the label
         // text base point. Subtract avail_width/2 to get the inner margin (unless it is too small).
         // Similar for Y: avail_height * label_scale_position - avail_height/2 is the distance from
         // the pie center up to the label text base point.
         // Calculate available space for both values of LR_marg, TB_marg and take the smaller ones.
         $avail_width = min(($this->plot_area_width / 2 - $label_max_width - $this->safe_margin) / $this->label_scale_position, $this->plot_area_width - 4 * $this->safe_margin - 2 * $label_max_width);
         $avail_height = min(($this->plot_area_height / 2 - $label_max_height - $this->safe_margin - $this->shading) / $this->label_scale_position, $this->plot_area_height - 4 * $this->safe_margin - 2 * ($label_max_height + $this->shading));
         // Sanity check - don't let large labels shrink the pie too much.
         $avail_width = max($avail_width, $this->pie_min_size_factor * $this->plot_area_width);
         $avail_height = max($avail_height, $this->pie_min_size_factor * $this->plot_area_height);
     } else {
         // No adjustment needed for labels
         $avail_width = $this->plot_area_width - 2 * $this->safe_margin;
         // Note shading is only on bottom, but need to subtract 2x because center does not move.
         $avail_height = $this->plot_area_height - 2 * ($this->safe_margin + $this->shading);
     }
     // Calculate the pie width and height for the best fit, given diam_factor and available space:
     if ($avail_height / $avail_width > $diam_factor) {
         $pie_width = $avail_width;
         $pie_height = $pie_width * $diam_factor;
     } else {
         $pie_height = $avail_height;
         $pie_width = $pie_height / $diam_factor;
     }
     // Factors used to calculate label positions by DrawPieLabel(). See there for explanation.
     if ($do_labels) {
         $r['reverse'] = 0.25 < $this->label_scale_position && $this->label_scale_position < 0.5;
         $r['x'] = $pie_width * $this->label_scale_position;
         $r['y'] = $pie_height * $this->label_scale_position;
         if ($labels_outside) {
             // Don't let outside labels touch the pie edge - move them out a bit:
             $r['x'] = max($r['x'], $pie_width / 2 + $this->safe_margin);
             $r['y'] = max($r['y'], $pie_height / 2 + $this->safe_margin);
         } else {
             // Don't let inside labels touch the pie edge - move them in a bit:
             $r['x'] = min($r['x'], $pie_width / 2 - $this->safe_margin);
             $r['y'] = min($r['y'], $pie_height / 2 - $this->safe_margin);
         }
     }
     // Draw the pie. For shaded pies, draw one set for each shading level ($h).
     for ($h = $this->shading; $h >= 0; $h--) {
         $color_index = 0;
         // Initialize the start angle (for clockwise) or end angle (for counter-clockwise).
         // See "Calculate the two angles" below to make sense of this.
         $end_angle = $start_angle = $this->pie_start_angle;
         // Loop over all pie segments:
         for ($j = 0; $j < $num_slices; $j++) {
             $slice_weight = $sumarr[$j];
             $arc_angle = 360 * $slice_weight / $total;
             // For shaded pies: the last one (at the top of the "stack") has a brighter color:
             if ($h == 0) {
                 $slicecol = $this->ndx_data_colors[$color_index];
             } else {
                 $slicecol = $this->ndx_data_dark_colors[$color_index];
             }
             // Calculate the two angles that define this pie segment.
             // Note that regardless of the direction (CW or CCW), start_angle < end_angle.
             if ($this->pie_direction_cw) {
                 $end_angle = $start_angle;
                 $start_angle -= $arc_angle;
             } else {
                 $start_angle = $end_angle;
                 $end_angle += $arc_angle;
             }
             // Calculate the arc angles for ImageFilledArc(), which measures angles in the opposite
             // direction (counter-clockwise), and only takes integer values.
             $arc_start_angle = (int) (360 - $start_angle);
             $arc_end_angle = (int) (360 - $end_angle);
             // Don't try to draw a 0 degree slice - it would make a full circle.
             if ($arc_start_angle > $arc_end_angle) {
                 // Draw the slice
                 ImageFilledArc($this->img, $xpos, $ypos + $h, $pie_width, $pie_height, $arc_end_angle, $arc_start_angle, $slicecol, IMG_ARC_PIE);
                 // Processing to do only for the last (if shaded) or only (if unshaded) loop:
                 if ($h == 0) {
                     // Draw the pie segment outline (if enabled):
                     if ($do_borders) {
                         ImageFilledArc($this->img, $xpos, $ypos, $pie_width, $pie_height, $arc_end_angle, $arc_start_angle, $this->ndx_pieborder_color, IMG_ARC_PIE | IMG_ARC_EDGED | IMG_ARC_NOFILL);
                     }
                     // Draw the label:
                     if ($do_labels) {
                         $this->DrawPieLabel($labels[$j], $xpos, $ypos, $start_angle, $arc_angle, $r);
                     }
                     // Trigger a data points callback; note it gets the calculated (reversed) angles:
                     $this->DoCallback('data_points', 'pie', $j, 0, $xpos, $ypos, $pie_width, $pie_height, $arc_start_angle, $arc_end_angle);
                 }
             }
             if (++$color_index >= $max_data_colors) {
                 $color_index = 0;
             }
         }
         // end loop for each slice
     }
     // end loop for each level of shading
     return TRUE;
 }
开发者ID:danorama,项目名称:orsee,代码行数:101,代码来源:class.phplot.php

示例11: ImageCreate

<?php

//create the canvas
$myImage = ImageCreate(300, 300);
//set up some colors for use on the canvas
$white = ImageColorAllocate($myImage, 255, 255, 255);
$red = ImageColorAllocate($myImage, 255, 0, 0);
$green = ImageColorAllocate($myImage, 0, 255, 0);
$blue = ImageColorAllocate($myImage, 0, 0, 255);
//draw a pie
ImageFilledArc($myImage, 100, 100, 200, 150, 0, 90, $red, IMG_ARC_PIE);
ImageFilledArc($myImage, 100, 100, 200, 150, 90, 180, $green, IMG_ARC_PIE);
ImageFilledArc($myImage, 100, 100, 200, 150, 180, 360, $blue, IMG_ARC_PIE);
//output the image to the browser
header("Content-type: image/png");
ImagePNG($myImage);
//clean up after yourself
ImageDestroy($myImage);
开发者ID:asifameer,项目名称:PMAAiO-code,代码行数:18,代码来源:imagecreatepie.php

示例12: print_fan_chart


//.........这里部分代码省略.........
    // image init
    $image = ImageCreate($fanw, $fanh);
    $black = ImageColorAllocate($image, 0, 0, 0);
    $white = ImageColorAllocate($image, 0xff, 0xff, 0xff);
    ImageFilledRectangle($image, 0, 0, $fanw, $fanh, $white);
    ImageColorTransparent($image, $white);
    $rgb = $css->Get(".fan_chart", "color");
    if (empty($rgb)) {
        $rgb = "#000000";
    }
    $color = ImageColorAllocate($image, hexdec(substr($rgb, 1, 2)), hexdec(substr($rgb, 3, 2)), hexdec(substr($rgb, 5, 2)));
    $rgb = $css->Get(".fan_chart", "background-color");
    if (empty($rgb)) {
        $rgb = "#EEEEEE";
    }
    $bgcolor = ImageColorAllocate($image, hexdec(substr($rgb, 1, 2)), hexdec(substr($rgb, 3, 2)), hexdec(substr($rgb, 5, 2)));
    $rgb = $css->Get(".fan_chart_box", "background-color");
    if (empty($rgb)) {
        $rgb = "#D0D0AC";
    }
    $bgcolorM = ImageColorAllocate($image, hexdec(substr($rgb, 1, 2)), hexdec(substr($rgb, 3, 2)), hexdec(substr($rgb, 5, 2)));
    $rgb = $css->Get(".fan_chart_boxF", "background-color");
    if (empty($rgb)) {
        $rgb = "#D0ACD0";
    }
    $bgcolorF = ImageColorAllocate($image, hexdec(substr($rgb, 1, 2)), hexdec(substr($rgb, 3, 2)), hexdec(substr($rgb, 5, 2)));
    // imagemap
    $imagemap = "<map id=\"fanmap\" name=\"fanmap\">";
    // loop to create fan cells
    while ($gen >= 0) {
        // clean current generation area
        $deg2 = 360 + ($fandeg - 180) / 2;
        $deg1 = $deg2 - $fandeg;
        ImageFilledArc($image, $cx, $cy, $rx, $rx, $deg1, $deg2, $bgcolor, IMG_ARC_PIE);
        $rx -= 3;
        // calculate new angle
        $p2 = pow(2, $gen);
        $angle = $fandeg / $p2;
        $deg2 = 360 + ($fandeg - 180) / 2;
        $deg1 = $deg2 - $angle;
        // special case for rootid cell
        if ($gen == 0) {
            $deg1 = 90;
            $deg2 = 360 + $deg1;
        }
        // draw each cell
        while ($sosa >= $p2) {
            $pid = $treeid[$sosa];
            if (!empty($pid)) {
                $indirec = find_person_record($pid);
                if (!$indirec) {
                    $indirec = find_updated_record($pid);
                }
                if ($sosa % 2) {
                    $bg = $bgcolorF;
                } else {
                    $bg = $bgcolorM;
                }
                if ($sosa == 1) {
                    $bg = $bgcolor;
                    // sex unknown
                    if (preg_match("/1 SEX F/", $indirec) > 0) {
                        $bg = $bgcolorF;
                    } else {
                        if (preg_match("/1 SEX M/", $indirec) > 0) {
                            $bg = $bgcolorM;
开发者ID:bitweaver,项目名称:phpgedview,代码行数:67,代码来源:fanchart.php

示例13: drawshape

 private function drawshape($image, $action, $color)
 {
     switch ($action % 7) {
         case 0:
             ImageFilledRectangle($image, $this->getX(), $this->getY(), $this->getX(), $this->getY(), $color);
             break;
         case 1:
         case 2:
             ImageFilledEllipse($image, $this->getX(), $this->getY(), $this->getX(), $this->getY(), $color);
             break;
         case 3:
             $points = array($this->getX(), $this->getY(), $this->getX(), $this->getY(), $this->getX(), $this->getY(), $this->getX(), $this->getY());
             ImageFilledPolygon($image, $points, 4, $color);
             break;
         case 4:
         case 5:
         case 6:
             $start = $this->getInt() * 360 / 256;
             $end = $start + $this->getInt() * 180 / 256;
             ImageFilledArc($image, $this->getX(), $this->getY(), $this->getX(), $this->getY(), $start, $end, $color, IMG_ARC_PIE);
             break;
     }
 }
开发者ID:nichdu,项目名称:ZeroBin,代码行数:23,代码来源:vizhash_gd_zero.php

示例14: display


//.........这里部分代码省略.........
//			ImageRectangle($leg_img, $cellpadding, $ly+2, $cellpadding+$box_with, $ly+$box_height+2, $colTEXTBO);
//teste		ImageString($leg_img, 2, $lx, $ly, $text, $colTEXT);
//			ImageString($leg_img, $FontNumber, $lx, $ly, $text, $col);			

   		    $MeuY = round((ImageFontHeight($FontNumber) * .5) + ($valuecounter * 1.5 * ImageFontHeight($FontNumber)));
			ImageString($leg_img, $FontNumber, 5, $MeuY, $text, $col);	

					$MeuYLinha = $MeuY + ImageFontHeight($FontNumber) + 2;

					ImageLine($leg_img, 5, $MeuYLinha, $TamanhoLinha, $MeuYLinha, '999999');					
//					ImageLine($im, 5, $MeuYLinha+2, $TamanhoLinha, $MeuYLinha+2, '999999');										



			
			$ly += ($FontNumber + ImageFontHeight($FontNumber));
			$c++;
			$valuecounter++;
		}
		// final setups an image creation



        // Do the 3d effect
		$this->start_3d = $this->cy + $this->init_3d_height;

		for($i=$this->start_3d;$i > $this->cy; $i--)
		{
			reset($this->pie_data);
			$c=0;
			foreach($this->pie_data as $k => $data)
			{
				$col = $this->get_color($k, "3d");		    
				ImageFilledArc($this->pie, 
							   $this->cx, $i, 
							   $this->init_width, $this->init_height,  
							   $data[0], $data[1], 
							   $col, IMG_ARC_NOFILL);
				$c++;
			}
		}


		// Now do the graph
		reset($this->pie_data);
		$c=0;
		foreach($this->pie_data as $k => $data)
		{
			$col = $this->get_color($k, "normal");
			ImageFilledArc($this->pie, 
						   $this->cx, $this->cy, 
						   $this->init_width, $this->init_height,  
						   $data[0], $data[1], 
						   $col, IMG_ARC_PIE);
			$c++;
		}


		$pie_width = ImageSX($this->pie);
		$pie_height = ImageSY($this->pie);
		if($this->img_height < $leg_height)
		{
			$this->img_height = $leg_height;
		}
		$final = ImageCreateTrueColor($this->img_width+$leg_width+$cellpadding, $this->img_height);
开发者ID:GabrielDiniz,项目名称:FluxNetControl,代码行数:66,代码来源:piegraph.class.php

示例15: Diagramm

 function Diagramm($im, $VALUES, $LEGEND)
 {
     //GLOBAL $COLORS,$SHADOWS;
     $black = ImageColorAllocate($im, 0, 0, 0);
     // Получим размеры изображения
     $W = ImageSX($im);
     $H = ImageSY($im);
     // Вывод легенды #####################################
     // Посчитаем количество пунктов, от этого зависит высота легенды
     //$legend_count=count($LEGEND);
     $legend_count = $this->ucount;
     // Посчитаем максимальную длину пункта, от этого зависит ширина легенды
     $max_length = 0;
     foreach ($LEGEND as $v) {
         if ($max_length < strlen($v)) {
             $max_length = strlen($v);
         }
     }
     // Номер шрифта, котором мы будем выводить легенду
     $FONT = 2;
     $font_w = ImageFontWidth($FONT);
     $font_h = ImageFontHeight($FONT);
     // Вывод прямоугольника - границы легенды ----------------------------
     $l_width = $font_w * $max_length + $font_h + 10 + 5 + 10;
     $l_height = $font_h * $legend_count + 10 + 10;
     // Получим координаты верхнего левого угла прямоугольника - границы легенды
     $l_x1 = $W - 10 - $l_width;
     $l_y1 = ($H - $l_height) / 2;
     // Выводя прямоугольника - границы легенды
     //ImageRectangle($im, $l_x1, $l_y1, $l_x1+$l_width, $l_y1+$l_height, $black);
     // Вывод текст легенды и цветных квадратиков
     $text_x = $l_x1 + 10 + 5 + $font_h;
     $square_x = $l_x1 + 10;
     $y = $l_y1 + 10;
     $i = 0;
     foreach ($LEGEND as $v) {
         $dy = $y + $i * $font_h;
         ImageString($im, $FONT, $text_x, $dy, $v, $black);
         ImageFilledRectangle($im, $square_x + 1, $dy + 1, $square_x + $font_h - 1, $dy + $font_h - 1, $this->COLORS[$i]);
         ImageRectangle($im, $square_x + 1, $dy + 1, $square_x + $font_h - 1, $dy + $font_h - 1, $black);
         $i++;
     }
     // Вывод круговой диаграммы ----------------------------------------
     $total = array_sum($VALUES);
     $anglesum = $angle = array(0);
     $i = 1;
     // Расчет углов
     while ($i < count($VALUES)) {
         $part = $VALUES[$i - 1] / $total;
         $angle[$i] = floor($part * 360);
         $anglesum[$i] = array_sum($angle);
         $i++;
     }
     $anglesum[] = $anglesum[0];
     // Расчет диаметра
     //	$diametr=$l_x1-10-10;
     $diametr = $l_x1 - 10 - 10;
     // Расчет координат центра эллипса
     $circle_x = $diametr / 2 + 10;
     $circle_y = $H / 2 - 10;
     // Поправка диаметра, если эллипс не помещается по высоте
     if ($diametr > $H * 2 - 10 - 10) {
         $diametr = $H * 2 - 20 - 20 - 40;
     }
     // Вывод тени
     for ($j = 20; $j > 0; $j--) {
         for ($i = 0; $i < count($anglesum) - 1; $i++) {
             ImageFilledArc($im, $circle_x, $circle_y + $j, $diametr, $diametr / 2, $anglesum[$i], $anglesum[$i + 1], $this->SHADOWS[$i], IMG_ARC_PIE);
         }
     }
     // Вывод круговой диаграммы
     for ($i = 0; $i < count($anglesum) - 1; $i++) {
         ImageFilledArc($im, $circle_x, $circle_y, $diametr, $diametr / 2, $anglesum[$i], $anglesum[$i + 1], $this->COLORS[$i], IMG_ARC_PIE);
     }
 }
开发者ID:ruNovel,项目名称:sams2,代码行数:75,代码来源:chart.php


注:本文中的ImageFilledArc函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。