Home Tutorial Php Phpgd PHP GD tilled filled colors


Share on Google+Share on Google+
PHP GD tilled filled colors
Posted on: November 13, 2009 at 12:00 AM
This example shows how to make tilled filled colors in php gd.


define("WIDTH", 200);

define("HEIGHT", 200);

define("T_WIDTH", 20);


$img = imagecreate(WIDTH, HEIGHT);

$background = $white = imagecolorallocate($img, 0xFF, 0xFF, 0xFF);

$black = imagecolorallocate($img, 0, 0, 0);

$tile = imagecreate(T_WIDTH, T_HEIGHT);

$t_bkgr = $t_white = imagecolorallocate($tile, 0xFF, 0xFF, 0xFF);

$t_black = imagecolorallocate($tile, 0,0,0);

imagefilledrectangle($tile, 0, 0, T_WIDTH/2, T_HEIGHT/2, $t_black);

imagefilledrectangle($tile, T_WIDTH/2, T_HEIGHT/2, T_WIDTH-1, T_HEIGHT-1, $t_black);

imagerectangle($img, 0, 0, WIDTH-1, HEIGHT-1, $black);

imagesettile($img, $tile);

imagefilledrectangle($img, 1, 1, WIDTH-2, HEIGHT-2, IMG_COLOR_TILED);

header("Content-Type: image/png");



After running the program you will get the following output


Related Tags for PHP GD tilled filled colors:

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 13, 2009

Recommend the tutorial

Advertisements Advertisements