World > Background#
A Background is a child class of Appearance.
Most methods and attributes are inherited from the Appearance base class.
API Reference#
- class miniworlds.appearances.background.Background(*args, **kwargs)[source]#
Background appearance of a world.
A background can be color-based or image-based, and each world can hold multiple background appearances that can be switched at runtime.
Examples
- Add an image background:
world = World() world.add_background(“images/my_image.png”)
- Add a color background:
world = World() world.add_background((255, 0, 0, 255))
- add_drawing_command(kind, *args, owner=None, **kwargs)[source]#
Add a persistent drawing command to the active background image.
- add_image(source)[source]#
Add an image source and immediately refresh the window surface.
- Return type:
- animation_length#
- clear_drawing_layer(owner=None)[source]#
Clear persistent background drawings.
- Return type:
- Parameters:
owner – If provided, only commands with this owner id are removed.
- draw_images#
- draw_shapes#
- property drawing_commands: tuple[dict[str, Any], ...]#
Persistent drawing commands rendered onto this background.
- font_manager#
- property grid: bool | tuple#
Whether a grid overlay is shown.
Accepts True, False, or a color tuple to set the grid color.
- id#
- image_manager: image_manager.ImageManager#
- initialized#
- last_image#
- loop#
- parent: world_mod.World#
Background.parent The world to which the background belongs to
- set_dirty(value='all', status=1)[source]#
Mark the background as dirty and refresh dependent actor visuals.
- set_drawing_commands(commands)[source]#
Replace persistent drawing commands and re-render the background.
- Return type:
- surface_loaded#
- transformations_manager#