Yet another example from Mehdi Achour

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@227606 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Hannes Magnusson 2007-01-19 20:03:00 +00:00
parent f57a15e728
commit 8e5438d8b9
2 changed files with 44 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.8 $ -->
<!-- $Revision: 1.9 $ -->
<refentry id="function.imagesetpixel">
<refnamediv>
<refname>imagesetpixel</refname>
@ -58,6 +58,49 @@
&return.success;
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>imagesetpixel</function> example</title>
<para>
A random drawing that ends with a regular picture.
</para>
<programlisting role="php">
<![CDATA[
<?php
$x = 200;
$y = 200;
$gd = imagecreatetruecolor($x, $y);
$corners[0] = array('x' => 100, 'y' => 10);
$corners[1] = array('x' => 0, 'y' => 190);
$corners[2] = array('x' => 200, 'y' => 190);
$red = imagecolorallocate($gd, 255, 0, 0);
for ($i = 0; $i < 100000; $i++) {
imagesetpixel($gd, round($x),round($y), $red);
$a = rand(0, 2);
$x = ($x + $corners[$a]['x']) / 2;
$y = ($y + $corners[$a]['y']) / 2;
}
header('Content-Type: image/png');
imagepng($gd);
?>
]]>
</programlisting>
&example.outputs.similar;
<screenshot>
<graphic fileref="figures/image.imagesetpixel.png" />
</screenshot>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>