コード例 #1
0
ファイル: Line.php プロジェクト: span20/Kallay
 /**
  * Output the plot
  *
  * @return bool Was the output 'good' (true) or 'bad' (false).
  * @access private
  */
 function _done()
 {
     if (Image_Graph_Plot::_done() === false) {
         return false;
     }
     $this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
     $this->_clip(true);
     $keys = array_keys($this->_dataset);
     foreach ($keys as $key) {
         $dataset =& $this->_dataset[$key];
         $dataset->_reset();
         $data = array();
         while ($point = $dataset->_next()) {
             $data[] = array('X' => $this->_pointX($point), 'Y' => $this->_pointY($point));
         }
         $regression = Image_Graph_Tool::calculateLinearRegression($data);
         $this->_getLineStyle($key);
         $this->_canvas->line(array('x0' => $this->_left, 'y0' => $this->_left * $regression['slope'] + $regression['intersection'], 'x1' => $this->_right, 'y1' => $this->_right * $regression['slope'] + $regression['intersection']));
     }
     $this->_clip(false);
     $this->_canvas->endGroup();
     return true;
 }
コード例 #2
0
ファイル: Odo.php プロジェクト: villos/tree_admin
 /**
  * Draw the arrows
  *
  * @access private
  */
 function _drawArrow()
 {
     $keys = array_keys($this->_dataset);
     foreach ($keys as $key) {
         $dataset =& $this->_dataset[$key];
         $dataset->_reset();
         $this->setLineStyle($this->_arrowLineStyle);
         $this->setFillStyle($this->_arrowFillStyle);
         while ($point = $dataset->_next()) {
             $ID = $point['ID'];
             $this->_getFillStyle($ID);
             $this->_getLineStyle($ID);
             $deg = $this->_value2angle($point['Y']);
             list($xr, $yr) = Image_Graph_Tool::rotate($this->_centerX + $this->_arrowLength * $this->_radius / 100, $this->_centerY, $this->_centerX, $this->_centerY, $deg);
             $this->_canvas->addVertex(array('x' => $xr, 'y' => $yr));
             list($xr, $yr) = Image_Graph_Tool::rotate($this->_centerX, $this->_centerY - $this->_arrowWidth * $this->_radius / 100, $this->_centerX, $this->_centerY, $deg);
             $this->_canvas->addVertex(array('x' => $xr, 'y' => $yr));
             list($xr, $yr) = Image_Graph_Tool::rotate($this->_centerX - $this->_arrowWidth * $this->_radius / 100, $this->_centerY, $this->_centerX, $this->_centerY, $deg);
             $this->_canvas->addVertex(array('x' => $xr, 'y' => $yr));
             list($xr, $yr) = Image_Graph_Tool::rotate($this->_centerX, $this->_centerY + $this->_arrowWidth * $this->_radius / 100, $this->_centerX, $this->_centerY, $deg);
             $this->_canvas->addVertex(array('x' => $xr, 'y' => $yr));
             $this->_canvas->polygon(array('connect' => true));
         }
     }
 }
コード例 #3
0
ファイル: Tool.php プロジェクト: ronaldoof/geocloud2
 /**
  * Calculate the dimensions and center point (of gravity) for an arc
  * 
  * @param int $v1 The angle at which the arc starts
  * @param int $v2 The angle at which the arc ends
  * @return array An array with the dimensions in a fraction of a circle width radius 1 'rx', 'ry' and the
  * center point of gravity ('cx', 'cy')
  * @static
  */
 function calculateArcDimensionAndCenter($v1, $v2)
 {
     // $v2 always larger than $v1
     $r1x = Image_Graph_Tool::close2zero(cos(deg2rad($v1)), 3);
     $r2x = Image_Graph_Tool::close2zero(cos(deg2rad($v2)), 3);
     $r1y = Image_Graph_Tool::close2zero(sin(deg2rad($v1)), 3);
     $r2y = Image_Graph_Tool::close2zero(sin(deg2rad($v2)), 3);
     // $rx = how many percent of the x-diameter of the entire ellipse does the arc x-diameter occupy: 1 entire width, 0 no width
     // $cx = at what percentage of the diameter does the center lie
     // if the arc passes through 0/360 degrees the "highest" of r1x and r2x is replaced by 1!
     if ($v1 <= 0 && $v2 >= 0 || $v1 <= 360 && $v2 >= 360) {
         $r1x = min($r1x, $r2x);
         $r2x = 1;
     }
     // if the arc passes through 180 degrees the "lowest" of r1x and r2x is replaced by -1!
     if ($v1 <= 180 && $v2 >= 180 || $v1 <= 540 && $v2 >= 540) {
         $r1x = max($r1x, $r2x);
         $r2x = -1;
     }
     if ($r1x >= 0) {
         // start between [270; 360] or [0; 90]
         if ($r2x >= 0) {
             $rx = max($r1x, $r2x) / 2;
             $cx = 0;
             // center lies 0 percent along this "vector"
         } else {
             $rx = abs($r1x - $r2x) / 2;
             $cx = abs($r2x / 2) / $rx;
         }
     } else {
         // start between ]90; 270[
         if ($r2x < 0) {
             $rx = max(abs($r1x), abs($r2x)) / 2;
             $cx = $rx;
         } else {
             $rx = abs($r1x - $r2x) / 2;
             $cx = abs($r1x / 2) / $rx;
         }
     }
     // $ry = how many percent of the y-diameter of the entire ellipse does the arc y-diameter occupy: 1 entire, 0 none
     // $cy = at what percentage of the y-diameter does the center lie
     // if the arc passes through 90 degrees the "lowest" of r1x and r2x is replaced by -1!
     if ($v1 <= 90 && $v2 >= 90 || $v1 <= 450 && $v2 >= 450) {
         $r1y = min($r1y, $r2y);
         $r2y = 1;
     }
     // if the arc passes through 270 degrees the "highest" of r1y and r2y is replaced by -1!
     if ($v1 <= 270 && $v2 >= 270 || $v1 <= 630 && $v2 >= 630) {
         $r1y = max($r1y, $r2y);
         $r2y = -1;
     }
     if ($r1y >= 0) {
         // start between [0; 180]
         if ($r2y >= 0) {
             $ry = max($r1y, $r2y) / 2;
             $cy = 0;
             // center lies 0 percent along this "vector"
         } else {
             $ry = abs($r1y - $r2y) / 2;
             $cy = abs($r2y / 2) / $ry;
         }
     } else {
         // start between ]180; 360[
         if ($r2y < 0) {
             $ry = max(abs($r1y), abs($r2y)) / 2;
             $cy = $ry;
         } else {
             $ry = abs($r1y - $r2y) / 2;
             $cy = abs($r1y / 2) / $ry;
         }
     }
     return array('rx' => $rx, 'cx' => $cx, 'ry' => $ry, 'cy' => $cy);
 }
コード例 #4
0
ファイル: Bezier.php プロジェクト: jamesiarmes/php-ups-api
 /**
  * Calculates all Bezier points, for the curve
  *
  * @param array $p1 The actual point to calculate control points for
  * @param array $p0 The point "just before" $p1
  * @param array $p2 The point "just after" $p1
  * @param array $p3 The point "just after" $p2
  * @return array Array of Bezier points
  * @access private
  */
 function _getControlPoints($p1, $p0, $p2, $p3)
 {
     $p1 = $this->_pointXY($p1);
     if ($p2) {
         $p2 = $this->_pointXY($p2);
     }
     if (!$p0) {
         $p0['X'] = $p1['X'] - abs($p2['X'] - $p1['X']);
         $p0['Y'] = $p1['Y'];
         //-($p2['Y']-$p1['Y']);
     } else {
         $p0 = $this->_pointXY($p0);
     }
     if (!$p3) {
         $p3['X'] = $p1['X'] + 2 * abs($p1['X'] - $p0['X']);
         $p3['Y'] = $p1['Y'];
     } else {
         $p3 = $this->_pointXY($p3);
     }
     if (!$p2) {
         $p2['X'] = $p1['X'] + abs($p1['X'] - $p0['X']);
         $p2['Y'] = $p1['Y'];
     }
     $pC1['X'] = Image_Graph_Tool::controlPoint($p0['X'], $p1['X'], $p2['X']);
     $pC1['Y'] = Image_Graph_Tool::controlPoint($p0['Y'], $p1['Y'], $p2['Y']);
     $pC2['X'] = Image_Graph_Tool::controlPoint($p3['X'], $p2['X'], $p1['X']);
     $pC2['Y'] = Image_Graph_Tool::controlPoint($p3['Y'], $p2['Y'], $p1['Y']);
     return array('X' => $p1['X'], 'Y' => $p1['Y'], 'P1X' => $pC1['X'], 'P1Y' => $pC1['Y'], 'P2X' => $pC2['X'], 'P2Y' => $pC2['Y']);
 }