Games:...:Dg2Ps(3pm)

πŸ“¦
version 4.252 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble

πŸ’– 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: 19
  • doubleDigits => true | false β€” the numbers on the stones get wrapped back to 1 once they hit 100. the numbers attached to comments and diagram titles? they are not affected, they live their own life. default: false
  • coords => true | false β€” generates a coordinate grid. default: false
  • topLine => 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, $y into whatever coordinate system your Games::Go::Sgf2Dg::Diagram object is using. the default diaCoords converts 1-based $x, $y into 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 the print method (below), and it's handed the reference to the Dg2TeX object 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's 1/72 of 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:
    • Courier
    • Courier-Bold
    • Courier-BoldOblique
    • Courier-Oblique
    • Helvetica
    • Helvetica-Bold
    • Helvetica-BoldOblique
    • Helvetica-Oblique
    • Times-Roman
    • Times-Bold
    • Times-Italic
    • Times-BoldItalic
  • text_fontSize => points β€” the point size for the comment text. diagram titles use this size plus 4, and the game title uses this size plus 6. the math is mathing. ✨

default: 11

  • stone_fontSize => points β€” stone_fontSize is 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 default stone_fontSize allows 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 β€” lineWidth and lineHeight decide 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 in PostScript::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 the diaCoords option (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 $text to 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 a Games::Go::Sgf2Dg::Diagram into PostScript.
  • my $converted_text = $dg2ps->convertText ($text) β€” converts $text into 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