Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
postscriptlib
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Registry
Registry
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Peter Billam
postscriptlib
Commits
2c67f5cb
Commit
2c67f5cb
authored
Jun 28, 2018
by
Peter Billam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.3 now works also on a t.fen file
parent
56423634
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
15 deletions
+26
-15
fen2img
bin/fen2img
+15
-6
fen2img.html
html/fen2img.html
+11
-9
No files found.
bin/fen2img
View file @
2c67f5cb
...
...
@@ -5,20 +5,20 @@
-- This script is free software; you can redistribute it and/or --
-- modify it under the same terms as Lua5 itself. --
---------------------------------------------------------------------
local
Version
=
'1.
2
for Lua5'
local
VersionDate
=
'2
7
jun2018'
;
local
Version
=
'1.
3
for Lua5'
local
VersionDate
=
'2
8
jun2018'
;
local
Synopsis
=
[[
fen2img [-w 350] \
'rnb1k1nr/pppp1ppp/8/4p3/3b3q/4PPP1/PPP2K1P/RNBQ1BNR b KQkq - 0 5' \
output.png
# default width is
4
00 pixels
# default width is
5
00 pixels
# output file can be a .jpg or .png or .eps
perldoc fen2img # read the manual :-)
]]
local
FEN
=
require
'chess.fen'
Width
=
4
00
;
Width
=
5
00
;
Flip
=
'false'
local
function
which
(
s
)
...
...
@@ -61,6 +61,13 @@ Dx = round(Width * 0.1)
Fenstr
=
arg
[
iarg
]
if
not
Fenstr
then
die
(
'must specify FEN string'
)
end
-- if Fenstr ends in .fen and exists as a file then it should be read as a file
if
string.match
(
Fenstr
,
'%.fen$'
)
then
local
fenfh
=
assert
(
io.open
(
Fenstr
,
'r'
))
Fenstr
=
string.gsub
(
fenfh
:
read
(
'a'
),
'%s+$'
,
''
)
io.close
(
fenfh
)
end
Output
=
arg
[
iarg
+
1
]
if
not
Output
then
die
(
'must specify output file'
)
end
-- 20180627 must be able to pipe into display, so if no output file
...
...
@@ -406,7 +413,7 @@ fen2img - Creates a .png or .jpg diagram of a chess position in FEN
fen2img -w 500 "$FEN" /tmp/t.png
fen2img -w 500 "$FEN" /tmp/t.eps
fen2img -w 500 "$FEN" - | display - # pipes into display as a .png
fen2img -
w 500 "$FEN" -f
- | display - # flip the display
fen2img -
f -w 500 "$FEN"
- | display - # flip the display
=head1 DESCRIPTION
...
...
@@ -425,10 +432,11 @@ to convert into C<.jpg> or C<.png> format.
The board will be displayed B<F>lipped, ie: from Black's point of view.
=item I<-w
5
00>
=item I<-w
7
00>
This option sets the B<W>idth in pixels of the C<.jpg> or C<.png> image,
or the width in points of C<.eps> files.
The default width is 500.
=item I<-v>
...
...
@@ -463,6 +471,7 @@ which you move into C</usr/share/fonts/truetype/>
=head1 CHANGES
20180628 1.3 now works also on a t.fen file
20180627 1.2 introduce the -f Flip option
20180627 1.1 allows output on stdout, for piping into display
20180411 1.0 first working version
...
...
html/fen2img.html
View file @
2c67f5cb
...
...
@@ -43,17 +43,17 @@ CONTENT="PostScript, chess, FEN, pgn, jpg">
<H3
id=
"SYNOPSIS"
>
SYNOPSIS
</H3>
<pre><code>
fen2img -w
5
00 \
<pre><code>
fen2img -w
8
00 \
'rnb1k1nr/pppp1ppp/8/4p3/3b3q/4PPP1/PPP2K1P/RNBQ1BNR b KQkq - 0 5' \
/tmp/hammerschlag.png
display /tmp/hammerschlag.png
FEN=`pgn2fen '1.f3 e5 2. Kf2 Bc5+ 3.d4 Qh4+ 4. g3 Bxd4+ 5.e3'`
fen2img
-w 500
"$FEN" /tmp/t.jpg
fen2img
-w 500
"$FEN" /tmp/t.png
fen2img
-w 500
"$FEN" /tmp/t.eps
fen2img -w
5
00 "$FEN" - | display - # pipes a .png into display
fen2img -
w 500 "$FEN" -f
- | display - # flip the display
</code></pre>
fen2img "$FEN" /tmp/t.jpg
fen2img "$FEN" /tmp/t.png
fen2img "$FEN" /tmp/t.eps
fen2img -w
8
00 "$FEN" - | display - # pipes a .png into display
fen2img -
f -w 800 "$FEN"
- | display - # flip the display
</code></pre>
<H3
id=
"DESCRIPTION"
>
DESCRIPTION
</H3>
...
...
@@ -74,10 +74,11 @@ to convert into <code>.jpg</code> or <code>.png</code> format.</p>
ie: from Black's point of view.
</p>
</dd>
<dt
id=
"w-
500"
><i>
-w 5
00
</i></dt>
<dd>
<dt
id=
"w-
700"
><i>
-w 7
00
</i></dt>
<dd>
<p>
This option sets the
<b>
W
</b>
idth in pixels of the
<code>
.jpg
</code>
or
<code>
.png
</code>
image, or the width in points of
<code>
.eps
</code>
files.
</p>
files.
The default width is 500
</p>
</dd>
<dt
id=
"v"
><i>
-v
</i></dt>
<dd>
...
...
@@ -105,7 +106,8 @@ It also needs a particular TrueType font:</p>
</p>
<H3
id=
"CHANGES"
>
CHANGES
</H3>
<PRE>
20180627 1.2 introduce the -f Flip option
<PRE>
20180628 1.3 now works also on a t.fen file
20180627 1.2 introduce the -f Flip option
20180627 1.1 allows output on stdout, for piping into display
20180411 1.0 first working version
</PRE>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment