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{ }

Important

Since backgrounds are bound to board, you don’t need to instantiate backgrounds objects directly. Instead use token.add_costume()

Background

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.

add_image(path)[source]

Adds an image to the appearance

Parameters
  • path – The path to the image relative to actual directory

  • animation – True if image should be removed after first animation

Returns: The index of the added image.

property grid_overlay

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

Examples

>>> 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
property is_scaled_to_tile

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.

Examples

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))
next_image()[source]

Switches to the next image of the appearance.

parent

The parent of a Background is the associated board.