Commit 8f50ba64 authored by Feu's avatar Feu

wip

parent e2f69076
......@@ -229,7 +229,24 @@ class galaxy
new requete($this->dbrw,"UPDATE galaxy_star SET rx_star = (x_star-".sprintf("%f",$top_x).") * $tx, ry_star = (y_star-".sprintf("%f",$top_y).") * $tx");
}
function render ($target="galaxy_temp.png",$mini_target=null)
function mini_render ( $mini_target="mini_galaxy_temp.png")
{
if ( empty($this->width) || empty($this->height) )
$this->pre_render();
$img = imagecreatetruecolor($this->width/100,$this->height/100);
$bg = imagecolorallocate($img, 0, 0, 0);
imagefill($img, 0, 0, $bg);
$req = new requete($this->db, "SELECT FLOOR(rx_star/100),FLOOR(ry_star/100),AVG(sum_tense_star) FROM galaxy_star GROUP BY FLOOR(rx_star/100),FLOOR(ry_star/100)");
while ( list($x,$y,$d) = $req->get_row() )
imagesetpixel($img,$x,$y,$this->star_color($img,$d));
imagepng($img,$mini_target);
imagedestroy($img);
}
function render ($target="galaxy_temp.png")
{
if ( empty($this->width) || empty($this->height) )
$this->pre_render();
......@@ -292,19 +309,7 @@ class galaxy
imagepng($img);
else
imagepng($img,$target);
if ( !is_null($mini_target) )
{
$img2 = imagecreatetruecolor($this->width/100,$this->height/100);
imagecopyresampled ( $img2, $img, 0, 0, 0, 0, $this->width/100,$this->height/100, $this->width,$this->height );
imagedestroy($img);
imagepng($img2,$mini_target);
imagedestroy($img2);
return;
}
imagedestroy($img);
}
......
......@@ -85,11 +85,20 @@ for($i=0;$i<$cycles;$i++)
echo "done in ".round(microtime(true)-$st,2)." sec<br/>\n";
}
if ( isset($_REQUEST["minirender"]) )
{
echo "MINI-RENDER : ";
$st = microtime(true);
$galaxy->mini_render("../var/mini_galaxy.png");
echo "done in ".(microtime(true)-$st)." sec<br/>\n";
echo "<br/><br/><img src=\"../var/mini_galaxy.png\" />";
}
if ( isset($_REQUEST["render"]) )
{
echo "RENDER : ";
$st = microtime(true);
$galaxy->render("../var/galaxy.png","../var/mini_galaxy.png");
$galaxy->render("../var/galaxy.png");
echo "done in ".(microtime(true)-$st)." sec<br/>\n";
echo "<br/><br/><img src=\"../var/galaxy.png\" />";
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment