Any tool to convert FEN strings to diagrams?

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
yurikvelo
Posts: 710
Joined: Sat Dec 06, 2014 1:53 pm

Re: Any tool to convert FEN strings to diagrams?

Post by yurikvelo »

www.jinchess.com/chessboard/?p=--r-q--- ... =adventure[/b]

bp and ps parameters in URL allow to change skins


Sorry, missed side to move code:

Code: Select all

<?php 
$fens = file&#40;'fen.txt'); 
$url="http&#58;//www.jinchess.com/chessboard/?p=%s&tm=%s&download&bp=red-marble&ps=adventure"; 


foreach ($fens as $fen&#41;&#123; 
	$fen=str_replace&#40;'/', '', $fen&#41;;
	$fen=str_replace&#40;'1', '-', $fen&#41;; 
	$fen=str_replace&#40;'2', '--', $fen&#41;; 
	$fen=str_replace&#40;'3', '---', $fen&#41;; 
	$fen=str_replace&#40;'4', '----', $fen&#41;; 
	$fen=str_replace&#40;'5', '-----', $fen&#41;; 
	$fen=str_replace&#40;'6', '------', $fen&#41;; 
	$fen=str_replace&#40;'7', '-------', $fen&#41;; 
	$fen=str_replace&#40;'8', '--------', $fen&#41;; 
	$a = explode&#40;' ', $fen&#41;; 

	$result = file_get_contents&#40;sprintf&#40;$url, $a&#91;0&#93;, $a&#91;1&#93;), false, $context&#41;; 

	file_put_contents&#40;$a&#91;0&#93;.$a&#91;1&#93;.'.png', $result&#41;; 
&#125;
?>
jinchess allow to encode in URL many more options:
- size, titles, comments, coordinates, arrows

example:

Image