thx to uzriel who told me twice a day to do so. and since uzriel asked me for the code here is it ... kind of open source now
Code: Select all
<html>
<head>
<style>
b {
font-weight:normal;
}
.lg {
color:#00FF00;
}
.dg {
color:#008000;
}
.ye {
color:#FFFF80;
}
.gr {
color:#C0C0C0;
}
.ma {
color:#FF00FF;
}
.db {
color:#0080FF;
}
.lb {
color:#00FFFF;
}
.br {
color:#808000;
}
.re {
color:#FF0000;
}
.wh {
color:#FFFFFF;
}
.tz {
color:#61C3A2;
}
</style>
</head>
<body bgcolor="#000000">
<pre><code style="font-family:'Courier New', Courier, mono; fontSize:11px; color:#FFFF80" >
<?php
$img = imagecreatefrompng('http://www.icesus.org/images/map/map.png');
$convert = array(0 => 'S', 1 =>'*', 2 => 't', 3 => 'd', 4 => 'E',
5 => 'z', 6 => '?', 7 => 'g', 8 => 'e', 10 => 's', 11 => 'H',
12 => 'C', 13 => '^', 14 => 'D', 15 => 'w', 16 => 'F',
17 => 'r', 18 => '$', 19 => 'V', 20 => '~', 21 => 'h',
22 => 'M', 23 => '.', 24 => 'f', 25 => 'i', 26 => '#',
27 => 'm', 28 => '.', 29 => 'p', 30 => 'R');
$colors = array('S' => 're', '*' => 'gr', 't' => 'tz', 'd' => 'lg', 'E' => 'dg',
'z' => 'ma', '?' => 'ma', 'g' => 'wh', 'e' => 'lg', 's' => 're',
'H' => 'br', 'w' => 'lg', '^' => 'gr', 'D' => 'dg', 'C' => 'gr',
'F' => 'dg', 'r' => 'db', '*' => 'gr', 'V' => 're', '~' => 'db',
'h' => 'br', 'M' => 'ye', '.' => 'gr', 'f' => 'lg', 'i' => 'lb',
'#' => 'ma', 'm' => 'ye', '$' => 'ma', 'p' => 'ye', 'R' => 'db',
'|' => 'gr', '-' => 'gr', '+' => 'gr', '/' => 'gr', '\\' => 'gr');
$top = 300;
$left = 400;
$width = 800;
$height = 600;
for($y = $top;$y < ($top + $height) ;++$y){
for($x = $left; $x < ($left+ $width) ;++$x){
$map_ascii [$y][$x] = $convert[ImageColorAt($img, $x, $y)];
}
}
for($y = $top;$y < ($top + $height) ;++$y){
$lastchar = "";
$lastcolor = "";
$printstring = "";
for($x = $left; $x < ($left+ $width) ;++$x){
$actchar = $map_ascii[$y][$x];
if ($actchar=="*")
{
if ($map_ascii[$y-1][$x-1] == "." ||
$map_ascii[$y-1][$x] == "." ||
$map_ascii[$y-1][$x+1] == "." ||
$map_ascii[$y][$x-1] == "." ||
$map_ascii[$y][$x+1] == "." ||
$map_ascii[$y+1][$x-1] == "." ||
$map_ascii[$y+1][$x] == "." ||
$map_ascii[$y+1][$x+1] == ".")
{
$actchar = "+";
}
else if ($map_ascii[$y][$x-1] == "*" && $map_ascii[$y][$x+1] == "*")
{
$actchar = "-";
}
else if ($map_ascii[$y-1][$x] == "*" && $map_ascii[$y+1][$x] == "*")
{
$actchar = "|";
}
else if ($map_ascii[$y-1][$x-1] == "*" && $map_ascii[$y+1][$x+1] == "*")
{
$actchar = "\\";
}
else if ($map_ascii[$y-1][$x+1] == "*" && $map_ascii[$y+1][$x-1] == "*")
{
$actchar = "/";
}
else
{
$actchar = "+";
}
}
if ($colors[$actchar] == $lastcolor)
{
$printstring .= $actchar;
}
else
{
if ($lastchar <> "")
{
if ($colors[$lastchar] <> 'ye')
print "<b class=\"".$colors[$lastchar]."\">".$printstring."</b>";
else
print $printstring;
}
$lastchar = $actchar;
$lastcolor = $colors[$actchar];
$printstring = $actchar;
}
}
if ($colors[$lastchar] <> 'ye')
print "<b class=\"".$colors[$lastchar]."\">".$printstring."</b>";
else
print $printstring;
print "\n";
}
?>
</code></pre>
</body></html>