*/ set_time_limit(0); header('Content-Type: image/png'); $im = imagecreate(500, 400); imagecolorallocate($im, 255, 255, 255); $color = imagecolorallocate($im, 0, 0, 0); define('N', 16); // 再帰呼び出し次数の上限 define('BASE', 200); // 少しずらした場所に描画 $x0 = 320; $y0 = 320; $k = 240; // パラメーター(ここを-1~1程度に変化させると模様が変わる) $a1 = 0.6; $b1 = -0.2; $c1 = 0.2; $d1 = 0.6; $a2 = 0.6; $b2 = 0.2; $c2 = 0.2; $d2 = -0.6; chaos(1.0, 0, 1); imagepng($im); exit; function chaos($x, $y, $n) { global $im, $color, $k, $a1, $b1, $c1, $d1, $a2, $b2, $c2, $d2; if ($n <= N) { $xx1 = $a1 * $x + $b1 * $y; $yy1 = $c1 * $x + $d1 * $y; imagesetpixel($im, $k*$xx1+BASE, -1*$k*$yy1+BASE, $color); chaos($xx1, $yy1, $n+1); $xx2 = $a2 * $x + $b2 * $y + 1 - $a2; $yy2 = $c2 * $x + $d2 * $y - $c2; imagesetpixel($im, $k*$xx2+BASE, -1*$k*$yy2+BASE, $color); chaos($xx2, $yy2, $n+1); } } ?>