Przepraszam za ntf.
No to w sumie juz chyba nieaktualne moje pytanie, bo siedzialem dlugo i sie muzdzylem, az sam cos napisalem, powiedzcie czy macie jakies uwagi. Moze cos poprawic?
[php:1:58a2084bd0]<?php
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;
$fil = fopen("log.txt",w);
fwrite($fil,"");
fclose($fil);
$ps = Array(5,70); //wsp. punktu startowego
// dlugosc boku
if(!isset($_GET['bok'])) $bok = 400;
else $bok = $_GET['bok'];
// liczba powtorzen
if(!isset($_GET['ile'])) $ile = 1;
else $ile = $_GET['ile'];
// kolor
if(!isset($_GET['kolor'])) $kolor = "green";
else $kolor = $_GET['kolor'];
$obrazek = 100 + $bok;
switch($kolor) {
case "green": $cl = Array(16,167,0); break;
case "red": $cl = Array(177,0,0); break;
case "bronze": $cl = Array(177,117,0); break;
case "blue": $cl = Array(0,79,177); break;
case "violet": $cl = Array(117,100,177); break;
case "black": $cl = Array(0,0,0); break;
}
$img_handle = ImageCreate ($obrazek, $obrazek) or die ("Nie moge utworzyc obrazka");
$kolor_tla = ImageColorAllocate ($img_handle, 255, 255, 255);
$kolor_wypelnienia = ImageColorAllocate ($img_handle, $cl[0],$cl[1],$cl[2]);
$kolor_pustego = ImageColorAllocate ($img_handle,255,255,255);
ImageString ($img_handle, 12, 5, 2, "Dywan Sierpinskiego", $kolor_wypelnienia); //napis 1
ImageString ($img_handle, 12, 5, 20, "Poziom: $ile", $kolor_wypelnienia); //napis cykle
ImageString ($img_handle, 12, 5, 35, "Dlugosc boku: $bok pikseli", $kolor_wypelnienia); //napis dlugosc boku
ImageFilledRectangle ($img_handle,$ps[0],$ps[1],$ps[0]+$bok,$ps[1]+$bok,$kolor_wypelnienia); //pierwszy kwadrat, wypelniony ciemnym kolorem
for($i = 0; $i < $ile; $i++) {
$rzedy = pow(3,$i);
for($r = 1; $r <= $rzedy; $r++) {
$kolumny = pow(3,$i);
for($k = 1; $k <= $kolumny; $k++) {
$dz = pow(3,$i+1);
$x1 = $ps[0]+($bok/$dz) + ($bok/$kolumny)*($k - 1);
$y1 = $ps[1]+($bok/$dz) + ($bok/$kolumny)*($r - 1);
$x2 = $ps[0]+(2*($bok/$dz)) + ($bok/$kolumny)*($k - 1);
$y2 = $ps[1]+(2*($bok/$dz)) + ($bok/$kolumny)*($r - 1);
$fil = fopen("log.txt",a);
$tex = "rn$i,$r,$k: ($x1,$y1)($x2,$y2)";
fwrite($fil,$tex);
fclose($fil);
ImageFilledRectangle ($img_handle,$x1,$y1,$x2,$y2,$kolor_pustego); //pusty kwadrat
}
}
}
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totaltime = ($endtime - $starttime);
$totaltime .= " sekund";
ImageString ($img_handle, 12, 5, 50, "Czas generowania obrazka: $totaltime", $kolor_wypelnienia); //napis czas
header ("Content-type: image/jpeg");
ImageJPEG ($img_handle,'',100);
?>
[/php:1:58a2084bd0]