added example (incorporated from user notes)

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@138012 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Heilig (Cece) Szabolcs 2003-08-16 19:29:17 +00:00
parent 08b33851e1
commit 4e586d5658

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.2 $ -->
<!-- $Revision: 1.3 $ -->
<refentry id="function.imagecolorallocatealpha">
<refnamediv>
<refname>imagecolorallocatealpha</refname>
@ -26,6 +26,49 @@
<para>
Returns &false; if the allocation failed.
</para>
<para>
<example>
<title>Example of using <function>imagecolorallocatealpha</function></title>
<programlisting role="php">
<![CDATA[
<?php
$size = 300;
$Image=imagecreatetruecolor($size, $size);
// something to get a white background
$back = imagecolorallocate( $Image, 255, 255, 255 );
$border = imagecolorallocate( $Image, 0, 0, 0);
imagefilledrectangle ( $Image, 0, 0, $size-1, $size-1, $back);
imagerectangle ( $Image, 0, 0, $size-1, $size-1, $border);
$yellowX = 100;
$yellowY = 75;
$redX = 120;
$redY = 165;
$blueX = 187;
$blueY = 125;
$radius = 150;
// allocate colors with alpha values
$yellow = imagecolorallocateAlpha ( $Image, 255, 255, 0,75);
$red = ImageColorAllocateAlpha( $Image, 255, 0, 0, 75 );
$blue = ImageColorAllocateAlpha ( $Image, 0, 0, 255,75 );
// drawing 3 overlapped circle
ImageFilledEllipse($Image, $yellowX, $yellowY,$radius,$radius,$yellow);
ImageFilledEllipse($Image, $redX, $redY,$radius,$radius,$red);
ImageFilledEllipse($Image, $blueX, $blueY,$radius,$radius,$blue);
// don't forget to output correct header!
header('Content-Type: image/png');
// output the result
ImagePNG($Image);
ImageDestroy($Image);
?>
]]>
</programlisting>
</example>
<para>
<para>
See also <function>imagecolorallocate</function> and
<function>imagecolordeallocate</function>.