⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jpgraph_plotband.php

📁 一个基于web的开源项目管理工具
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php//=======================================================================// File:	JPGRAPH_PLOTBAND.PHP// Description:	PHP4 Graph Plotting library. Extension module.// Created: 	2004-02-18// Author:	Johan Persson (johanp@aditus.nu)// Ver:		$Id: jpgraph_plotband.php,v 1.1.10.1 2006/02/28 19:46:57 gregorerhardt Exp $//// Copyright (c) Aditus Consulting. All rights reserved.//========================================================================// Constants for types of static bands in plot areaDEFINE("BAND_RDIAG",1);	// Right diagonal linesDEFINE("BAND_LDIAG",2); // Left diagonal linesDEFINE("BAND_SOLID",3); // Solid one colorDEFINE("BAND_VLINE",4); // Vertical linesDEFINE("BAND_HLINE",5);  // Horizontal linesDEFINE("BAND_3DPLANE",6);  // "3D" PlaneDEFINE("BAND_HVCROSS",7);  // Vertical/Hor crossesDEFINE("BAND_DIAGCROSS",8); // Diagonal crosses// Utility class to hold coordinates for a rectangleclass Rectangle {    var $x,$y,$w,$h;    var $xe, $ye;    function Rectangle($aX,$aY,$aWidth,$aHeight) {	$this->x=$aX;	$this->y=$aY;	$this->w=$aWidth;	$this->h=$aHeight;	$this->xe=$aX+$aWidth-1;	$this->ye=$aY+$aHeight-1;    }}//=====================================================================// Class RectPattern// Base class for pattern hierarchi that is used to display patterned// bands on the graph. Any subclass that doesn't override Stroke()// must at least implement method DoPattern(&$aImg) which is responsible// for drawing the pattern onto the graph.//=====================================================================class RectPattern {    var $color;    var $weight;    var $rect=null;    var $doframe=true;    var $linespacing;	// Line spacing in pixels    var $iBackgroundColor=-1;  // Default is no background fill	    function RectPattern($aColor,$aWeight=1) {	$this->color = $aColor;	$this->weight = $aWeight;		    }    function SetBackground($aBackgroundColor) {	$this->iBackgroundColor=$aBackgroundColor;    }    function SetPos(&$aRect) {	$this->rect = $aRect;    }	    function ShowFrame($aShow=true) {	$this->doframe=$aShow;    }    function SetDensity($aDens) {	if( $aDens < 1 || $aDens > 100 )	    JpGraphError::RaiseL(16001,$aDens);//(" Desity for pattern must be between 1 and 100. (You tried $aDens)");	// 1% corresponds to linespacing=50	// 100 % corresponds to linespacing 1	$this->linespacing = floor(((100-$aDens)/100.0)*50)+1;    }    function Stroke(&$aImg) {	if( $this->rect == null )	    JpGraphError::RaiseL(16002);//(" No positions specified for pattern.");	if( !(is_numeric($this->iBackgroundColor) && $this->iBackgroundColor==-1) ) {	    $aImg->SetColor($this->iBackgroundColor);	    $aImg->FilledRectangle($this->rect->x,$this->rect->y,$this->rect->xe,$this->rect->ye); 	}	$aImg->SetColor($this->color);	$aImg->SetLineWeight($this->weight);	// Virtual function implemented by subclass	$this->DoPattern($aImg);	// Frame around the pattern area	if( $this->doframe ) 	    $aImg->Rectangle($this->rect->x,$this->rect->y,$this->rect->xe,$this->rect->ye);    }}//=====================================================================// Class RectPatternSolid// Implements a solid band//=====================================================================class RectPatternSolid extends RectPattern {    function RectPatternSolid($aColor="black",$aWeight=1) {	parent::RectPattern($aColor,$aWeight);    }    function DoPattern(&$aImg) {	$aImg->SetColor($this->color);	$aImg->FilledRectangle($this->rect->x,$this->rect->y,			       $this->rect->xe,$this->rect->ye);    }}//=====================================================================// Class RectPatternHor// Implements horizontal line pattern//=====================================================================class RectPatternHor extends RectPattern {		    function RectPatternHor($aColor="black",$aWeight=1,$aLineSpacing=7) {	parent::RectPattern($aColor,$aWeight);	$this->linespacing = $aLineSpacing;    }		    function DoPattern(&$aImg) {	$x0 = $this->rect->x;			$x1 = $this->rect->xe;	$y = $this->rect->y;	while( $y < $this->rect->ye ) {	    $aImg->Line($x0,$y,$x1,$y);	    $y += $this->linespacing;	}    }}//=====================================================================// Class RectPatternVert// Implements vertical line pattern//=====================================================================class RectPatternVert extends RectPattern {    var $linespacing=10;	// Line spacing in pixels		    function RectPatternVert($aColor="black",$aWeight=1,$aLineSpacing=7) {	parent::RectPattern($aColor,$aWeight);	$this->linespacing = $aLineSpacing;    }    //--------------------    // Private methods    //    function DoPattern(&$aImg) {	$x = $this->rect->x;			$y0 = $this->rect->y;	$y1 = $this->rect->ye;	while( $x < $this->rect->xe ) {	    $aImg->Line($x,$y0,$x,$y1);	    $x += $this->linespacing;	}    }}//=====================================================================// Class RectPatternRDiag// Implements right diagonal pattern//=====================================================================class RectPatternRDiag extends RectPattern {    var $linespacing;	// Line spacing in pixels		    function RectPatternRDiag($aColor="black",$aWeight=1,$aLineSpacing=12) {	parent::RectPattern($aColor,$aWeight);	$this->linespacing = $aLineSpacing;    }    function DoPattern(&$aImg) {	//  --------------------	//  | /   /   /   /   /|	//  |/   /   /   /   / |	//  |   /   /   /   /  |	//  --------------------	$xe = $this->rect->xe;	$ye = $this->rect->ye;	$x0 = $this->rect->x + round($this->linespacing/2); 	$y0 = $this->rect->y;	$x1 = $this->rect->x; 	$y1 = $this->rect->y + round($this->linespacing/2);	while($x0<=$xe && $y1<=$ye) {	    $aImg->Line($x0,$y0,$x1,$y1);	    $x0 += $this->linespacing;	    $y1 += $this->linespacing;	}	if( $xe-$x1 > $ye-$y0 ) { 	    // Width larger than height	    $x1 = $this->rect->x + ($y1-$ye);	    $y1 = $ye; 	    $y0 = $this->rect->y; 	    while( $x0 <= $xe ) {		$aImg->Line($x0,$y0,$x1,$y1);		$x0 += $this->linespacing;		$x1 += $this->linespacing;	    }	    	    $y0=$this->rect->y + ($x0-$xe);	    $x0=$xe;	}	else {	    // Height larger than width	    $diff = $x0-$xe;	    $y0 = $diff+$this->rect->y;	    $x0 = $xe;	    $x1 = $this->rect->x;	    while( $y1 <= $ye ) {		$aImg->Line($x0,$y0,$x1,$y1);		$y1 += $this->linespacing;		$y0 += $this->linespacing;	    }	    	    $diff = $y1-$ye;	    $y1 = $ye;	    $x1 = $diff + $this->rect->x;	}	while( $y0 <= $ye ) {	    $aImg->Line($x0,$y0,$x1,$y1);	    $y0 += $this->linespacing;			    $x1 += $this->linespacing;	}    }} //=====================================================================// Class RectPatternLDiag// Implements left diagonal pattern//=====================================================================class RectPatternLDiag extends RectPattern {    var $linespacing;	// Line spacing in pixels		    function RectPatternLDiag($aColor="black",$aWeight=1,$aLineSpacing=12) {	$this->linespacing = $aLineSpacing;	parent::RectPattern($aColor,$aWeight);    }    function DoPattern(&$aImg) {	//  --------------------	//  |\   \   \   \   \ |	//  | \   \   \   \   \|	//  |  \   \   \   \   |	//  |------------------|	$xe = $this->rect->xe;	$ye = $this->rect->ye;	$x0 = $this->rect->x + round($this->linespacing/2); 	$y0 = $this->rect->ye;	$x1 = $this->rect->x; 	$y1 = $this->rect->ye - round($this->linespacing/2);	while($x0<=$xe && $y1>=$this->rect->y) {	    $aImg->Line($x0,$y0,$x1,$y1);	    $x0 += $this->linespacing;	    $y1 -= $this->linespacing;	}	if( $xe-$x1 > $ye-$this->rect->y ) { 	    // Width larger than height	    $x1 = $this->rect->x + ($this->rect->y-$y1);	    $y0=$ye; $y1=$this->rect->y; 	    while( $x0 <= $xe ) {		$aImg->Line($x0,$y0,$x1,$y1);		$x0 += $this->linespacing;		$x1 += $this->linespacing;	    }	    	    $y0=$this->rect->ye - ($x0-$xe);	    $x0=$xe;	}	else {	    // Height larger than width	    $diff = $x0-$xe;	    $y0 = $ye-$diff;	    $x0 = $xe;	    while( $y1 >= $this->rect->y ) {		$aImg->Line($x0,$y0,$x1,$y1);		$y0 -= $this->linespacing;		$y1 -= $this->linespacing;	    }	    	    $diff = $this->rect->y - $y1;	    $x1 = $this->rect->x + $diff;	    $y1 = $this->rect->y;	}	while( $y0 >= $this->rect->y ) {	    $aImg->Line($x0,$y0,$x1,$y1);	    $y0 -= $this->linespacing;	    $x1 += $this->linespacing;	}    }}//=====================================================================// Class RectPattern3DPlane// Implements "3D" plane pattern//=====================================================================class RectPattern3DPlane extends RectPattern {    var $alpha=50;  // Parameter that specifies the distance    // to "simulated" horizon in pixel from the    // top of the band. Specifies how fast the lines    // converge.    function RectPattern3DPlane($aColor="black",$aWeight=1) {	parent::RectPattern($aColor,$aWeight);	$this->SetDensity(10);  // Slightly larger default    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -