Games:...:Dg2Ps(3pm)
π Games:...:Dg2Ps(3pm) π
okay so bestie, this is the User Contributed Perl Documentation page for Games:...:Dg2Ps(3pm), and no cap, it's lowkey iconic. it's giving "i turn Go diagrams into PostScript" and honestly? obsessed. π
β¨ NAME β¨
Games::Go::Sgf2Dg::Dg2Ps β converts Games::Go::Sgf2Dg::Diagrams into PostScript. that's it, that's the whole job. π
πΈ SYNOPSIS πΈ
use Games::Go::Sgf2Dg::Dg2Ps
my $dg2ps = Games::Go::Sgf2Dg::Dg2Ps->new (options);
$dg2ps->convertDiagram($diagram);
look at her go. two lines and she's already serving. π¦
π DESCRIPTION π
Games::Go::Sgf2Dg::Dg2Ps takes a Games::Go::Sgf2Dg::Diagram and converts it into PostScript. that's the entire personality. she's a converter, she converts, she slays. periodt. π
π NEW π
my $dg2ps = Games::Go::Sgf2Dg::Dg2Ps->new (?options?)
a fresh new Games::Go::Sgf2Dg::Dg2Ps accepts the following options, and bestie there are a LOT of them, so grab a snack: π
boardSizeX => number,boardSizeY => numberβ sets the size of the board. default:19doubleDigits => true | falseβ the numbers on the stones get wrapped back to1once they hit100. the numbers attached to comments and diagram titles? they are not affected, they live their own life. default:falsecoords => true | falseβ generates a coordinate grid. default:falsetopLine => number(default:1),bottomLine => number(default:19),leftLine => number(default:1),rightLine => number(default:19) β these are the edges of the board that should actually be displayed. anything on the board that extends past these numbers just... does not make it into the output. it's giving cropping era. βοΈdiaCoords => sub { # convert $x, $y to Diagram coordinates }β this callback lets you define a subroutine that converts coordinates from$x,$yinto whatever coordinate system yourGames::Go::Sgf2Dg::Diagramobject is using. the defaultdiaCoordsconverts 1-based$x,$yinto the exact same coordinates used in SGF format files. you only need to define this if your Diagram is running a different coordinate system, iykyk.
default:
sub { my ($x, $y) = @_;
$x = chr($x - 1 + ord('a')); # convert 1 to 'a', etc
$y = chr($y - 1 + ord('a'));
return("$x$y"); }, # concatenate two letters
also go peek at the diaCoords method further down, they're besties. π
print => sub { my ($dg2tex, @tex) = @_; ... }β a user defined subroutine that replaces the default printing method. this callback gets called from theprintmethod (below), and it's handed the reference to theDg2TeXobject plus a list of lines that are part of the TeX diagram source.
Dg2Ps-specific options: (yes, she has her own special section, main character energy π )
pageSize => 'page size'β may be one of:'A0'-'A9''B0'-'B10''Executive''Folio''Half-Letter''Letter''US-Letter''Legal''US-Legal''Tabloid''SuperB''Ledger''Comm #10 Envelope''Envelope-Monarch''Envelope-DL''Envelope-C5''EuroPostcard'
default: 'Letter'
topMargin => points,bottomMargin => points,leftMargin => points,rightMargin => pointsβ margins get set in PostScript 'user space units', which are approximately equivilent to points (that's1/72of an inch, for the girlies keeping score π).
default for all margins: 72 * .70 (7/10s of an inch)
text_fontName => 'font'default:'Times-Roman',stone_fontName => 'font'default:'Courier-Bold'β text and stone font names may be one of these, and heads up, they're case sensitive:CourierCourier-BoldCourier-BoldObliqueCourier-ObliqueHelveticaHelvetica-BoldHelvetica-BoldObliqueHelvetica-ObliqueTimes-RomanTimes-BoldTimes-ItalicTimes-BoldItalic
text_fontSize => pointsβ the point size for the comment text. diagram titles use this size plus4, and the game title uses this size plus6. the math is mathing. β¨
default: 11
stone_fontSize => pointsβstone_fontSizeis what decides the size of the stones and the diagrams. the stone size is picked so up to three digits can fit on a stone. the defaultstone_fontSizeallows for three diagrams (with-coords) per 'letter' page, as long as comments don't take up extra space below the diagrams.
if doubleDigits is specified, the stones and board end up slightly smaller (and stone 100 may look a bit cramped π).
default: 5
lineWidth => points,lineHeight => pointsβlineWidthandlineHeightdecide the size of the stones and the diagrams.
if lineWidth isn't explicitly set, it gets calculated from stone_fontSize so that up to three digits can fit on a stone. the default stone_fontSize allows for three diagrams (with -coords) per 'letter' page, assuming comments aren't eating extra space below the diagrams. if doubleDigits is specified, the stones and board get slightly smaller (stone 100 may look a bit cramped).
if lineHeight isn't explicitly set, it'll be 1.05 * lineWidth, which creates a slightly rectangular diagram. not a square, a slightly rectangle, we love a subtle shape moment.
default: undef β determined from stone_fontSize
ps_debug => number from 0 to 2β when it's non-zero, code and subroutines get added to the PostScript output to help debug the PostScript file. this is very slightly documented inPostScript::File, but honestly you'll probably have to read through the PostScript output yourself to make any use of it. good luck bestie π«Ά
default: 0
π METHODS π
$dg2ps->configure (option => value, ?...?)β change Dg2Ps options from values passed at new time.my $coord = $dg2mp->diaCoords ($x, $y)β gives you access to thediaCoordsoption (see above). returns coordinates in the converter's coordinate system for the board coordinates($x, $y). for example, if you want to grab a specific intersection structure:
my $int = $diagram->get($dg2mp->diaCoords(3, 4));
$dg2ps->print ($text ? , ... ?)β prints raw PostScript code to the file as defined at new time.$dg2ps->printComment ($text ? , ... ?)β adds$textto the diagram comments.$dg2ps->comment ($comment ? , ... ?)β inserts the PostScript comment character ('%') in front of every line of every comment and prints it to the file.
heads up: this is not the same thing as the printComment method. do not confuse the girlies. π
my $canvas = $dg2ps->convertDiagram ($diagram)β converts aGames::Go::Sgf2Dg::Diagraminto PostScript.my $converted_text = $dg2ps->convertText ($text)β converts$textinto text for display (it handles PostScript escape sequences).
returns the converted text.
$dg2ps->closeβ prints the final PostScript code to the output file and closes the file. that's a wrap, babes. π¬
β SEE ALSO β
sgf2dg(1)β script to convert SGF format files to Go diagrams
π BUGS π
Bugs? In my code? never. π
and that's the whole page, bestie. this was perl v5.30.0, dated 2019-10-27, and she ate every single time. π«Άβ¨π
π¦ where this page comes from
- debian bookworm: sgf2dg 4.252-1
- debian trixie: sgf2dg 4.252-1
- ubuntu jammy: sgf2dg 4.252-1
- ubuntu noble: sgf2dg 4.252-1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms