Exemple #1
0
$dx = (GRAPH_WIDTH - 40) / ($iPoints - 1);
$x = 20;
for ($i = 0; $i < $iPoints; $i++) {
    $y = rand(20, GRAPH_HEIGHT - 20);
    $aCoords[$x] = $y;
    $x += $dx;
}
$vImagegHeight = GRAPH_HEIGHT + 30;
$vImage = imagecreatetruecolor(GRAPH_WIDTH + 50, $vImagegHeight);
$vBgColor = imagecolorallocate($vImage, 160, 160, 160);
$vTextColor = imagecolorallocate($vImage, 0, 0, 0);
$vAxisColor = imagecolorallocate($vImage, 0, 0, 0);
$vDotColor = imagecolorallocate($vImage, 192, 64, 64);
imagefill($vImage, 0, 0, $vBgColor);
$oPlot = new Plot($aCoords);
$oPlot->drawDots($vImage, $vDotColor, 10, GRAPH_HEIGHT, 8);
$oCurve = new CubicSplines();
$vColor = imagecolorallocate($vImage, 225, 64, 64);
$iStart = microtime(1);
if ($oCurve) {
    $oCurve->setInitCoords($aCoords, 1);
    $r = $oCurve->processCoords();
    if ($r) {
        $curveGraph = new Plot($r);
    } else {
        continue;
    }
} else {
    $curveGraph = $oPlot;
}
$curveGraph->drawLine($vImage, $vColor, 10, GRAPH_HEIGHT);