PHP GD brush style coloring


 

PHP GD brush style coloring

This example shows how to display brush style coloring in php gd.

This example shows how to display brush style coloring in php gd.

<?php

define("WIDTH", 200);

define("HEIGHT", 200);

$img = imagecreate(WIDTH, HEIGHT);

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

$red = imagecolorallocate($img, 255, 0, 0);

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

$dashed = array($red, $red, $red, $white, $white, $white);

$sos = array($red, $red,

$white, $white,

$red, $red,

$white, $white,

$red, $red,

$white, $white,

$red, $red, $red, $red,

$white, $white,

$red, $red, $red, $red,

$white, $white,

$red, $red, $red, $red,

$white, $white,

$red, $red,

$white, $white,

$red, $red,

$white, $white,

$red, $red,

$white, $white,$white, $white,$white, $white);

imagesetstyle($img, $sos);

imageline($img, 0, 0, WIDTH-1, HEIGHT-1, IMG_COLOR_STYLED);

imageline($img, 0, HEIGHT-1, WIDTH-1, 0, IMG_COLOR_STYLED);

imagesetstyle($img, $dashed);

0

imagerectangle($img, 30, 30, WIDTH-31, HEIGHT-31, IMG_COLOR_STYLED);

imagerectangle($img, 50, 50, WIDTH-51, HEIGHT-51, $red);

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

1

imagepng($img);

?>

After running the program you will get the following output

Ads