function pChart::drawLine in Visitors 8
Same name and namespace in other branches
- 7.0 pchart/pChart.inc \pChart::drawLine()
16 calls to pChart::drawLine()
- pChart::drawBasicPieGraph in pchart/
pChart.inc - pChart::drawCubicCurve in pchart/
pChart.inc - pChart::drawFilledRadar in pchart/
pChart.inc - pChart::drawFilledRoundedRectangle in pchart/
pChart.inc - pChart::drawFlatPieGraph in pchart/
pChart.inc
File
- pchart/
pChart.inc, line 2309
Class
Code
function drawLine($X1, $Y1, $X2, $Y2, $R, $G, $B, $GraphFunction = FALSE) {
if ($this->LineDotSize > 1) {
$this
->drawDottedLine($X1, $Y1, $X2, $Y2, $this->LineDotSize, $R, $G, $B, $GraphFunction);
return 0;
}
if ($R < 0) {
$R = 0;
}
if ($R > 255) {
$R = 255;
}
if ($G < 0) {
$G = 0;
}
if ($G > 255) {
$G = 255;
}
if ($B < 0) {
$B = 0;
}
if ($B > 255) {
$B = 255;
}
$Distance = sqrt(($X2 - $X1) * ($X2 - $X1) + ($Y2 - $Y1) * ($Y2 - $Y1));
if ($Distance == 0) {
return -1;
}
$XStep = ($X2 - $X1) / $Distance;
$YStep = ($Y2 - $Y1) / $Distance;
for ($i = 0; $i <= $Distance; $i++) {
$X = $i * $XStep + $X1;
$Y = $i * $YStep + $Y1;
if ($X >= $this->GArea_X1 && $X <= $this->GArea_X2 && $Y >= $this->GArea_Y1 && $Y <= $this->GArea_Y2 || !$GraphFunction) {
if ($this->LineWidth == 1) {
$this
->drawAntialiasPixel($X, $Y, $R, $G, $B);
}
else {
$StartOffset = -($this->LineWidth / 2);
$EndOffset = $this->LineWidth / 2;
for ($j = $StartOffset; $j <= $EndOffset; $j++) {
$this
->drawAntialiasPixel($X + $j, $Y + $j, $R, $G, $B);
}
}
}
}
}