<?php
 
/* PIMG module: fill's the image with a chosen color */
 
class pimg_fill
 
{
 
    /* Resources */
 
    private $pimg;
 
    
 
    // PIMG constructor
 
    function __construct($pimg)
 
    {
 
        $this -> pimg = $pimg;
 
    }
 
    
 
    
 
    
 
    /*
 
        Fills the image with the specified color
 
        @param: $color - a pimg_color instance
 
        @result: pimg_image instance
 
    */
 
    function init($color)
 
    {
 
        /* INPUT VALIDATORS */
 
        if (!$color instanceOf pimg_color)
 
            $this -> pimg -> setDebug('The passed fill color is not a valid pimg_color', 'error', __CLASS__);
 
        
 
        // Fill the image
 
        imagefill($this -> pimg -> handle(), 0, 0, $color -> allocate());
 
        
 
        // Return pimg_image instance
 
        return $this -> pimg;
 
    }
 
}
 
?>
 
 |