core module¶
- class squaremap_combine.core.Combiner(tiles_dir: str | ~pathlib.Path, *, grid_step: int | None = None, style: ~squaremap_combine.core.CombinerStyle = CombinerStyle(bg_color=Color<#00000000>(0, 0, 0, 0), grid_line_color=Color<#000000ff>(0, 0, 0, 255), grid_line_size=1, grid_text_font=PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/squaremap-combine/envs/latest/lib/python3.12/site-packages/squaremap_combine/asset/FiraCode-SemiBold.ttf'), grid_text_pt=32, grid_text_stroke_size=6, grid_text_stroke_color=Color<#000000ff>(0, 0, 0, 255), grid_text_fill_color=Color<#ffffffff>(255, 255, 255, 255), grid_coords_format=''), confirm_fn: ~collections.abc.Callable[[str], bool] | None = None, progress_bar: bool = False)¶
Takes a squaremap
tilesdirectory path and can export stitched map images.- __init__(tiles_dir: str | ~pathlib.Path, *, grid_step: int | None = None, style: ~squaremap_combine.core.CombinerStyle = CombinerStyle(bg_color=Color<#00000000>(0, 0, 0, 0), grid_line_color=Color<#000000ff>(0, 0, 0, 255), grid_line_size=1, grid_text_font=PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/squaremap-combine/envs/latest/lib/python3.12/site-packages/squaremap_combine/asset/FiraCode-SemiBold.ttf'), grid_text_pt=32, grid_text_stroke_size=6, grid_text_stroke_color=Color<#000000ff>(0, 0, 0, 255), grid_text_fill_color=Color<#ffffffff>(255, 255, 255, 255), grid_coords_format=''), confirm_fn: ~collections.abc.Callable[[str], bool] | None = None, progress_bar: bool = False) None¶
- Parameters:
tiles_dir –
A path to a directory in the same format as what squaremap automatically generates. Example:
tiles (<- what this path should point to) ├───minecraft_overworld | ├───0 | ├───1 | ├───2 | └───3 ├───minecraft_the_nether | ├───0 | ├───1 | ├───2 | └───3 └───minecraft_the_end ├───0 ├───1 ├───2 └───3grid_step – The interval that should be used for things like drawing grid lines or coordinates onto the finished image. Will be treated as an interval of blocks, not pixels on the image.
style –
CombinerStyleinstance to define styling rules with.confirm_fn – A
Callableto use in cases where anyCombinerfunctions wish to ask for confirmation before continuing, which must returnTrueto continue.progress_bar – Whether to show a progress bar for any functions that support it.
- combine(world: str | ~pathlib.Path, *, zoom: int, area: ~squaremap_combine.geo.Rect | tuple[int, int, int, int] | None = None, crop: tuple[int, int] | ~typing.Literal['auto'] | None = None, tile_ext: str = '*', grid_step: int | None = None, style: ~squaremap_combine.core.CombinerStyle | dict[str, ~typing.Any] | None = None, grid_progress_interval_secs: float = 1.0, draw_grid_fn: ~collections.abc.Callable[[~PIL.Image.Image, ~squaremap_combine.geo.Grid, ~squaremap_combine.geo.Grid, ~squaremap_combine.core.CombinerStyle, float], None] = <staticmethod(<function Combiner._draw_grid_overlay>)>) Image¶
Combine the given world (dimension) tile images into one large map.
- Parameters:
world – Name of the world to use the tiles of, as a subdirectory of the instance’s
tiles_dirattribute. Alternatively, if given as aPathobject, the path will be used as-is and will ignoretiles_dirfor this run.zoom – The zoom level to use, from 0 (lowest detail, 8x8 blocks per pixel) to 3 (highest detail 1 block per pixel).
area – Specifies an area of the world to export. If
None, all tiles available are used.crop –
A size to crop the final image to, centering on the center of
area; or,'auto'can be given to trim excess empty space around the map’s borders, and crop it to the resulting visible area. In this case, the image is no longer guaranteed to be centered onarea.Note
Only tiles within
areawill be used, regardless of this value—ifcropis larger than the rendered area (and by extension, not'auto'), blank space will be left surrounding the map.tile_ext – The file extension used for the tile images. By default,
combine()will attempt to use all existing files under the relevant tiles directory that have any file suffix, and are not directories.grid_step – A grid step value to use instead of the
Combinerinstance’s.stepvalue, if notNone.style – A
CombinerStyleinstance to use instead of theCombinerinstance’sstyleinstance, if notNone. Can also be adictof key-value pairs, in which case only the specified keys’ values are overridden, and theCombinerinstance’sstyleis use as a fallback.grid_progress_interval_secs – At what interval to log grid overlay drawing updates. Set to
0or lower to disable.draw_grid_fn –
A function to call which will handle drawing the grid overlay on top of the map image being created. Will receive these arguments: -
PIL.Image.Image: The map image object to be drawn onto. -Grid: The “world grid”, representing the coordinates of the Minecraftworld.
Grid: The “canvas grid” for the image, a rectangle of0, 0to thesize of the image.
CombinerStyle: The style object to use, that being thisCombinerinstance’s
.styleattribute after being updated with or replaced by thestyleparameter of thecombinemethod.
float: In the default drawing function(
_draw_grid_overlay()), this is used as an interval of seconds at which to log updates on the drawing progress.
- Returns image:
The final stitched image, a
PIL.Image.Imageobject.- Raises:
NotADirectoryError – Raised if
worldis not a directory or does not exist.
- grid_step: int¶
Interval of blocks to use for the grid overlay. Grid overlay is disabled if set to 0.
- tiles_dir: Path¶
The squaremap
tilesdirectory to source tile images from.
- class squaremap_combine.core.CombinerStyle(bg_color: Color | str | None = None, grid_line_color: Color | str | None = None, grid_line_size: int | None = None, grid_text_font: str | Path | None = None, grid_text_pt: int | None = None, grid_text_stroke_size: int | None = None, grid_text_stroke_color: Color | str | None = None, grid_text_fill_color: Color | str | None = None, grid_coords_format: str | None = None)¶
Defines styling rules for
Combiner-generated map images.- __init__(bg_color: Color | str | None = None, grid_line_color: Color | str | None = None, grid_line_size: int | None = None, grid_text_font: str | Path | None = None, grid_text_pt: int | None = None, grid_text_stroke_size: int | None = None, grid_text_stroke_color: Color | str | None = None, grid_text_fill_color: Color | str | None = None, grid_coords_format: str | None = None) None¶
- Parameters:
bg_color – Background color to use for empty areas of the map. Default:
#00000000(clear)grid_line_color – Color for grid overlay lines. Default:
#000000ff(black)grid_line_size – Thickness of grid overlay lines. Default: 1
grid_text_font – Font to use for grid overlay coordinate text. Default: Fira Code (included with package)
grid_text_pt – Point size to use for grid overlay coordinate text. Default: 32
grid_text_stroke_size – Stroke (outline) size to use for grid overlay coordinate text. Default: 20% (rounded down) of
grid_text_ptgrid_text_stroke_color – Stroke (outline) color to use for grid overlay coordinate text. Default:
#000000ff(black)grid_text_fill_color – Color to use for grid overlay coordinate text. Default:
#ffffffff(white)grid_coords_format – String to use for coordinate text, which expects {x} and {y} specifiers to format. Default:
''