Flood filling based on a pattern
Just as you can register custom brushes, custom flood fill patterns can be used by specifying a pattern image to use via the imagesettile() function and specifying the IMG_COLOR_TILED as the value of the fill color.

Using a custom fill pattern
<?php
    define
("WIDTH"450);
    
define("HEIGHT"450);
    
define("T_WIDTH"20);
    
define("T_HEIGHT",20);

    
$img imagecreate(WIDTHHEIGHT);
    
$background $white imagecolorallocate($img0xFF0xFF0xFF);
    
$black imagecolorallocate($img000);
    
    
$tile imagecreate(T_WIDTHT_HEIGHT);
    
$t_bkgr $t_white imagecolorallocate($tile0xFF0xFF0xFF);
    
$t_black imagecolorallocate($tile0,0,0);
    
    
imagefilledrectangle($tile00T_WIDTH/2T_HEIGHT/2$t_black);
    
imagefilledrectangle($tileT_WIDTH/2T_HEIGHT/2,
                                
T_WIDTH-1T_HEIGHT-1$t_black);
    
    
imagerectangle($img00WIDTH-1HEIGHT-1$black);
    
imagesettile($img$tile);
    
imagefilledrectangle($img11WIDTH-2HEIGHT-2IMG_COLOR_TILED);
    
    
header("Content-Type: image/png");
    
imagepng($img);   
?>