function draw_sierpinski ($size, $color
{
// see http://en.wikipedia.org/wiki/Sierpinski_triangle
// this code from http://php.net/manual/en/function.imagesetpixel.php
$hght = roundsqrt$size$size - ($size/2)*($size/2)));
$diff = round(($size - $hght)/2);
$gd = imagecreatetruecolor$size, $size);
$corners[0] = array'x' => round$size/2), 'y' => $diff);
$corners[1] = array'x' => 0, 'y' => $size$diff);
$corners[2] = array'x' => $size, 'y' => $size$diff);
$red = hexdecsubstr$color, 0, 2));
$green = hexdecsubstr$color, 2, 2));
$blue = hexdecsubstr$color, 4, 2));
$color = imagecolorallocate$gd, $red, $green, $blue);
$x = $size
$y = $size
for ($i = 0; $i < 200000; $i++) {
imagesetpixel$gd, round$x),round$y), $color);
$a = rand(0, 2);
$x = ($x + $corners$a]['x']) / 2;
$y = ($y + $corners$a]['y']) / 2;
}
return $gd
}