<?php


# mysql
$con = mysql_connect("localhost", "pixelverse", "pixelverse");
mysql_select_db(pixelverse);
$setting = mysql_fetch_array(mysql_query("SELECT * FROM settings"));
$pixels = mysql_query("SELECT * FROM pixels");

# gd
$im = imagecreatetruecolor($setting["width"] ,$setting["height"]);
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
$green = imagecolorallocate($im, 0, 255, 0);
$gray = imagecolorallocate($im, 127, 127, 127);
$light_blue = imagecolorallocate($im, 0, 0, 127);
imagefilltoborder($im, 0, 0, $white, $white);

while($row = mysql_fetch_array($pixels))
{
 $x = $row["x"];
 $y = $row["y"];
 $type = $row["color"];
 $color = $white;
 if ($type == "00ff00")
 {
  $color = $black;
  #echo "yes";
 }
 imagesetpixel($im, $x, $y, $color);
 #echo($x . $y . $type);#work
}

mysql_close($con);

header('Content-type: image/gif');
imagegif($im);
imagedestroy($im);

?>