API
- class pygoban.GobanMaker(*, size=(9, 9), line_widths=(1.0, 2.0), line_spacing=(22.0, 23.7), border_spacing=(11.0, 12.0), star_point_diameter=4.0, star_point_pos='auto', x_annotation=None, y_annotation=None, font_face='Microsoft YaHei', font_size=8)
Class to create svg files of Go boards using the cairo library.
Attributes
- sizetuple of two int, default=(9,9)
Number of vertical and horizontal lines that make up the grid.
- line_widthstuple of two float, default=(1.,2.)
Line widths of the grid (thinner lines), and the border of the grid (thicker lines), both in mm.
- line_spacingtuple of two float, default=(22., 23.7)
Spacing between vertical and horizontal lines of the grid in mm.
- border_spacingtuple of two float, default=(11.,12.)
Spacing of the border in mm, i.e., the space outside the grid.
- star_point_diameterfloat, default=4
Diameter of the star point markers in mm.
- star_point_poslist of tuples, default=’auto’
Grid points where to put star point markers. If ‘auto’, will try to put them in the 3 $ imes$ 3 corners on the center of the sides, and in the center, where possible.
- x_annotation[None, ‘arabic_numerals’, ‘chinese_numerals’, ‘latin_letters’], default=None
Annotation style for the vertical grid lines.
- y_annotation[None, ‘arabic_numerals’, ‘chinese_numerals’, ‘latin_letters’], default=None
Annotation style for the horizontal grid lines.
- font_facestr, default=’Microsoft YaHei’
Font face to use for the annotation of the vertical and horizontal grid lines.
- font_sizefloat, default=8
Font size to use for the annotation of the vertical and horizontal grid lines.
Examples
>>> g = GobanMaker( ... size=13 ... ) >>> g.create_svg_file(None)
>>> g = GobanMaker( ... size=(9,5) ... ) >>> g.create_svg_file(None)
- create_svg_file(file_path)
Make an svg file of the Go board according to the specified settings.
Parameters
- file_pathstr
Save path of the created svg file.
- set_board_size(size)
Set the size of the Go board.
Parameters
- sizeint or tuple of ints
Number of vertical and horizontal lines that make up the grid.
Examples
>>> g = GobanMaker() >>> g.set_board_size(9) >>> g.create_svg_file(None)
>>> g = GobanMaker() >>> g.set_board_size((13,12)) >>> g.create_svg_file(None)
- set_border_spacing(border_spacing)
Set the size of the border in mm.
Parameters
- border_spacingfloat or tuple of two floats
Spacing of border in mm.
>>> g = GobanMaker() >>> g.set_border_spacing((28.,28.)) >>> g.create_svg_file(None)
- set_font_size(font_size)
Set font size.
Parameters
- font_sizefloat
Font size to use.
>>> g = GobanMaker( ... x_annotation="latin_letters" ... ) >>> g.set_font_size(10) >>> g.create_svg_file(None)
- set_grid_annotation_style(x_annotation=None, y_annotation=None)
Set the type of annotation for the x and the y grid, so either none, annotation with Arabic numerals, Chinese numerals, or Latin letters.
Parameters
- x_annotation[None, “arabic_numerals”, “chinese_numerals”, “latin_letters”]
Annotation of the x-axis, i.e., the player facing sides of the board.
- y_annotation[None, “arabic_numerals”, “chinese_numerals”, “latin_letters”]
Annotation of the y-axis, i.e., the left/right sides of the board.
>>> g = GobanMaker() >>> g.set_grid_annotation_style( ... x_annotation='arabic_numerals', ... y_annotation='latin_letters' ... ) >>> g.create_svg_file(None)
- set_line_spacing(line_spacing)
Set the distance between horizontal and vertical lines in mm.
Parameters
- line_spacingfloat or tuple of two floats
Spacing between grids in mm.
>>> g = GobanMaker() >>> g.set_line_spacing((22.,23.)) >>> g.create_svg_file(None)
- set_line_widths(line_widths)
Set the line widths for the grid, and the border of the grid in mm.
Parameters
- line_widthstuple of floats
Line thickness in mm for the thinner grid lines and the thicker lines of the grid border.
Examples
>>> g = GobanMaker() >>> g.set_line_widths((1,2)) >>> g.create_svg_file(None)
- set_star_point_settings(star_point_pos=None, star_point_diameter=None)
Set the settings of the star point markers.
Parameters
- star_point_posint, tuple or ‘auto’.
If set to ‘auto’, will create star points on the 4x4, center and 4xcenter grid intersections. If an int n is specified, will put the star points on the nxn , center and nxcenter grid intersections. If a list of tuples is specified will create the point on only those points.
- star_point_diameterfloat
Diameter of the star point marker in mm.
Examples
>>> g = GobanMaker() >>> g.set_star_point_settings(star_point_pos=2) >>> g.create_svg_file(None)
>>> g.set_star_point_settings(star_point_pos=[(9,9)]) >>> g.create_svg_file(None)