Author: Tim Mirabile
Date: 08:29:54 08/15/01
Go up one level in this thread
There has been some controversy about this. I got the piece images from Bob
Hyatt, and I modified them a little. I was under the impression they were
public domain, but someone claimed they are from the Linares font set sold by
Alpine Electronics (http://www.partae.com/). Since we already owned a set of
Linares fonts I assumed it was no problem to use these either way, in the same
way it would be allowable to take a fancy text font and use it to make a title
graphic for a web page. Also, I dont mind sharing the Perl code for creating
the table, but I can't really help with integrating it into an existing program.
The fen sub takes a line of text and looks for an FEN string, and if found it
returns line with an HTML table for the diagram. (It also encodes URL's). The
first part is a little inelegant but I was lazy. :)
$es[1] = "es";
$es[2] = "eses";
$es[3] = "eseses";
$es[4] = "eseseses";
$es[5] = "eseseseses";
$es[6] = "eseseseseses";
$es[7] = "eseseseseseses";
$es[8] = "eseseseseseseses";
$width = "34";
$height = "35";
$c_height = $height * 8;
$c_width = $width * 8;
$pieces = "/diagram/";
$pcext = "gif";
$whitesq = "#FFFFCC"; # R=255 G=255 B=204
$blacksq = "#009966"; # R=000 G=153 B=102
sub fen {
local $line = shift;
local $error = 0;
$line =~ s!([a-zA-Z]+://[^ \t\r\n>\)\]\"']*[a-zA-Z0-9/])!<a
href="$1">$1</a>!g;
if ($line =~
/\[d\]\s?([kqbnrp1-8]{1,8}\/[kqbnrp1-8]{1,8}\/[kqbnrp1-8]{1,8}\/[kqbnrp1-8]{1,8}\/[kqbnrp1-8]{1,8}\/[kqbnrp1-8]{1,8}\/[kqbnrp1-8]{1,8}\/[kqbnrp1-8]{1,8}\s[wb])/i)
{
($position, $color) = split (/ /, $1);
@ranks = split (/\//, $position);
$table = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
$table .= "<tr><td><img src=\"$pieces"."top_l.$pcext\" border=0 alt=\"\"
width=\"$width\" height=\"$height\"></td>";
$table .= "<td colspan=\"8\"><img src=\"$pieces"."top.$pcext\" border=0
alt=\"\" width=\"$c_width\" height=\"$height\"></td>";
$table .= "<td><img src=\"$pieces"."top_r.$pcext\" border=0 alt=\"\"
width=\"$width\" height=\"$height\"></td>";
$table .= "</tr>\n";
$table .= "<tr><td rowspan=\"8\"><img src=\"$pieces"."left.$pcext\"
border=0 alt=\"\" width=\"$width\" height=\"$c_height\"></td>";
for ($i = 0; $i < 8; $i++) {
if ($i > 0) { $table .= "<tr>" }
$rank = $ranks[$i];
$rank =~ s/[kqbnrp]/"b$&"/ge;
$rank =~ s/[KQBNRP]/"w".lc($&)/ge;
$rank =~ s/\d/$es[$&]/g;
if (length($rank) != 16) { $error = 1; last; }
for ($j = 0; $j < 8; $j++) {
$piece = substr($rank, $j*2, 2);
if (($i+$j)/2 == int(($i+$j)/2)) { $sq = $whitesq }
else { $sq = $blacksq }
if ($piece eq "es") {
if ($sq eq $blacksq) { $alt = "::" }
else { $alt = " " }
}
else { $alt = uc($piece)." " }
$table .= "<td bgcolor=\"$sq\"><img src=\"$pieces$piece.$pcext\"
border=0 alt=\"$alt\" width=\"$width\" height=\"$height\"></td>";
}
if ($i == 0) { $table .= "<td rowspan=\"8\"><img
src=\"$pieces$color.$pcext\" border=0 alt=\"\" width=\"$width\"
height=\"$c_height\"></td>" }
$table .= "</tr>\n";
}
$table .= "<td><img src=\"$pieces"."bottom_l.$pcext\" border=0 alt=\"\"
width=\"$width\" height=\"$height\"></td>";
$table .= "<td colspan=\"8\"><img src=\"$pieces"."bottom.$pcext\" border=0
alt=\"\" width=\"$c_width\" height=\"$height\"></td>";
$table .= "<td><img src=\"$pieces"."bottom_r.$pcext\" border=0 alt=\"\"
width=\"$width\" height=\"$height\"></td>";
$table .= "</tr>\n";
$table .= "</table>";
if (!$error) {
$line .= "</pre>\n";
$line .= $table;
$line .= "<pre>";
}
}
return ($line);
}
On August 15, 2001 at 01:02:06, Shane Hudson wrote:
>Hi,
>
>I'm wanting to improve the look of diagrams in games in the HMTL export
>format of my free chess database app Scid, and I like the ones generated
>on this forum when a FEN position is posted, e.g.
>
>[D]rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
>
>Does anyone know who created these bitmaps, or if there is any implicit
>copyright for them? I checked the FAQ and the diagram/ web directory here
>but it only has the GIF images, no descriptive text file.
>
>Cheers,
>Shane
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.