本文整理汇总了PHP中imagefilledarc函数的典型用法代码示例。如果您正苦于以下问题:PHP imagefilledarc函数的具体用法?PHP imagefilledarc怎么用?PHP imagefilledarc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imagefilledarc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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);
}
}
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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));
}
示例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;
}
示例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);
}
示例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;
}
}