pygamelib.gfx.core.Sprixel

class pygamelib.gfx.core.Sprixel(model='', bg_color='', fg_color='', is_bg_transparent=None)

A sprixel is the representation of 1 cell of the sprite or one cell on the Board. It is not really a pixel but it is the closest notion we’ll have. A Sprixel has a background color, a foreground color and a model. All regular BoardItems can have use Sprixel instead of model.

If the background color and the is_bg_transparent are None or empty strings, the sprixel will be automatically configured with transparent background. In that case, as we can really achieve transparency in the console, the sprixel will take the background color of whatever it is overlapping.

Parameters:
  • model (str) – The model, it can be any string. Preferrably a single character.
  • bg_color (str) – An ANSI escape sequence to configure the background color.
  • fg_color (str) – An ANSI escape sequence to configure the foreground color.
  • is_bg_transparent

Example:

player = Player(sprixel=Sprixel(
                                '#',
                                screen.terminal.on_color_rgb(128,56,32),
                                screen.terminal.color_rgb(255,255,0),
                                ))
__init__(model='', bg_color='', fg_color='', is_bg_transparent=None)

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__([model, bg_color, fg_color, …]) Initialize self.
black_rect() This classmethod returns a sprixel that is the equivalent of pygamelib.assets.graphics.BLACK_RECT.
black_square() This classmethod returns a sprixel that is the equivalent of pygamelib.assets.graphics.BLACK_SQUARE.
blue_rect() This classmethod returns a sprixel that is the equivalent of pygamelib.assets.graphics.BLUE_RECT.
blue_square() This classmethod returns a sprixel that is the equivalent of pygamelib.assets.graphics.BLUE_SQUARE.
cyan_rect() This classmethod returns a sprixel that is the equivalent of pygamelib.assets.graphics.CYAN_RECT.
cyan_square() This classmethod returns a sprixel that is the equivalent of pygamelib.assets.graphics.CYAN_SQUARE.
from_ansi(string) Takes an ANSI string, parse it and return a Sprixel.
green_rect() This classmethod returns a sprixel that is the equivalent of pygamelib.assets.graphics.GREEN_RECT.
green_square() This classmethod returns a sprixel that is the equivalent of pygamelib.assets.graphics.GREEN_SQUARE.
magenta_rect() This classmethod returns a sprixel that is the equivalent of pygamelib.assets.graphics.MAGENTA_RECT.
magenta_square() This classmethod returns a sprixel that is the equivalent of pygamelib.assets.graphics.MAGENTA_SQUARE.
red_rect() This classmethod returns a sprixel that is the equivalent of pygamelib.assets.graphics.RED_RECT.
red_square() This classmethod returns a sprixel that is the equivalent of pygamelib.assets.graphics.RED_SQUARE.
serialize() Serialize a Sprixel into a dictionary.
white_rect() This classmethod returns a sprixel that is the equivalent of pygamelib.assets.graphics.WHITE_RECT.
white_square() This classmethod returns a sprixel that is the equivalent of pygamelib.assets.graphics.WHITE_SQUARE.
yellow_rect() This classmethod returns a sprixel that is the equivalent of pygamelib.assets.graphics.YELLOW_RECT.
yellow_square() This classmethod returns a sprixel that is the equivalent of pygamelib.assets.graphics.YELLOW_SQUARE.

Attributes

bg_color
fg_color
model