function pDraw::drawRoundedFilledRectangle in Visitors 7.2
Same name and namespace in other branches
- 7 pChart/class/pDraw.class.php \pDraw::drawRoundedFilledRectangle()
5 calls to pDraw::drawRoundedFilledRectangle()
- pDraw::drawBarChart in pChart/
class/ pDraw.class.php - pDraw::drawLegend in pChart/
class/ pDraw.class.php - pDraw::drawRoundedFilledRectangle_deprecated in pChart/
class/ pDraw.class.php - pDraw::drawStackedBarChart in pChart/
class/ pDraw.class.php - pDraw::drawText in pChart/
class/ pDraw.class.php
File
- pChart/
class/ pDraw.class.php, line 271
Class
Code
function drawRoundedFilledRectangle($X1, $Y1, $X2, $Y2, $Radius, $Format = "") {
$R = isset($Format["R"]) ? $Format["R"] : 0;
$G = isset($Format["G"]) ? $Format["G"] : 0;
$B = isset($Format["B"]) ? $Format["B"] : 0;
$BorderR = isset($Format["BorderR"]) ? $Format["BorderR"] : -1;
$BorderG = isset($Format["BorderG"]) ? $Format["BorderG"] : -1;
$BorderB = isset($Format["BorderB"]) ? $Format["BorderB"] : -1;
$Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
$Surrounding = isset($Format["Surrounding"]) ? $Format["Surrounding"] : NULL;
/* Temporary fix for AA issue */
$Y1 = floor($Y1);
$Y2 = floor($Y2);
$X1 = floor($X1);
$X2 = floor($X2);
if ($Surrounding != NULL) {
$BorderR = $R + $Surrounding;
$BorderG = $G + $Surrounding;
$BorderB = $B + $Surrounding;
}
if ($BorderR == -1) {
$BorderR = $R;
$BorderG = $G;
$BorderB = $B;
}
list($X1, $Y1, $X2, $Y2) = $this
->fixBoxCoordinates($X1, $Y1, $X2, $Y2);
if ($X2 - $X1 < $Radius * 2) {
$Radius = floor(($X2 - $X1) / 4);
}
if ($Y2 - $Y1 < $Radius * 2) {
$Radius = floor(($Y2 - $Y1) / 4);
}
$RestoreShadow = $this->Shadow;
if ($this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0) {
$this->Shadow = FALSE;
$this
->drawRoundedFilledRectangle($X1 + $this->ShadowX, $Y1 + $this->ShadowY, $X2 + $this->ShadowX, $Y2 + $this->ShadowY, $Radius, array(
"R" => $this->ShadowR,
"G" => $this->ShadowG,
"B" => $this->ShadowB,
"Alpha" => $this->Shadowa,
));
}
$Color = array(
"R" => $R,
"G" => $G,
"B" => $B,
"Alpha" => $Alpha,
"NoBorder" => TRUE,
);
if ($Radius <= 0) {
$this
->drawFilledRectangle($X1, $Y1, $X2, $Y2, $Color);
return 0;
}
$YTop = $Y1 + $Radius;
$YBottom = $Y2 - $Radius;
$Step = 360 / (2 * PI * $Radius);
$Positions = "";
$Radius--;
$MinY = "";
$MaxY = "";
for ($i = 0; $i <= 90; $i = $i + $Step) {
$Xp1 = cos(($i + 180) * PI / 180) * $Radius + $X1 + $Radius;
$Xp2 = cos((90 - $i + 270) * PI / 180) * $Radius + $X2 - $Radius;
$Yp = floor(sin(($i + 180) * PI / 180) * $Radius + $YTop);
if ($MinY == "" || $Yp > $MinY) {
$MinY = $Yp;
}
if ($Xp1 <= floor($X1)) {
$Xp1++;
}
if ($Xp2 >= floor($X2)) {
$Xp2--;
}
$Xp1++;
if (!isset($Positions[$Yp])) {
$Positions[$Yp]["X1"] = $Xp1;
$Positions[$Yp]["X2"] = $Xp2;
}
else {
$Positions[$Yp]["X1"] = ($Positions[$Yp]["X1"] + $Xp1) / 2;
$Positions[$Yp]["X2"] = ($Positions[$Yp]["X2"] + $Xp2) / 2;
}
$Xp1 = cos(($i + 90) * PI / 180) * $Radius + $X1 + $Radius;
$Xp2 = cos((90 - $i) * PI / 180) * $Radius + $X2 - $Radius;
$Yp = floor(sin(($i + 90) * PI / 180) * $Radius + $YBottom);
if ($MaxY == "" || $Yp < $MaxY) {
$MaxY = $Yp;
}
if ($Xp1 <= floor($X1)) {
$Xp1++;
}
if ($Xp2 >= floor($X2)) {
$Xp2--;
}
$Xp1++;
if (!isset($Positions[$Yp])) {
$Positions[$Yp]["X1"] = $Xp1;
$Positions[$Yp]["X2"] = $Xp2;
}
else {
$Positions[$Yp]["X1"] = ($Positions[$Yp]["X1"] + $Xp1) / 2;
$Positions[$Yp]["X2"] = ($Positions[$Yp]["X2"] + $Xp2) / 2;
}
}
$ManualColor = $this
->allocateColor($this->Picture, $R, $G, $B, $Alpha);
foreach ($Positions as $Yp => $Bounds) {
$X1 = $Bounds["X1"];
$X1Dec = $this
->getFirstDecimal($X1);
if ($X1Dec != 0) {
$X1 = floor($X1) + 1;
}
$X2 = $Bounds["X2"];
$X2Dec = $this
->getFirstDecimal($X2);
if ($X2Dec != 0) {
$X2 = floor($X2) - 1;
}
imageline($this->Picture, $X1, $Yp, $X2, $Yp, $ManualColor);
}
$this
->drawFilledRectangle($X1, $MinY + 1, floor($X2), $MaxY - 1, $Color);
$Radius++;
$this
->drawRoundedRectangle($X1, $Y1, $X2 + 1, $Y2 - 1, $Radius, array(
"R" => $BorderR,
"G" => $BorderG,
"B" => $BorderB,
"Alpha" => $Alpha,
));
$this->Shadow = $RestoreShadow;
}