function draw_triangle ($points, $color
{
if (count$points)!=6) {
throw new Exception'The points must be an array of 6 integers.');
}
$image = image_create_alphamax$points[0], $points[2], $points[4])+1, max$points[1], $points[3], $points[5])+1);
$red = hexdecsubstr$color, 0, 2));
$green = hexdecsubstr$color, 2, 2));
$blue = hexdecsubstr$color, 4, 2));
$color = imagecolorallocatealpha$image, $red, $green, $blue, 0);
imagefilledpolygon$image, $points, 3, $color);
return $image
}