pub l i c $co lo rs = ar ray ( ) ;
pub l i c func t ion __cons t ruc t ( $wid th , $he ight )
{
$th i s - >wid th = $wid th ;
$th i s - >he ight = $he ight ;
$th i s - >gdo = imagecreate t rueco lo r ( $wid th , $he ight ) ;
$th i s - >addCo lo r ( "wh i te " , 255 , 255 , 255 ) ;
image f i l l ed rec tang le ( $th i s - >gdo , 0 , 0 ,
$wid th , $he ight ,
$th i s - >getCo lo r ( "wh i te " ) ) ;
}
pub l i c func t ion width ( ) { re tu rn $th i s - >width ; }
pub l i c func t ion he ight ( ) { re tu rn $th i s - >he ight ; }
pub l i c func t ion addCo lo r ( $name, $r , $g , $b )
{
$th i s - >co lo rs [ $name ] = imageco lo ra l l ocate (
$th i s - >gdo ,
$r , $g , $b ) ;
}
pub l i c func t ion getGraph icOb jec t ( )
{
re tu rn $th i s - >gdo;
}
pub l i c func t ion getCo lo r ( $name )
{
re tu rn $th i s - >co lo rs [ $name ] ;
}
pub l i c func t ion saveAsPng( $f i l ename )
{
imagepng( $th i s - >gdo , $f i l ename ) ;
}