Appearance: Background

The ‘Background’ class is a child classes of the ‘Appearance’ class.

classDiagram Appearance <|-- Costume Appearance <|-- Background Token o-- Appearance class Token{ +add_costume() } class Appearance{ +add_image(str) } class Costume{ } class Background{ }


Usually backgrounds are created with board.add_background([image_path|color])


class miniworldmaker.appearances.background.Background(*args, **kwargs)[source]

The class describes the background of a board.

Each board has one or more backgrounds that can be switched between. In addition, each background also has several pictures between which you can switch.

You can scale a background or tile it like a texture.


Adds an image to the appearance


path (str) – Path to the image relative to actual directory


Index of the created image.

Return type


property grid_overlay: Union[bool, tuple]

If not False, a grid overlay is drawn over the background image.


>>> a_token.background.grid_overlay = (255, 0, 0, 0)
Draws a red (255, 0, 0, 0) background overlay
>>> a_token.background.grid_overlay = False
Disables background grid_overlay
>>> a_token.background.grid_overlay = ()
Disables background grid_overlay. Same as a_token.background.grid_overlay = False
Return type

Union[bool, tuple]

property is_scaled_to_tile: bool

Scales the image to Tile_size.

The method is needed if you want to texture the background on a Tiled_Board and want the texture to fill one tile at a time.


Defines a textured board

>>> class MyBoard(TiledBoard):
>>>    def on_setup(self):
>>>         self.add_image(path="images/stone.png")
>>>         self.background.is_textured = True
>>>         self.background.is_scaled_to_tile = True
>>>         self.player = Player(position=(3, 4))
Return type



Switches to the next image of the appearance.


The parent of a Background is the associated board.