<?php

function faire_image($nbdep,$nbavide)
{global $x_pt,$y_pt,$num;
$image=imagecreate(450,250);
$col_fond = ImageColorAllocate($image, 200,200,200);
$col1 = ImageColorAllocate($image,255,255,255);
$col2 = ImageColorAllocate($image,255,0,0);
$col3 = ImageColorAllocate($image,0,255,0);
$col4 = ImageColorAllocate($image,0,0,0);
imagefill($image,0, 0,$col_fond);
imagefilledrectangle ($image,10,10,440,240,$col1);
imageline($image,30,220,430,220,$col4);
imageline($image,30,220,30,20,$col4);
imagedashedline($image,130,220,130,20,$col3);
imagedashedline($image,230,220,230,20,$col3);
imagedashedline($image,330,220,330,20,$col3);
imagestring ($image,2,120,220,"m=1",$col4); 
imagestring ($image,2,220,220,"m=2",$col4);
imagestring ($image,2,320,220,"m=3",$col4);
imagestring ($image,2,10,210,"u=0",$col4);
imagestring ($image,2,10,15,"u=1",$col4);
$param=0;
for ($i=1;$i<400;$i++)
{$param=$i/100;$u0=0.3;
for ($j=1;$j<=$nbavide;$j++)
{$u0=$param*(1-$u0)*$u0;}
for ($j=1;$j<=$nbdep;$j++)
{$u0=$param*(1-$u0)*$u0;
$x_pt=round(30+$i);
$y_pt=round(220-$u0*200);
imagesetpixel($image,$x_pt,$y_pt,$col2); 
}
}
ImagePng($image);
}

function faire_page()
{global $nbdep,$nbavide,$num;
echo "<html><body><FONT face='Verdana, Arial' size=2 color='#000080'><center>\n";
echo "Etude de la suite définie par f(x)=m x (1 - x )";
echo "<BR>Pour m variant de 0 à 4 et avec u0 = 0.3";
echo "<form METHOD='GET' ACTION='bifurcation.php3?action=niv&'>\n";
echo "<table border='1' width='100%'>\n";
echo "<tr><td width='25%'><b>Termes non dessinés</b></td>\n";
echo "<td width='20%'><input type='text' name='nbavide' size='15' value='".$nbavide."'></td>\n";
echo "<td width='25%'><b>Nombre de termes</b></td><td width='20%'>";
echo "<input type='text' name='nbdep' size='15' value='".$nbdep."'></td>\n";
echo "<td width='10%'><INPUT TYPE=SUBMIT VALUE='OK'>\n";
echo "</tr></table></form>\n";
echo "<BR>";
echo "<img src='bifurcation.php3?action=img&nbdep=".$nbdep."&nbavide=".$nbavide."' width='450' height='250'>";
echo "</body></html>";
}
if (isset($_GET["action"]))
	$action = $_GET["action"]; else $action = "niv";
if (isset($_GET["nbdep"]))
	$nbdep = $_GET["nbdep"]; else $nbdep = 100;
if (isset($_GET["nbavide"]))
	$nbavide = $_GET["nbavide"]; else $nbavide = 100;
if ($action=="img") {faire_image($nbdep,$nbavide);} else {faire_page();}

?>