amaze.misc.resources

Handles image generation, loading and conversion Qt <-> numpy conversion

Module Attributes

NO_FILE_CACHE

Environment variable to set to disable file caching

Functions

arrow_path()

Returns a plain arrow

builtins()

List of all programmatically drawn signs

cached_resources_path()

Where to look for cached built-ins

clear_cache([verbose, files])

Clear the image cache

custom_resources_path()

Where to look for custom images

default_builtin()

Returns the default sign shape

default_lightness()

Returns the default lightness of a sign

default_size()

Returns the default size at which a built-in sign will be generated

error_builtin()

Returns the default sign shape for signaling an error

image(sign, size)

Return the image associated with given sign in the requested size

image_cached_path(sign, size)

Returns the path under which the image is cached for this specific resolution

names()

List of all possible sign shapes, including both built-ins and those found in resources_path()

no_file_cache()

Returns whether resources file caching is disabled

np_images(signs, resolution[, rgb_fill])

Returns images in numpy format (array) for all provided signs, with the requested resolution

qimage_to_numpy(img)

Converts a QImage into a numpy array

qt_images(signs, resolution)

Returns images in Qt format (QImage) for all provided signs, with the requested resolution

rebuild_signs_database()

Triggers an update of the lists of available signs (builtin and custom)

resources_format()

Image format for the cached and custom resources

resources_path()

Where to look for sign images and where to cache built-ins

Classes

Sign([name, value])

Describe a specific kind of Sign (clue, lure, trap) with a name and a lightness value.

SignType(value)

What kind of information the related sign provides

amaze.misc.resources.NO_FILE_CACHE = 'KGD_AMAZE_NOCACHE'

Environment variable to set to disable file caching

amaze.misc.resources.no_file_cache() bool[source]

Returns whether resources file caching is disabled

amaze.misc.resources.default_builtin()[source]

Returns the default sign shape

amaze.misc.resources.error_builtin()[source]

Returns the default sign shape for signaling an error

amaze.misc.resources.default_lightness()[source]

Returns the default lightness of a sign

amaze.misc.resources.default_size()[source]

Returns the default size at which a built-in sign will be generated

class amaze.misc.resources.SignType(value)[source]

What kind of information the related sign provides

CLUE = 'Clue'

Helpful sign. Shows the correct direction in an intersection

LURE = 'Lure'

Unhelpful sign. Points to random direction along the path

TRAP = 'Trap'

Deceitful sign. Shows the wrong direction in an intersection

class amaze.misc.resources.Sign(name: str = 'arrow', value: float = 0.5)[source]

Describe a specific kind of Sign (clue, lure, trap) with a name and a lightness value. Shape is derived either as a built-in function or as an image file

amaze.misc.resources.resources_path()[source]

Where to look for sign images and where to cache built-ins

amaze.misc.resources.cached_resources_path() Path[source]

Where to look for cached built-ins

amaze.misc.resources.custom_resources_path() Path[source]

Where to look for custom images

amaze.misc.resources.resources_format() str[source]

Image format for the cached and custom resources

amaze.misc.resources.clear_cache(verbose=False, files=True)[source]

Clear the image cache

Parameters:
  • verbose – Whether to print what has been cleared

  • files – Whether to also clear the cached files

amaze.misc.resources.builtins()[source]

List of all programmatically drawn signs

amaze.misc.resources.rebuild_signs_database()[source]

Triggers an update of the lists of available signs (builtin and custom)

amaze.misc.resources.names()[source]

List of all possible sign shapes, including both built-ins and those found in resources_path()

amaze.misc.resources.image(sign: Sign, size: int) QImage[source]

Return the image associated with given sign in the requested size

Raises:

ValueError – If the size is invalid (lower than 3)

amaze.misc.resources.image_cached_path(sign: Sign, size: int) Path[source]

Returns the path under which the image is cached for this specific resolution

amaze.misc.resources.qt_images(
signs: List[Sign],
resolution: int,
) List[List[QImage]][source]

Returns images in Qt format (QImage) for all provided signs, with the requested resolution

amaze.misc.resources.np_images(
signs: List[Sign],
resolution: int,
rgb_fill: int = 0,
) List[List[ndarray]][source]

Returns images in numpy format (array) for all provided signs, with the requested resolution

amaze.misc.resources.qimage_to_numpy(img: QImage) ndarray[source]

Converts a QImage into a numpy array

amaze.misc.resources.arrow_path()[source]

Returns a plain arrow