1 and $n<13) {
$anz=$n;
} else {
$anz=max(2,$n);
$anz=min(12,$anz);
}
# maximale relative Abweichung des Trennpunktes vom Mittelwert 0.5
if(isset($_GET['abt'])) {
$abt=$_GET['abt'];
} else {
$abt=0.1;
}
$abt=max(0,$abt);
$abt=min(0.49,$abt);
# maximlae Auslenkung relativ zum Trennpunkt
if(isset($_GET['arp'])) {
$arp=$_GET['arp'];
} else {
$arp=0.2;
}
$arp=max(0.01,$arp);
$arp=min(1,$arp);
# zufälliger Vorzeichenwechsel bei Auslenkung?
# 0 nein, sonst ja
if(isset($_GET['ari'])) {
$ari=$_GET['ari'];
} else {
$ari=1;
}
if ($ari != 0) {
$ari=1;
}
# Zufallsgenerator initialisieren
mt_srand ((double)microtime()*1000000);
# Vorzeichen Auslenkung, wenn nicht wechselnd
$vz=(2*mt_rand(0,1)-1);
# Riß zwischen zwei Punkten ausbilden:
# Anfangspunkte
$x[0][1]=100;
$x[0][2]=900;
$y[0][1]=mt_rand(-100,100);
$y[0][2]=mt_rand(-100,100);
# iterieren
for ($j = 0; $j <= $anz; $j++) {
# wieviele Striche gibt es?
$pkt=pow(2,$j);
# Zähler Punkte nächste Iteration
$ct=1;
# aus jeder Strecke zwei machen ...
for ($i = 1; $i <= $pkt; $i++) {
$ii=$i+1;
# Richtung
$xr=$x[$j][$ii] - $x[$j][$i];
$yr=$y[$j][$ii] - $y[$j][$i];
# Trennpunkt festlegen
$t=0.5 + $abt*mt_rand(-1000,1000)/1000;
$xt=$x[$j][$ii]*$t+$x[$j][$i]*(1-$t);
$yt=$y[$j][$ii]*$t+$y[$j][$i]*(1-$t);
# Auslenkung festlegen
#
if ($ari==1) {
$vz=(2*mt_rand(0,1)-1);
}
$a=$vz*$arp*mt_rand(100,1000)/1000;
#neuer Punkt:
$xn=round($xt + $a*$yr);
$yn=round($yt - $a*$xr);
# neue Punkte einsortieren
$jj=$j+1;
$x[$jj][$ct]=$x[$j][$i];
$y[$jj][$ct]=$y[$j][$i];
$ct=$ct+1;
$x[$jj][$ct]=$xn;
$y[$jj][$ct]=$yn;
$ct=$ct+1;
}
# letzten Punkt ergänzen
$x[$jj][$ct]=$x[0][2];
$y[$jj][$ct]=$y[0][2];
$ct=$ct+1;
}
#Farbfaktor
$ff=255/$anz;
# zum Abschätzen der viewBox
$xmin=1000;
$xmax=1;
$ymin=1000;
$ymax=-100;
#Ausgabe erzeugen
$pf='';
for ($j = 0; $j <= $anz; $j++) {
# Farbe ermitteln
$f1=round($j*$ff);
$f2=round(255-$j*$ff);
$fw="rgb($f1,0,$f2)";
# Strichdicke festlegen
$sw=(1+$j)/5;
# Pfad zusammenbasteln
$pfad[$j]=" \n";
# Ausgabe zusammenfügen
$pf.=$pfad[$j];
}
# viewBox
$xd=$xmax-$xmin+40;
$yd=$ymax-$ymin+40;
$xmin=$xmin-20;
$ymin=$ymin-20;
$vb="$xmin $ymin $xd $yd";
# SVG-header senden:
$content="Content-type: image/svg+xml";
header($content);
echo " \n";
?>