?? jpgraph_gradient.php
字號:
<?php
class gradient
{
var $img = null;
var $numcolors = 100;
function gradient( &$img )
{
$this->img = $img;
}
function setnumcolors( $aNum )
{
$this->numcolors = $aNum;
}
function filledrectangle( $xl, $yt, $xr, $yb, $from_color, $to_color, $style = 1 )
{
switch ( $style )
{
case GRAD_VER :
$steps = round( abs( $xr - $xl ) );
$delta = $xl <= $xr ? 1 : -1;
$this->getcolarray( $from_color, $to_color, $steps, $colors, $this->numcolors );
$i = 0;
$x = $xl;
for ( ; $i < $steps; ++$i )
{
$this->img->current_color = $colors[$i];
$this->img->line( $x, $yt, $x, $yb );
$x += $delta;
break;
}
case GRAD_HOR :
$steps = round( abs( $yb - $yt ) );
$delta = $yt <= $yb ? 1 : -1;
$this->getcolarray( $from_color, $to_color, $steps, $colors, $this->numcolors );
$i = 0;
$y = $yt;
for ( ; $i < $steps; ++$i )
{
$this->img->current_color = $colors[$i];
$this->img->line( $xl, $y, $xr, $y );
$y += $delta;
break;
}
case GRAD_MIDHOR :
$steps = round( abs( $yb - $yt ) / 2 );
$delta = $yt <= $yb ? 1 : -1;
$this->getcolarray( $from_color, $to_color, $steps, $colors, $this->numcolors );
$y = $yt;
$i = 0;
for ( ; $i < $steps; ++$i )
{
$this->img->current_color = $colors[$i];
$this->img->line( $xl, $y, $xr, $y );
$y += $delta;
}
--$i;
if ( abs( $yb - $yt ) % 2 == 1 )
{
--$steps;
}
$j = 0;
for ( ; $j < $steps; ++$j, --$i )
{
$this->img->current_color = $colors[$i];
$this->img->line( $xl, $y, $xr, $y );
$y += $delta;
}
$this->img->line( $xl, $y, $xr, $y );
break;
case GRAD_MIDVER :
$steps = round( abs( $xr - $xl ) / 2 );
$delta = $xl <= $xr ? 1 : -1;
$this->getcolarray( $from_color, $to_color, $steps, $colors, $this->numcolors );
$x = $xl;
$i = 0;
for ( ; $i < $steps; ++$i )
{
$this->img->current_color = $colors[$i];
$this->img->line( $x, $yb, $x, $yt );
$x += $delta;
}
--$i;
if ( abs( $xr - $xl ) % 2 == 1 )
{
--$steps;
}
$j = 0;
for ( ; $j < $steps; ++$j, --$i )
{
$this->img->current_color = $colors[$i];
$this->img->line( $x, $yb, $x, $yt );
$x += $delta;
}
$this->img->line( $x, $yb, $x, $yt );
break;
case GRAD_WIDE_MIDVER :
$diff = round( abs( $xr - $xl ) );
$steps = floor( abs( $diff ) / 3 );
$firststep = $diff - 2 * $steps;
$delta = $xl <= $xr ? 1 : -1;
$this->getcolarray( $from_color, $to_color, $firststep, $colors, $this->numcolors );
$x = $xl;
$i = 0;
for ( ; $i < $firststep; ++$i )
{
$this->img->current_color = $colors[$i];
$this->img->line( $x, $yb, $x, $yt );
$x += $delta;
}
--$i;
$this->img->current_color = $colors[$i];
$j = 0;
for ( ; $j < $steps; ++$j )
{
$this->img->line( $x, $yb, $x, $yt );
$x += $delta;
}
$j = 0;
for ( ; $j < $steps; ++$j, --$i )
{
$this->img->current_color = $colors[$i];
$this->img->line( $x, $yb, $x, $yt );
$x += $delta;
break;
}
case GRAD_WIDE_MIDHOR :
$diff = round( abs( $yb - $yt ) );
$steps = floor( abs( $diff ) / 3 );
$firststep = $diff - 2 * $steps;
$delta = $yt <= $yb ? 1 : -1;
$this->getcolarray( $from_color, $to_color, $firststep, $colors, $this->numcolors );
$y = $yt;
$i = 0;
for ( ; $i < $firststep; ++$i )
{
$this->img->current_color = $colors[$i];
$this->img->line( $xl, $y, $xr, $y );
$y += $delta;
}
--$i;
$this->img->current_color = $colors[$i];
$j = 0;
for ( ; $j < $steps; ++$j )
{
$this->img->line( $xl, $y, $xr, $y );
$y += $delta;
}
$j = 0;
for ( ; $j < $steps; ++$j, --$i )
{
$this->img->current_color = $colors[$i];
$this->img->line( $xl, $y, $xr, $y );
$y += $delta;
break;
}
case GRAD_LEFT_REFLECTION :
$steps1 = round( 0.3 * abs( $xr - $xl ) );
$delta = $xl <= $xr ? 1 : -1;
$from_color = $this->img->rgb->color( $from_color );
$adj = 1.4;
[exception occured]
================================
Exception code[ C0000005 ]
Compiler[ 00385B28 ]
Executor[ 00386030 ]
OpArray[ 0096F520 ]
File< D:\MYOA08\php-de\Dezender28\inc\jpgraph\jpgraph_gradient.php >
Class< gradient >
Function< filledrectangle >
Stack[ 00145AC8 ]
Step[ 7 ]
Offset[ 588 ]
LastOffset[ 1142 ]
588 MUL [-] 0[0] $Tmp_1 - $Tmp_2 - $Tmp_3
================================
?>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -