深圳全飞鸿

标题: pchart画直线的分析(drawLine) [打印本页]

作者: zhgc    时间: 2021-8-29 16:17
标题: pchart画直线的分析(drawLine)
本帖最后由 zhgc 于 2022-1-5 21:56 编辑

pchart画直线的分析的
从pDraw.class.php截取
  1.    /* Draw a line between two points */
  2.    function drawLine($X1,$Y1,$X2,$Y2,$Format="")
  3.     {
  4.      $R                = isset($Format["R"]) ? $Format["R"] : 0;
  5.      $G                = isset($Format["G"]) ? $Format["G"] : 0;
  6.      $B                = isset($Format["B"]) ? $Format["B"] : 0;
  7.      $Alpha        = isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
  8.      $Ticks        = isset($Format["Ticks"]) ? $Format["Ticks"] : NULL;
  9.      $Cpt        = isset($Format["Cpt"]) ? $Format["Cpt"] : 1;
  10.      $Mode        = isset($Format["Mode"]) ? $Format["Mode"] : 1;
  11.      $Weight        = isset($Format["Weight"]) ? $Format["Weight"] : NULL;
  12.      $Threshold        = isset($Format["Threshold"]) ? $Format["Threshold"] : NULL;
复制代码

画线,不需要其他功能部件:
  1. <?php
  2. /* Include all the classes */  
  3. include("../../pChart2.1.4/class/pDraw.class.php");  
  4. include("../../pChart2.1.4/class/pImage.class.php");  
  5. include("../../pChart2.1.4/class/pData.class.php");

  6. /* Create your dataset object */  
  7. $myData = new pData();  

  8. /* Create a pChart object and associate your dataset */  
  9. $myPicture = new pImage(1000,500,$myData,true);

  10. $myPicture->drawLine(370,160,650,160,array("R"=>255,"G"=>255,"B"=>255,"Ticks"=>4,"Weight"=>3));

  11. /* Render the picture (choose the best way) */
  12. $myPicture->autoOutput("example.basic.png");
  13. ?>
复制代码



作者: zhgc    时间: 2021-8-29 16:21
example.drawLine.php



  1. <?php   
  2. /* CAT:Drawing */

  3. /* pChart library inclusions */
  4. include("../class/pDraw.class.php");
  5. include("../class/pImage.class.php");

  6. /* Create the pChart object */
  7. $myPicture = new pImage(700,230);

  8. /* Draw the background */
  9. $Settings = array("R"=>170, "G"=>183, "B"=>87, "Dash"=>1, "DashR"=>190, "DashG"=>203, "DashB"=>107);
  10. $myPicture->drawFilledRectangle(0,0,700,230,$Settings);

  11. /* Overlay with a gradient */
  12. $Settings = array("StartR"=>219, "StartG"=>231, "StartB"=>139, "EndR"=>1, "EndG"=>138, "EndB"=>68, "Alpha"=>50);
  13. $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL,$Settings);
  14. $myPicture->drawGradientArea(0,0,700,20,DIRECTION_VERTICAL,array("StartR"=>0,"StartG"=>0,"StartB"=>0,"EndR"=>50,"EndG"=>50,"EndB"=>50,"Alpha"=>80));

  15. /* Draw the picture border */  
  16. $myPicture->drawRectangle(0,0,699,229,array("R"=>0,"G"=>0,"B"=>0));
  17.   
  18. /* Write the picture title */  
  19. $myPicture->setFontProperties(array("FontName"=>"../fonts/Silkscreen.ttf","FontSize"=>6));
  20. $myPicture->drawText(10,13,"drawLine() - Basis",array("R"=>255,"G"=>255,"B"=>255));

  21. /* Turn on shadow computing */  
  22. $myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>20));

  23. /* Draw some lines */  
  24. for($i=1;$i<=100;$i=$i+4)
  25.   $myPicture->drawLine($i+5,215,$i*7+5,30,array("R"=>rand(0,255),"G"=>rand(0,255),"B"=>rand(0,255),"Ticks"=>rand(0,4)));

  26. /* Draw an horizontal dashed line with extra weight */
  27. $myPicture->drawLine(370,160,650,160,array("R"=>0,"G"=>0,"B"=>0,"Ticks"=>4,"Weight"=>3));

  28. /* Another example of extra weight */
  29. $myPicture->drawLine(370,180,650,200,array("R"=>255,"G"=>255,"B"=>255,"Ticks"=>15,"Weight"=>1));

  30. /* Render the picture (choose the best way) */
  31. $myPicture->autoOutput("pictures/example.drawLine.png");
  32. ?>
复制代码





欢迎光临 深圳全飞鸿 (http://www.nagomes.com/disc/) Powered by Discuz! X3.2