本文整理汇总了PHP中imagefilledarc函数的典型用法代码示例。如果您正苦于以下问题:PHP imagefilledarc函数的具体用法?PHP imagefilledarc怎么用?PHP imagefilledarc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imagefilledarc函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: draw_clusters
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;
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:35,代码来源:cluster_testing.php
示例2: fill_arc
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);
}
}
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:26,代码来源:APCImages.php
示例3: piechart
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);
}
开发者ID:asta-kit,项目名称:friwahl-legacy,代码行数:25,代码来源:graph.php
示例4: gd_rectangle
/**
* 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;
}
开发者ID:Sajaki,项目名称:addons,代码行数:51,代码来源:gd_rectangle.php
示例5: check
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);
}
开发者ID:lsunny,项目名称:henanshichang,代码行数:30,代码来源:i.php
示例6: drawPieChart
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;
}
}
开发者ID:Wasan45,项目名称:PDCA_Project-Service-,代码行数:29,代码来源:GraphController.php
示例7: draw
/**
* 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);
}
}
开发者ID:melogamepay,项目名称:xp-framework,代码行数:14,代码来源:Arc.class.php
示例8: draw_data
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);
}
开发者ID:Atiragram,项目名称:poit-labs,代码行数:8,代码来源:image-2.php
示例9: imagefilledroundedrectangle
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);
}
开发者ID:jiangxilong,项目名称:network-weathermap,代码行数:9,代码来源:image-functions.php
示例10: draw
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;
}
开发者ID:rawork,项目名称:colors-life,代码行数:56,代码来源:CDiagram.php
示例11: createPie
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);
}
开发者ID:mkrdip,项目名称:Management-Information-System,代码行数:56,代码来源:createPie.php
示例12: arc
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));
}
开发者ID:rendix2,项目名称:QW_MVS,代码行数:10,代码来源:Images.php
示例13: _get_lt_rounder_corner
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;
}
开发者ID:184609680,项目名称:wcy_O2O_95180,代码行数:11,代码来源:yuanjiao.lib.php
示例14: perform
/**
* 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);
}
开发者ID:BGCX262,项目名称:zym-svn-to-git,代码行数:18,代码来源:DrawArc.php
示例15: drawpie
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;
}
}
开发者ID:nicelxm,项目名称:about_php,代码行数:12,代码来源:tongji.php
示例16: drawPie
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);
}
开发者ID:noikiy,项目名称:owaspbwa,代码行数:14,代码来源:gd.php
示例17: DrawPie
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('画布边长设置不正确或统计数据为空!');
}
}
开发者ID:xiaohong1633,项目名称:shl207,代码行数:49,代码来源:drawCloumn.php
示例18: generate
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);
}
开发者ID:VasekPurchart,项目名称:khanovaskola-v3,代码行数:49,代码来源:BlackboardPreview.php
示例19: graphData
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;
}
}
开发者ID:raynaldmo,项目名称:php-education,代码行数:19,代码来源:PieChart.php
示例20: drawDisc
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++;
}
}
开发者ID:Cibale,项目名称:sofascoreEDU,代码行数:21,代码来源:PieChart.php
注:本文中的imagefilledarc函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论