my friend
Member
الان داشتم تو کدهام میگشتم ، اینو پیدا کردم
کلی خاطره برام زنده کرد
دیدم الگوریتم جالبی داره ، گفتم بزارم اینجا تا شما هم باهاش حال کنید
شما هم اگه از اینجور چیزا دارید دریغ نکنید
کلی خاطره برام زنده کرد
دیدم الگوریتم جالبی داره ، گفتم بزارم اینجا تا شما هم باهاش حال کنید
PHP:
<?php
//canvas size
$width = 1600;
$height = 1200;
//create and paint the canvas, generate colors to draw the fern
$canvas = imagecreatetruecolor($width,$height);
$white = imagecolorallocate($canvas,255,255,255);
imagefill($canvas,0,0,$white);
for ($n=1;$n<255;$n++) {
$green[$n] = imagecolorallocatealpha($canvas,0,$n,0,105);
}
//basic fern settings
$max = 80000;
$p1 = 79;
$p2 = 89;
$p3 = 98;
$x = 0;
$y = 0;
for ($n=0;$n<$max;$n++) {
$p = rand(0,100);
$xt = $x;
if ($p < $p1) {
$x = (0.85*$x)+(0.04*$y)+0.075;
$y = (-0.04*$xt)+(0.85*$y)+0.18;
} elseif($p < $p2) {
$x = (0.20*$x)-(0.26*$y)+0.4;
$y = (0.23*$xt)+(0.22*$y)+0.045;
} elseif($p < $p3) {
$x = (-0.15*$x)+(0.28*$y)+0.575;
$y = (0.26*$xt)+(0.24*$y)-0.086;
} else {
$x = 0.5;
$y = 0.16*$y;
}
//paint the pixels onto the canvas
$diameter = rand(1,15);
imagefilledellipse($canvas, $width-($width*$x), $height-($height*$y), $diameter, $diameter, $green[(100*$y)+(155*$x)]);
}
//Antialias the image sort of .. scale down the big version.
$i = imagecreatetruecolor($width/2, $height/2);
imagecopyresampled($i, $canvas, 0, 0, 0, 0, ($width/2), ($height/2), $width, $height);
header("Content-type: image/png");
imagepng($i);
?>