Applying Color Fills
You can fill an area with color using PHP just as you can with your favorite graphics application. The function imagefill() requires an image resource, starting coordinates for the fill it is to perform, and a color resource. It then transforms the starting pixel and all adjacent pixels of the same color. Listing 15.3 adds a call to imagefill() to our script, making the image a little more interesting.
Listing 15.3 Using imagefill()
2: header("Content-type: image/png");
3: $image = imagecreate( 200, 200 );
4: $red = imagecolorallocate($image, 255,0,0);
5: $blue = imagecolorallocate($image, 0,0,255 );
6: imageline( $image, 0, 0, 199, 199, $blue );
7: imagefill( $image, 0, 199, $blue );
The only change we have made to our example is the call to imagefill() on line 7. Figure 15.3 shows the output from Listing 15.3.
Figure 15.3. Using imagefill().