spritesheetlib Package

spritesheetlib Module

The spritesheet lib is a class to manipulate the spritesheet definitions. It can validate, create, transform (spacing and margin) and save spritesheet definitions. It also can generate a pygame surface with the outline of the sprites drawn on it (as template to draw sprites).

The spritesheet definition format is a json structure that allows to define the outline of a sprite as a polygon.

Versioning scheme based on: http://en.wikipedia.org/wiki/Versioning#Designating_development_stage

  +-- api change, probably incompatible with older versions
  |     +-- enhancements but no api change
  |     |
major.minor[.build[.revision]]
               |        |
               |        +-|* x for x bugfixes
               |
               +-|* 0 for alpha (status)
                 |* 1 for beta (status)
                 |* 2 for release candidate
                 |* 3 for (public) release

Changed in version 0.0.0.0: initial version

class build.lib.spritesheetlib.spritesheetlib.AABB(min_x, min_y, max_x, max_y)[source]

Bases: object

Axis aligned bounding box.

Parameters:
  • min_x – the min x coordinate
  • min_y – the min y coordinate
  • max_x – the max x coordinate
  • max_y – the max y coordinate
center_x

Returns the calculated center x value.

Returns:calculated center in x.
center_y

Returns the calculated center y value.

Returns:calculated center in y.
collide(other)[source]

Check if this AABB collides with other AABB.

Parameters:other – other AABB to collide with.
Returns:True if they have a common area, otherwise False.
collide_all(others)[source]

Checks if any of the other AABBs collide.

Parameters:others – list or iterable of other AABB.
Returns:List of colliding AABB. May be empty.
copy()[source]

Creates a new AABB instance with the same values.

Returns:New AABB with same values.
copy_from(other)[source]

Copies the values from the other instance.

Parameters:other – Other AABB instance.
static from_points(points)[source]

Creates a AABB from a bunch of points in the form [(px, py),...].

Parameters:points – a list of points in px, py coordinates, e.g. [(px, py), ....].
Returns:The AABB containing all points.
move(dx, dy)[source]

Creates a new instance of an AABB that is moved by dx, dy

Parameters:
  • dx – the distance to move in x direction.
  • dy – the distance to move in y direction.
Returns:

a new AABB instance that is moved by dx, dy.

move_ip(dx, dy)[source]

Move this AABB instance about dx, dy.

Parameters:
  • dx – the distance to move in x direction.
  • dy – the distance to move in y direction.
to_rect_tuple()[source]

Converts the AABB to a tuple representing a rect in the format (x, y, w, h).

Returns:tuple with following coordinates: (x, y, width, height)
union(other)[source]

Creates a new instances containing the other AABB.

Parameters:other – another AABB instance.
Returns:an AABB containing the other AABB.
union_all(others)[source]

Creates a new instance which contains all other AABB instances.

Parameters:others – iterable of other AABB instances.
Returns:an AABB containing all other AABB.
class build.lib.spritesheetlib.spritesheetlib.DummyLogger[source]

Bases: object

A dummy logger implementation. The methods are no-operations. Could be used as a basis to implement an interface for another logging framework.

debug(msg, *args, **kwargs)[source]

The debug message to log. :param msg: The message to log. :param args: Arguments if msg is a format string. :param kwargs: Keyword arguments.

error(msg, *args, **kwargs)[source]

The error message to log. :param msg: The message to log. :param args: Arguments if msg is a format string. :param kwargs: Keyword arguments.

info(msg, *args, **kwargs)[source]

The info message to log. :param msg: The message to log. :param args: Arguments if msg is a format string. :param kwargs: Keyword arguments.

warn(msg, *args, **kwargs)[source]

The warn message to log. :param msg: The message to log. :param args: Arguments if msg is a format string. :param kwargs: Keyword arguments.

class build.lib.spritesheetlib.spritesheetlib.FileInfo(file_path, os_module=<module 'os' from 'C:\Data\Programs\Python340\lib\os.py'>)[source]

Bases: object

This is an object for easier file manipulation.

Parameters:file_path – the path to the file, it must be a file.
Raises ValueError:
 ValueError is raised if the file path ends with either os.sep, os.altsep, os.curdir or the file path does contain a os.pathsep or the file path equals os.devnull.
delete()[source]

Deletes the file.

directory_name

The directory name where the file is.

Returns:The directory of the file.
exists

The exists property indicates if the file exists on the file system.

Returns:True, if the file exists on the file system, otherwise False.
full_name

The full name of the file, containing the path.

Returns:The path and filename of the file.
is_casing_different

Returns true if the files on the filesystem differs in the casing. Only relevant on windows. Otherwise it returns False, as if the file does not exist.

Returns:True if the casing is different than the one on the filesystem, otherwise False.
name

Name of the file.

Returns:The name of the file.
open(mode, buffering=-1)[source]

Opens the file for manipulation.

Parameters:
  • mode – the file open mode. See FileMode.
  • buffering – the buffering.
Returns:

a file descriptor.

class build.lib.spritesheetlib.spritesheetlib.FileMode[source]

Bases: object

This is a ‘enum’ enumerating the file modes.

WriteUpdate corresponds to ‘w+’ and truncates the file!

Append = 'a'
AppendBinary = 'ab'
AppendUpdate = 'a+'
AppendUpdateBinary = 'a+b'
Read = 'r'

same as ReadText, read text mode

ReadBinary = 'rb'
ReadText = 'rt'
ReadUniversalNewLines = 'rU'
ReadUpdate = 'r+'
ReadUpdateBinary = 'r+b'
Write = 'w'
WriteBinary = 'wb'
WriteText = 'wt'
WriteUpdate = 'w+'

Truncates the file!

WriteUpdateBinary = 'w+b'

Truncates the file to 0 bytes!

build.lib.spritesheetlib.spritesheetlib.get_area_of_polygon(points, epsilon=2.220446049250313e-16)[source]

Calculates the (unsigned) area of a polygon.

Parameters:
  • points – List of points, e.g. [(p1x, p1y), (p2x, p2y), ....]
  • epsilon – Precision, any absolute area value smaller than epsilon will be treated as 0.
Returns:

The area of the polygon. Always positive or 0.

build.lib.spritesheetlib.spritesheetlib.get_needed_digits(integer_number)[source]

Calculates the number of digits that are needed to represent a number as string.

Parameters:integer_number – The number to get the digits from.
Returns:
raise ValueError:
 if its not of type int of it is negative, ValueError is raised.
build.lib.spritesheetlib.spritesheetlib.get_orientation(points)[source]

Finds the orientation of a list of points.

Parameters:points – list of points, e.g. [(p1x, p1y), (p2x, p2y),...]
Returns:Returns 1 for Clockwise orientation, otherwise -1 for Counterclockwise.
build.lib.spritesheetlib.spritesheetlib.get_signed_area_of_polygon(points, epsilon=2.220446049250313e-16)[source]

Calculates the signed area of a polygon.

Parameters:
  • points – List of points, e.g. [(p1x, p1y), (p2x, p2y), ...]
  • epsilon – Precision, any absolute area value smaller than epsilon will be treated as 0.
Returns:

The signed area of the polygon. Positive for a clockwise order of points, otherwise negative.

build.lib.spritesheetlib.spritesheetlib.move_points(points, dx, dy)[source]

Moves the points about dx, dy.

Parameters:
  • points – iterable of points, e.g. [(p1x, p1y), (p2x, p2y),....]
  • dx – Distance to move in x direction, positive or negative.
  • dy – Distance to move in y direction, positive or negative.
Returns:

returns a new list of moved points as list of lists, e.g. [[p1x, p1y], [p2x, p2y],....]

class build.lib.spritesheetlib.spritesheetlib.PolygonOrientation[source]

Bases: object

This is an ‘enum’ to define Clockwise and CounterClockwise.

Clockwise=1 CounterClockwise=-1

Clockwise = 1
CounterClockwise = -1
build.lib.spritesheetlib.spritesheetlib.sign(v)[source]

Sign function.

Parameters:v – Value to return the sign.
Returns:-1 for negative values, 0 for 0, 1 for positive values.
class build.lib.spritesheetlib.spritesheetlib.Sprite(image, anchor, gid, properties)[source]

Bases: object

The sprite class.

Parameters:
  • image – The pygame surface containing the image data.
  • anchor – The anchor point.
  • gid – The global id of this image (from the sprite definition).
  • properties – The properties of this Sprite as defined in the sprite definition as dictionary {‘name’: value}.
exception build.lib.spritesheetlib.spritesheetlib.SpriteListException[source]

Bases: Exception

The SpriteListException class. Makes this exceptions catchable.

class build.lib.spritesheetlib.spritesheetlib.SpritesheetLib10(logger=<build.lib.spritesheetlib.spritesheetlib.DummyLogger object at 0x038A55D0>)[source]

Bases: object

The spritesheet lib. For loading, saving, creating and manipulating a sprite definition v1.0.

sprite definition file format (xml):

<version value="1.0"/>
<spritesheet filename="out.png.sdef" [width="" height=""] backgroundcolor="rrggbbaa">
    <sprite name="" anchor="" points="" >
        [<Transformations>
            <alpha value=""/>
        </Transformations>]
    </sprite>
</spritesheet>

# minimal (json):

{
"version": "1.0",
"filename": "out.png.sdef",
"sprites":
[
    {
      "name": "000",
      "points": [(x1,y1), ],
    },
    {
      "label": ""
      "action": "",
      "direction": "-1",
      "gid": "",   # unique number within sprite sheet
      "row": "-1",
      "col":"-1",
      "points": [(x1,y1), ],
    }
  ],
}

# full (json with <optional parts>):

{
"version": "1.0",
"filename": "out.png.sdef",
"<backgroundcolor": [r, g, b, a],<255, 0, 255, 255>>
"sprites":
  [
       {
          "gid": "000",
          <"anchor": (x,y),<default: top left of AABB, otherwise relative coordinates to topleft of AABB>>
          "points": [(x1,y1), ],
          <"transformations":
                  [
                      {"type": "alpha", "value": 200},
                      {"type": "translation", "x": 200, "y": 200, "z": 200},
                      {"type": "rotation", "angle": 200, "axis-x": 0.0, "axis-y": 0.0, "axis-z": 1.0},
                      {"type": "scale", "x": 1.0, "y": 1.0, "z": 1.0},
                      {"type": "flip", "x": true, "y": false},
                      {"type": "shear", "?": 1.0},
                      {"type": "matrix", "?": 1.0},

                  ]<None>>
          <"properties": {'key': 'value', ...}>
       },
       {
          "gid": "",
          "anchor": (x,y),
          "points": [(x1,y1), ],
          "transformations":
                  [
                      {"name":alpha, "value":200},
                  ]
          <"properties": {'column': 2, 'row': 3, 'key': 'value', ...}>
       }
  ]
}
Parameters:logger – The logger instance to use.
class ELEMENTS[source]

Bases: object

The elements of the version 1 of the sprite definition.

ANCHOR = 'anchor'
BACKGROUND = 'backgroundcolor'
FILENAME = 'filename'
GID = 'gid'
POINTS = 'points'
PROPERTIES = 'properties'
SPRITES = 'sprites'
VERSION = 'version'
class SpritesheetLib10.PROPERTIES[source]

Bases: object

The properties that may be used by this library code.

update: just make an update of the properties, overwriting and extending update_strict: additionally to update check if for every sprite there is an entry extend: only add additional properties, do not overwrite extend_strict: same as extend but checking if for every sprite there is an entry

ACTION = 'action'
COLUMN = 'col'
FACING = 'facing'
MODE = 'mode'
MODE_EXTEND = 'extend'

only add additional properties, do not overwrite

MODE_EXTEND_STRICT = 'extend_strict'

same as extend but checking if for every sprite there is an entry

MODE_UPDATE = 'update'

just make an update of the properties, overwriting and extending

MODE_UPDATE_STRICT = 'update_strict'

additionally to update check if for every sprite there is an entry

ROW = 'row'
SpritesheetLib10.adjust_margin(sdef, margin)[source]

Creates a new sprite definition with added margin.

Parameters:
  • sdef – Sprite definition to manipulate.
  • margin – The margin to add in pixels.
Returns:

New sprite definition with adjusted margin.

Raises ValueError:
 

ValueError is raised if the margin is negative.

SpritesheetLib10.adjust_spacing(source_sprite_def, spacing)[source]

Adjusts sprite definition to fulfill the spacing requirement. The margin is set to 0 (so no negative coordinates exists for any sprites, this is important for the image).

Parameters:
  • source_sprite_def – The source sprite definition.
  • spacing – The spacing between the sprites in pixels. None: don’t move the sprites, [0...) space between sprites in pixels.
Returns:

New sprite definition respecting spacing.

Raises ValueError:
 

If spacing or the margin is negative, ValueError is raised.

SpritesheetLib10.clone_sprite_definition(source_sprite_def)[source]

Makes a deep copy (using json serialization).

Parameters:source_sprite_def – The source sprite definition.
Returns:Copy of source sprite definition.
static SpritesheetLib10.create_empty_sprite_definition(file_name, background_color=None)[source]

Creates a empty sprite definition with some default values set.

Parameters:
  • file_name – The file name of the sprite definition.
  • background_color
Returns:

A empty sprite definition in json format: a dictionary

SpritesheetLib10.create_grid(num_tiles_x, num_tiles_y, tile_width, tile_height, file_info)[source]

Creates a sprite definition that contains a grid according to the arguments.

Parameters:
  • num_tiles_x – Number of tiles in x direction.
  • num_tiles_y – Number of tiles in y direction.
  • tile_width – The tile width in pixels.
  • tile_height – The tile height in pixels.
  • file_info – A FileInfo instance describing the filename to use in the sprite definition.
Returns:

New sprite definition with sprites arranged in a grid.

Raises ValueError:
 

if number of digits is too small to hold all sprites.

SpritesheetLib10.create_image(sprite_definition, pygame_module=None)[source]

Creates a image as pygame surface.

Parameters:
  • sprite_definition – The source sprite definition which the image is based on.
  • pygame_module – Default is None, therefore the pygame module is imported. Otherwise it should provide the same functionality used in this method. Mainly used for testing with a mock object.
Returns:

pygame.Surface

static SpritesheetLib10.get_aabb_of_sprite_definition(sprite_definition)[source]

Calculates the AABB of the entire sprite definition (including all sprites).

Parameters:sprite_definition – The sprite definition to calculate the AABB from.
Returns:The AABB containing all sprites from the definition.
SpritesheetLib10.get_image_name_from_sdef(sprite_definition)[source]

Returns the image name according to the sprite definition.

Parameters:sprite_definition – The sprite definition file.
Returns:The image name.
SpritesheetLib10.get_image_name_from_sdef_name(sdef_file_name)[source]

Returns the image name according to the sprite definition name. It actually just chops of the last extension.

Parameters:sdef_file_name – The sprite definition name.
Returns:The image name.
SpritesheetLib10.is_sprite_def_valid(sprite_definition)[source]

Checks if the sprite definition version 1.0 is valid.

Parameters:sprite_definition – The sprite definition to check.
Returns:True if it validates, otherwise False.
SpritesheetLib10.load_sdef_from_file(file_info, json_module=None)[source]

Loads a sprite definition from the file system.

Parameters:
  • json_module – The json module, mainly for mocking purposes.
  • file_info – The file info object containing the file name to load.
Raises ValueError:
 

ValueError is raised if the file name element has not the same name as the file it contains.

SpritesheetLib10.load_spritesheet(sprite_definition_file_info, pygame_module=None)[source]

Loads the spritesheet and returns a dictionary containing the sprites keyed by their name.

Parameters:
  • sprite_definition_file_info – The sprite definition file info to load.
  • pygame_module – Default is None, therefore the pygame module is imported. Otherwise it should provide the same functionality used in this method. Mainly used for testing with a mock object.
Returns:

SpritesList instance containing Sprite instances.

SpritesheetLib10.load_spritesheet_from_sdef(sprite_definition, image_file_info, pygame_module=None)[source]

Loads the sprites using the given sprite definition and the image file path.

Parameters:
  • sprite_definition
  • image_file_info – The name of the image as file info to load.
  • pygame_module – Default is None, therefore the pygame module is imported. Otherwise it should provide the same functionality used in this method. Mainly used for testing with a mock object.
Returns:

SpritesList instance containing Sprite instances.

SpritesheetLib10.load_spritesheet_from_sdef_and_surface(sprite_definition, sprite_sheet_surf, pygame_module=None)[source]

Loads the sprites from the sprite sheet using the sprite definition.

Parameters:
  • sprite_sheet_surf – The surface to use as the spritesheet.
  • sprite_definition – The sprite definition (json dict).
  • pygame_module – Default is None, therefore the pygame module is imported. Otherwise it should provide the same functionality used in this method. Mainly used for testing with a mock object.
Returns:

SpritesList instance containing Sprite instances.

SpritesheetLib10.save_image_to_disk(sprite_sheet_mask, file_info, pygame_module=None)[source]

Saves the image to disk to the file from the file_info.

Parameters:
  • pygame_module – The module to use as pygame. If None, pygame will be imported and used.
  • sprite_sheet_mask – The pygame.surface to save.
  • file_info – The file info to save the image to.
SpritesheetLib10.save_sprite_definition_to_disk(sprite_definition, file_info)[source]

Saves the sprite definition to disk to the file from file_info.

Parameters:
  • sprite_definition – The sprite definition to be saved.
  • file_info – The file info to save the sprite definition to.
SpritesheetLib10.update_sprite_properties(sprite_definition, properties)[source]

Updates the properties of the sprites. The new properties need an additional key-value pair called ‘mode’. The value of ‘mode’ can be one of the following: update, update_strict, extend, extend_strict

  • ‘update’ does take what is in the properties dictionary and puts it into the existing one.
  • ‘update_strict’ does the same as ‘update’ but checks that there is an entry for every gid.
  • ‘extend’ does ignore the entries from the new dictionary if the key already exists in the sprites properties.
  • ‘extend_strict’ does the same as extend but checks that there is an entry for every key
Parameters:
  • sprite_definition – The sprites to update.
  • properties – The properties to use for updating.
Returns:

None

class build.lib.spritesheetlib.spritesheetlib.SpritesList(iterable=None)[source]

Bases: list

The SpriteList class. It is basically a list with some convenience methods to sort and group the sprites.

Parameters:iterable – Initial items if not None.
get_columns()[source]

Returns a list of columns, e.g. [[sprites of 1st column], [2.column], ...] if ‘col’ and ‘row’ properties are defined, otherwise that sprite is left out (may result in an empty list). The inner lists are instance of SpritesList. This will fail if any sprite that has a ‘col’ property is missing the ‘row’ property.

get_gid_slice(start_gid, end_gid=2147483647)[source]

Returns a SpritesList containing all sprites with start <= gid <= end. May be empty or the sequence of gid could have gaps (if some gid is missing).

Parameters:
  • start_gid – The first gid that should be considered.
  • end_gid – The last gid that should be considered. If not set, all sprites to the end will be returned.
get_grouped_by_action_and_facing()[source]

Returns a dict containing the sprites sorted as follows:

{
    action1:{facing1:[sprites], facing2:[sprites], ...},
    action2:{facing1:[sprites], facing2:[sprites], ...},
    action3:{facing1:[sprites], facing2:[sprites], ...},
    ...
}

This allows to easily find out what actions are available in the spritesheet.

Returns:New dict containing the sprites with key by ‘action’ then by ‘facing’.
get_grouped_by_facing_and_action()[source]

Returns a dict containing the sprites sorted as follows:

{
    facing1:{action1:[sprites], action2:[sprites], ...},
    facing2:{action1:[sprites], action2:[sprites], ...},
    facing3:{action1:[sprites], action3:[sprites], ...},
    ...
}
Returns:New dict containing the sprites with key by ‘facing’ then by ‘action’.
get_grouped_by_property(property_name, group_sort_key=None)[source]

Returns a dict containing the groups indexed by key, e.g. {key: [spr1, spr2, ...], ...}

Parameters:
  • property_name – The name of the property that should be grouped by.
  • group_sort_key – The key function used to sort the groups.
Returns:

Dictionary.

get_rows()[source]

Returns a list of rows, e.g. [[sprites of 1st row], [2. row], ...] if ‘col’ and ‘row’ properties are defined, otherwise that sprite is left out (may result in an empty list). The inner lists are instance of SpritesList. This will fail if any sprite that has a ‘row’ property is missing the ‘col’ property.

spritesheetmaskgeneratorlib Module

The spritesheet_mask_generator is a tool to generate a spritesheet definition. It also can create a corresponding image that can be used as a spritesheet template (for drawing your own sprites). Internally it uses the spritesheet lib for all manipulations. What follows are the command line arguments that are implemented so far.

usage: SpriteSheetMaskGenerator [-h] [-s SPACING] [-m MARGIN] [-v | -q]
                                [-f | --dry-run] [-i] [-p PROPERTIES]
                                [--version]
                                {create_from_file,create_grid} ... filename

Create a sprite definition file and optionally a image file, e.g. 'x.png.sdef'
and 'x.png'. It uses pygame (>= 1.8) to create the file.Sub command help
available, e.g. 'spritesheet_mask_generator.py create_grid -h'. Place the
arguments at the same position as described in this help.

positional arguments:
  {create_from_file,create_grid}
                        This are the available commands. Either create a
                        sprite definition file with a checkers pattern or
                        generate a new sprite definition from a existing
                        sprite definition file. In both cases optionally an
                        image can be created too.
    create_from_file    This command creates a new sprite definition based on
                        the given sprite definition file. Using the spacing
                        and margin arguments it can be transformed. If none is
                        set, then a copy will be generated.
    create_grid         Creates a checkers board grid pattern according to the
                        parameters.
  filename              A filename to store the generated sprite sheet mask.
                        Should be in the form of 'out.png.sdef' or
                        'out.bmp.sdef'. Follow formats are supported by
                        pygame: BMP, TGA, PNG, JPEG. If the filename extension
                        is unrecognized it will default to TGA. Both TGA, and
                        BMP file formats create uncompressed files.

optional arguments:
  -h, --help            show this help message and exit
  -s SPACING, --spacing SPACING
                        The spacing in pixels between the sprites, greater or
                        equal to 0. If set to None, no sprites are moved
                        because spacing is then disabled.Otherwise if used
                        with an existing sprite definition file it may
                        separate sprites. (default: None)
  -m MARGIN, --margin MARGIN
                        The margin around the tiles in pixels in this image,
                        greater or equal to 0. (default: 0)
  -v, --verbose         Verbose (debug) logging. no arg: logging.ERROR, '-v':
                        logging.WARNING,'-vv': logging.INFO,'-vvv':
                        logging.DEBUG '--verbose': this is the same as '-v'
                        which is logging.WARNING. The default log level is
                        logging.ERROR. (default: 0)
  -q, --quiet           Silent mode, only log warnings. (default: None)
  -f, --force           Try to override existing file. (default: False)
  --dry-run             Do not write anything. (default: False)
  -i, --save_to_image   Generates and saves the image file. (default: False)
  -p PROPERTIES, --properties PROPERTIES
                        Provide a string describing a dictionary or a file
                        name of a json file. In both cases they should provide
                        a dictionary containing the properties that should be
                        set for some or all sprites. The string (dictionary)
                        has following structure:
                        {'gid_key':{'prop_key':'prop_value'}}. MAKE SURE TO
                        REMOVE ANY WHITESPACES! (otherwise you get a strange
                        arg parse error). In a big spritesheet it might be a
                        long list therefore the slice or range notation
                        (start, stop, step) is accepted for the gid_key (think
                        of it as a slice of range(N)[slice]), e.g.:'1' => [1];
                        '0:' => [0, 1, 2, 3, ..., N-1]; '0:3' => [0, 1, 2];
                        '0:10:2' => [0, 2, 4, 6, 8]; '0::2' => [0, 2, 4, 6,
                        ..., N-2] (if N even, otherwise N-1); ':5' => [0, 1,
                        2, 3, 4]; '::2' => see '0::2'; ':' => [0, 1, 2, ...,
                        N-1]; Negative steps are not allowed as ':' in keys
                        other than gid range notation.Note that when putting
                        the dict into a json file, the gid_key need to be
                        strings. Also the same gid might be addressed in
                        multiple keys with following limitation:the the
                        defined dictionaries will be merged as long they don't
                        have the same key defined. Here an example:props={'1':
                        {'k1': v1}, '0:': {'k2' : v2}} will generate
                        internally following: {'1': {'k1': v1, 'k2': v2}, '2':
                        {'k2': v2}, '2': {'k2': v2}, ...'N': {'k2': v2}. The
                        following will all generate errors: props={'1': {'k1':
                        v1}, '0:': {'k1': v3, 'k2' : v2}} <= 'k1' is
                        duplicated for gid '1' or props={'1': {'k1': v1, 'k1':
                        vx}} <= duplicated key 'k1' for gid '1' (default:
                        None)
  --version             show program's version number and exit

Versioning scheme based on: http://en.wikipedia.org/wiki/Versioning#Designating_development_stage

  +-- api change, probably incompatible with older versions
  |     +-- enhancements but no api change
  |     |
major.minor[.build[.revision]]
               |        |
               |        +-|* x for x bugfixes
               |
               +-|* 0 for alpha (status)
                 |* 1 for beta (status)
                 |* 2 for release candidate
                 |* 3 for (public) release

Changed in version 0.0.0.0: initial version

class build.lib.spritesheetlib.spritesheetmaskgeneratorlib.SpriteSheetMaskGenerator(spritesheet_lib, logger=<build.lib.spritesheetlib.spritesheetlib.DummyLogger object at 0x0436D7B0>, json_module=None)[source]

Bases: object

The application class of the spritesheet mask generator. Contains the main logic.

Use -h for all options.

CREATE_FROM_FILE_COMMAND = 'create_from_file'
GRID_COMMAND = 'create_grid'
main(args=None)[source]

The main function of the program (the entry point).

Parameters:args – The command line arguments. When None the sys.argv arguments are used, otherwise the passed list of strings. For a description of the arguments use the help.
save_to_disk(image_file_info, sprite_sheet_mask, sprite_definition_file_info, target_sprite_definition, dry_run, force, save_image)[source]

Saves the sprite definition and image to disk.

Parameters:
  • image_file_info – The file info for the image.
  • sprite_sheet_mask – The surface to save.
  • sprite_definition_file_info – The file info for the sprite definition.
  • target_sprite_definition – The sprite definition to save.
  • dry_run – If True then only the log entries are written, otherwise do the real work (on disk).
  • force – If True then overwrite existing files, otherwise nothing is written.
  • save_image – If True then the image is written to disk, otherwise not.
exception build.lib.spritesheetlib.spritesheetmaskgeneratorlib.DictParseError[source]

Bases: Exception

The exception raised when parsing a dictionary from string fails.