ultimix
graph_core_1_0_0 Class Reference

Public Member Functions

 filledrectangle ($Image, $x1, $y1, $x2, $y2, $color, $thick=1)
 imagelinethick ($Image, $x1, $y1, $x2, $y2, $color, $thick=1)
 get_color_from_hex ($Image, $Color)
 fill_background (&$Img, $BackgroundColor)
 string_width ($FontFile, $Size, $String)
 string_height ($FontFile, $Size, $String)
 string_width_height ($FontFile, $Size, $String)
 compile_labels_from_data ($DataY, $StepsY)
 output (&$Options, &$Img)

Detailed Description

Working with graphs.

Author
Dodonov A.A.

Definition at line 26 of file graph_core.php.

Member Function Documentation

compile_labels_from_data (   $DataY,
  $StepsY 
)

Function compiles labels from data.

Parameters
$DataY- Data for the graph.
$StepsY- Count of labels.
Returns
Labels.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 434 of file graph_core.php.

{
try
{
$Labels = array();
$MaxY = max( $DataY );
$MinY = min( $DataY );
$dY = ( $MaxY - $MinY ) / $StepsY;
for( $i = 0 ; $i <= $StepsY ; $i++ )
{
$Labels [] = sprintf( '%.2f' , $MinY + $i * $dY );
}
return( $Labels );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
fill_background ( $Img,
  $BackgroundColor 
)

Function fills graph background.

Parameters
$Img- Image.
$BackgroundColor- Hexadecimal representation of the color.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 255 of file graph_core.php.

{
try
{
$BackgroundColor = intval( $BackgroundColor );
$BackgroundColor = $this->get_color_from_hex( $Img , $BackgroundColor );
$Res = imagefill( $Img , 0 , 0 , $BackgroundColor );
if( $Res === false )
{
throw( new Exception( 'An error occured while setting graph background' ) );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
filledrectangle (   $Image,
  $x1,
  $y1,
  $x2,
  $y2,
  $color,
  $thick = 1 
)

Function draws rectangle.

Parameters
$Image- Image's object.
$x1- Line's beginning.
$y1- Line's beginning.
$x2- Line's end.
$y2- Line's end.
$color- Line's color.
$thick- Line's thickness.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 70 of file graph_core.php.

{
$t = $thick / 2 - 0.5;
return(
imagefilledrectangle(
$Image , round( min( $x1 , $x2 ) - $t ) , round( min( $y1 , $y2 ) - $t ) ,
round( max( $x1 , $x2 ) + $t ) , round( max( $y1 , $y2 ) + $t ) , $color
)
);
}
get_color_from_hex (   $Image,
  $Color 
)

Function allocates color.

Parameters
$Image- Image's object.
$Color- Color.
Returns
Color.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 221 of file graph_core.php.

{
$Color = intval( $Color );
$ColorObject = imagecolorallocate(
$Image , ( $Color & ( 255 << 16 ) ) >> 16 ,
( $Color & ( 255 << 8 ) ) >> 8 , $Color & 255
);
return( $ColorObject );
}
imagelinethick (   $Image,
  $x1,
  $y1,
  $x2,
  $y2,
  $color,
  $thick = 1 
)

Function draws thick line.

Parameters
$Image- Image's object.
$x1- Line's beginning.
$y1- Line's beginning.
$x2- Line's end.
$y2- Line's end.
$color- Line's color.
$thick- Line's thickness.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 181 of file graph_core.php.

{
if( $thick == 1 )
{
return( imageline( $Image , $x1 , $y1 , $x2 , $y2 , $color ) );
}
elseif( $x1 == $x2 || $y1 == $y2 )
{
return( $this->filledrectangle( $Image , $x1 , $y1 , $x2 , $y2 , $color , $thick ) );
}
return( $this->commonimagelinethick( $Image , $x1 , $y1 , $x2 , $y2 , $color , $thick ) );
}
output ( $Options,
$Img 
)

Function outputs graph.

Parameters
$Options- Draw parameters.
$Img- Image.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 479 of file graph_core.php.

{
try
{
header( 'Content-type: image/png' );
imagepng( $Img );
imagedestroy( $Img );
exit( 0 );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
string_height (   $FontFile,
  $Size,
  $String 
)

Function calculates string height.

Parameters
$FontFile- Font file.
$Size- Size.
$String- String.
Returns
String height.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 350 of file graph_core.php.

{
try
{
$Box = imagettfbbox( $Size , 0 , $FontFile , $String );
return( abs( $Box[ 5 ] - $Box[ 1 ] ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
string_width (   $FontFile,
  $Size,
  $String 
)

Function calculates string width.

Parameters
$FontFile- Font file.
$Size- Size.
$String- String.
Returns
String width.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 306 of file graph_core.php.

{
try
{
$Box = imagettfbbox( $Size , 0 , $FontFile , $String );
return( $Box[ 2 ] - $Box[ 0 ] );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
string_width_height (   $FontFile,
  $Size,
  $String 
)

Function calculates string width and height.

Parameters
$FontFile- Font file.
$Size- Size.
$String- String.
Returns
String width and height.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 394 of file graph_core.php.

{
try
{
$Box = imagettfbbox( $Size , 0 , $FontFile , $String );
return( array( $Box[ 2 ] - $Box[ 0 ] , abs( $Box[ 5 ] - $Box[ 1 ] ) ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

The documentation for this class was generated from the following file: