深圳全飞鸿
标题:
pchart画直线的分析(drawLine)
[打印本页]
作者:
zhgc
时间:
2021-8-29 16:17
标题:
pchart画直线的分析(drawLine)
本帖最后由 zhgc 于 2022-1-5 21:56 编辑
pchart画直线的分析的
从pDraw.class.php截取
/* Draw a line between two points */
function drawLine($X1,$Y1,$X2,$Y2,$Format="")
{
$R = isset($Format["R"]) ? $Format["R"] : 0;
$G = isset($Format["G"]) ? $Format["G"] : 0;
$B = isset($Format["B"]) ? $Format["B"] : 0;
$Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
$Ticks = isset($Format["Ticks"]) ? $Format["Ticks"] : NULL;
$Cpt = isset($Format["Cpt"]) ? $Format["Cpt"] : 1;
$Mode = isset($Format["Mode"]) ? $Format["Mode"] : 1;
$Weight = isset($Format["Weight"]) ? $Format["Weight"] : NULL;
$Threshold = isset($Format["Threshold"]) ? $Format["Threshold"] : NULL;
复制代码
画线,不需要其他功能部件:
<?php
/* Include all the classes */
include("../../pChart2.1.4/class/pDraw.class.php");
include("../../pChart2.1.4/class/pImage.class.php");
include("../../pChart2.1.4/class/pData.class.php");
/* Create your dataset object */
$myData = new pData();
/* Create a pChart object and associate your dataset */
$myPicture = new pImage(1000,500,$myData,true);
$myPicture->drawLine(370,160,650,160,array("R"=>255,"G"=>255,"B"=>255,"Ticks"=>4,"Weight"=>3));
/* Render the picture (choose the best way) */
$myPicture->autoOutput("example.basic.png");
?>
复制代码
作者:
zhgc
时间:
2021-8-29 16:21
example.drawLine.php
example.drawLine.png
(87.44 KB, 下载次数: 612)
下载附件
2021-8-29 16:21 上传
<?php
/* CAT:Drawing */
/* pChart library inclusions */
include("../class/pDraw.class.php");
include("../class/pImage.class.php");
/* Create the pChart object */
$myPicture = new pImage(700,230);
/* Draw the background */
$Settings = array("R"=>170, "G"=>183, "B"=>87, "Dash"=>1, "DashR"=>190, "DashG"=>203, "DashB"=>107);
$myPicture->drawFilledRectangle(0,0,700,230,$Settings);
/* Overlay with a gradient */
$Settings = array("StartR"=>219, "StartG"=>231, "StartB"=>139, "EndR"=>1, "EndG"=>138, "EndB"=>68, "Alpha"=>50);
$myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL,$Settings);
$myPicture->drawGradientArea(0,0,700,20,DIRECTION_VERTICAL,array("StartR"=>0,"StartG"=>0,"StartB"=>0,"EndR"=>50,"EndG"=>50,"EndB"=>50,"Alpha"=>80));
/* Draw the picture border */
$myPicture->drawRectangle(0,0,699,229,array("R"=>0,"G"=>0,"B"=>0));
/* Write the picture title */
$myPicture->setFontProperties(array("FontName"=>"../fonts/Silkscreen.ttf","FontSize"=>6));
$myPicture->drawText(10,13,"drawLine() - Basis",array("R"=>255,"G"=>255,"B"=>255));
/* Turn on shadow computing */
$myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>20));
/* Draw some lines */
for($i=1;$i<=100;$i=$i+4)
$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)));
/* Draw an horizontal dashed line with extra weight */
$myPicture->drawLine(370,160,650,160,array("R"=>0,"G"=>0,"B"=>0,"Ticks"=>4,"Weight"=>3));
/* Another example of extra weight */
$myPicture->drawLine(370,180,650,200,array("R"=>255,"G"=>255,"B"=>255,"Ticks"=>15,"Weight"=>1));
/* Render the picture (choose the best way) */
$myPicture->autoOutput("pictures/example.drawLine.png");
?>
复制代码
欢迎光临 深圳全飞鸿 (http://www.nagomes.com/disc/)
Powered by Discuz! X3.2