- class smolGraph
- {
- public $screenWidth=1000;
- public $screenHeight=1000;
- //what is the incoming data going to look like
- public $minValueX;
- public $maxValueX;
- public $minValueY;
- public $maxValueY;
- //Where does it live physicall on the screen
- public $startX;
- public $widthX;
- public $startY;
- public $heightY;
- //cartesian center relative to the X Y of physical screen
- public $cartCenterX;
- public $cartCenterY;
- }
- $AGraph=new smolGraph();
- $AGraph->minValueX=-25;
- $AGraph->maxValueX=25;
- $AGraph->minValueY=-25;
- $AGraph->maxValueY=25;
- $AGraph->startX=100;
- $AGraph->startY=100;
- $AGraph->widthX=100;
- $AGraph->heightY=100;
- $AGraph->cartCenterX=50;
- $AGraph->cartCenterY=50;
- graphBounds($AGraph,2,"#0000ff");
- graphLine($AGraph,0,0,25,25,1,"#000000");
- graphLine($AGraph,-25,25,12,12,1,"#00ff00");
- //graphLine($AGraph,0,0,25,0,1,"#000000");
- //graphLine($AGraph,-25,-25,25,25,1,"#ff0000");
- function graphBounds($GSET,$width,$color)
- {
- global $SVGDOCUMENT;
- $x1=$GSET->startX;
- $x2=$GSET->startX+$GSET->widthX;
- $y1=$GSET->startY;
- $y2=$GSET->startY+$GSET->heightY;
- $SVGDOCUMENT.="<line x1=\"$x1\" y1=\"$y1\" x2=\"$x2\" y2=\"$y1\" style=\"stroke:$color;stroke-width:$width;\" />\n"; //top
- $SVGDOCUMENT.="<line x1=\"$x2\" y1=\"$y1\" x2=\"$x2\" y2=\"$y2\" style=\"stroke:$color;stroke-width:$width;\" />\n"; //right
- $SVGDOCUMENT.="<line x1=\"$x1\" y1=\"$y2\" x2=\"$x2\" y2=\"$y2\" style=\"stroke:$color;stroke-width:$width;\" />\n"; //bottom
- $SVGDOCUMENT.="<line x1=\"$x1\" y1=\"$y1\" x2=\"$x1\" y2=\"$y2\" style=\"stroke:$color;stroke-width:$width;\" />\n"; //left
- }
- function graphLine($GSET,$x,$y,$h,$v,$width,$color)
- {
- global $SVGDOCUMENT;
- $x1=map($x,$GSET->minValueX,$GSET->maxValueX,$GSET->startX,$GSET->startX+$GSET->widthX)-($GSET->cartCenterX);
- $x2=map($h,$GSET->minValueX,$GSET->maxValueX,$GSET->startX,$GSET->startX+$GSET->widthX)-($GSET->cartCenterX);
- // $y1=map($y,$GSET->minValueY,$GSET->maxValueY,$GSET->startY,$GSET->startY+$GSET->heightY)+$GSET->cartCenterY;
- // $y2=map($v,$GSET->minValueY,$GSET->maxValueY,$GSET->startY,$GSET->startY+$GSET->heightY)+$GSET->cartCenterY;
- $y1=map($y,$GSET->minValueY,$GSET->maxValueY,$GSET->startY+$GSET->heightY,$GSET->startY)+$GSET->cartCenterY;
- $y2=map($v,$GSET->minValueY,$GSET->maxValueY,$GSET->startY+$GSET->heightY,$GSET->startY)+$GSET->cartCenterY;
- $SVGDOCUMENT.="<line x1=\"$x1\" y1=\"$y1\" x2=\"$x2\" y2=\"$y2\" style=\"stroke:$color;stroke-width:$width;\" />\n";
- }
SmolGraph
Posted by Anonymous on Tue 19th Dec 2017 23:11
raw | new post
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.