<? if ($i != 4) { ?>
The image created by this script is available
<a href="examples.php?i=4">here</a>.
<hr size="1" width="70%" align="left" noshade>
<? } ?>

<pre>
&lt;?php

/*
 * This example draws a variety of shapes on an otherwise black image.
 * Demonstrates draw/filled rectangles, polygins, cliprects, ellipses, etc.
 */

require './class.ImlibImage.php';
require './class.ImlibColor.php';
require './class.ImlibText.php';
require './class.ImlibCliprect.php';
require './class.ImlibDraw.php';
require './class.ImlibPoly.php';

$im = new ImlibImage();
$im-&gt;create(225,260);

$outlinecolor = Array(255,0,0,255);
$color = Array(255,127,0,255);

$box = new ImlibDraw();
$box-&gt;set_image($im-&gt;get_id());
$box-&gt;set_color_array($outlinecolor);
$box-&gt;draw_rectangle(7,7,106,56);
$box-&gt;set_color_array($color);
$box-&gt;fill_rectangle(10,10,100,50);

$poly = new ImlibPoly();
$poly-&gt;new_poly();
$poly-&gt;set_image($im-&gt;get_id());
$poly-&gt;set_color(255,0,255,255);
$poly-&gt;add_point(100,100);
$poly-&gt;add_point(215,110);
$poly-&gt;add_point(150,215);
$poly-&gt;add_point(102,255);

// The cliprect will leave a gap in the middle of this polygon
$poly-&gt;set_cliprect(100,50,125,110);	// Draw the top
$poly-&gt;draw();
$poly-&gt;set_cliprect(100,190,125,70);	// Draw the bottom
$poly-&gt;draw();
$poly-&gt;free();

$poly-&gt;set_cliprect(0,0,0,0);	// Turns off the clipping rectangle
$poly-&gt;new_poly();
$poly-&gt;set_color(255,255,255,255);
$poly-&gt;add_point(106,106);
$poly-&gt;add_point(205,115);
$poly-&gt;add_point(147,211);
$poly-&gt;add_point(106,245);

$poly-&gt;draw();
$poly-&gt;free();

// This will draw a few pseudo-randomly colored ellipses
$j = 30;
for ($i = 90; $i &lt; 260; $i += 20)
{
   $box-&gt;set_color($i,$i*2,255-$i*2,255);
   $box-&gt;draw_ellipse($j,$i,10,$j/2);
   $j += 20;
   if ($j &gt; 70)
      $j = 25;
}

$im-&gt;save('./draw.png');
$im-&gt;free();

?&gt;
</pre>
