Games::Go::Sgf2Dg(3pm) | User Contributed Perl Documentation | Games::Go::Sgf2Dg(3pm) |
Games::Go::Sgf2Dg - convert Smart Go Format (SGF) files to diagrams similar to those seen in Go books and magazines.
sgf2dg [ option ... ] file[.sgf|.mgt]
Games::Go::Sgf2Dg takes a Smart Go Format (SGF) file filename or filename.sgf or filename.mgt and produces a diagram file filename.suffix where suffix is determined by the converter (see below).
Games::Go::Sgf2Dg modualizes the sgf2dg script. As such, it parses the command line (@ARGV) directly, and has only one callable method: run, called as follows (by the sgf2dg script):
Games::Go::Sgf2Dg->run;
The default converter is Dg2TeX which converts the Diagram to TeX source code (sgf2dg is a superset replacement for the sgf2tex script and package). If you have the GOOE fonts (provided in the same package as sgf2dg) correctly installed on your system you will be able to tex filename.tex to produce a .dvi file. You can of course embed all or parts of filename.tex into other TeX documents.
-newNumbers and -doubleDigits are alternative schemes for avoiding three-digit numbers in the diagrams. They should probably not be used together.
converters are quite easy to write - should take just a few hours if you are already conversant with the conversion target. If you would like to create a converter plugin module, the easiest way is probably to grab a copy of Dg2Ps.pm (for example) and modify it. Once it's working, please be sure to send us a copy so we can add it to the distribution.
Converters are always prepended with 'Games::Go::Sgf2Dg::Dg2', so to select the ASCII converter instead of the default TeX converter, use:
-converter ASCII
Converter names are case sensitive.
The default output filename suffix is determined by the converter: the converter name is lower-cased to become the suffix, so the ASCII converter produces <filename>.ascii from <filename>.sgf.
You can also select different converters by changing the name of the sgf2dg script (or better, make symbolic links, or copies if your system can't handle links). The converter name is extracted from the name with this regular expression:
m/sgf2(.*)/
Anything after 'sgf2' is assumed to be the name of a converter module. For example, let's create a link to the script:
$ cd /usr/local/bin $ ln -s sgf2dg sgf2Xyz
Executing:
$ sgf2Xyz foo.sgf [ options ]
attempts to use Games::Go::Sgf2Dg::Dg2Xyz as the converter. The converter name extracted from the script name is case sensitive.
Note that three extracted names are treated specially:
These three names (when extracted from the script name) always attempt to use Games::Go::Sgf2Dg::Dg2TeX as the converter.
Converters may be added dynamically as plugins, so this list only includes converter plugin modules that are included with the Sgf2Dg distribution.
Converter options are prepended with the converter name so that option xyz for converter Games::Go::Sgf2Dg::Dg2Abc is written on the command line as:
$ sgf2dg ... -Abc-xyz ...
Converter options that take arguments must be quoted so that the shell passes the option and any arguments as a single ARGV. For example, if the xyz option for converter Dg2Abc takes 'foo' and 'bar' as additional arguments, the command line would be:
$ sgf2dg ... "-Abc-xyz foo bar" ...
or a more realistic example of changing the background color:
$ sgf2dg genan-shuwa -converter Tk "-Tk-bg #d2f1b4bc8c8b"
Since Sgf2Dg is a super-set replacement for the Sgf2TeX package, TeX holds the default position for converters. Because of this historically priviledged position, the Dg2TeX options below do not need to be prepended with 'TeX-'. All of the following options apply to the Dg2TeX converter.
Other plugins available at the time of release are Dg2Mp, Dg2ASCII, Dg2PDF, Dg2Ps, Dg2Tk and Dg2TkPs. Dg2ASCII and Dg2TkPs take no additional options. Dg2Tk doesn't explicitly accept options, but it attempts to pass unrecognized options to the Tk::Canvas widgets at creation time (which is why the example above works).
For more information about converter-specific options, please refer to the perldoc or manual pages:
$ perldoc Games::Go::Sgf2Dg::Dg2PDF
or
$ man Games::Go::Sgf2Dg::Dg2Ps
control_string letters are consumed, one per diagram, until there is only one letter left. The final letter is used for all remaining diagrams.
The default control_string is 'rx' which places the first diagram on the right (text on the left) and all remaining diagrams are placed randomly.
sgf2dg was written by Reid Augustin, <reid@hellosix.com>
The GOOE fonts and TeX macros were designed by Daniel Bump (bump@math.stanford.edu). Daniel hosts the GOOE and sgf2dg home page at:
2019-10-27 | perl v5.30.0 |