{ "info": { "author": "Daniel CAUNE", "author_email": "daniel.caune@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Software Development :: Libraries" ], "description": "# Sprite Sheet Python Library\n\n## Overview\n\nThe **Sprite Sheet Python Library** adds sprite sheet processing capabilities to your Python interpreter.\n\nThis library provides method to find the sprites that are packed in a single image, and to return their position in this image (bounding boxes).\n\n## Concepts\n\n### Sprite\n\nA [**sprite**]() is a small [**raster graphic**](https://en.wikipedia.org/wiki/Raster_graphics) (a **bitmap**) that represents an object such as a character, a vehicle, a projectile, etc.\n\n![Metal Slug ](metal_slug_sprite_large.png)\n\nSprites are a popular way to create large, complex scenes as you can manipulate each sprite separately from the rest of the scene. This allows for greater control over how the scene is rendered, as well as over how the players can interact with the scene.\n\nSprites are mainly used in 2D video games, such as [Shoot'em up](https://en.wikipedia.org/wiki/Shoot_%27em_up) in which the hero combats a large number of enemies by shooting at them while dodging their fire:\n\n| [Cannon Fodder]() | [Commando]() | [Metal Slug](https://en.wikipedia.org/wiki/Metal_Slug) |\n| --------------------------------------------------------------------------- | ----------------------------------------------------------------- | ------------------------------------------------------ |\n| ![Cannon Fodder](2d_video_game_cannon_fodder.jpg) | ![Commando](2d_video_game_commando.jpg) | ![Metal Slug](2d_video_game_metal_slug.png) |\n\n## Sprite Sheet\n\nIt is not uncommon for games to have tens to hundreds of sprites. Loading each of these as an individual image would consume a lot of memory and processing power. To help manage sprites and avoid using so many images, many games use **sprite sheets** (also known as **image sprites**).\n\nA sprite sheet consists of multiple sprites in one image. In other words, sprite sheets pack multiple sprites into a single picture. Using sprite sheet, video game developers create sprite sheet animation representing one or several animation sequences while only loading a single file:\n\n![Metal Slug Sprites](metal_slug_sprite_sheet_large.png)\n\n### Sprite Bounding Box\n\nA frame (**bounding box**) can be used to delimit the sprite in the sprite sheet. This bounding box is defined with two 2D points `top_left` and the `bottom_right`, which their respective coordinates `x` and `y` are relative to the top-left corner of the sprite sheet's image.\n\nFor example:\n\n![Shape Bounding Boxes](metal_slug_sprite_detection_bounding_boxes.png)\n\n### Sprite Mask\n\nThe mask of a sprite defines the 2D shape of the sprite. For example, the sprite sheet [`metal_slug_sprite_standing_stance.png`](metal_slug_sprite_standing_stance_large.png) contains the 3 following sprites:\n\n![Metal Slug Standing Stance](metal_slug_sprite_detection.png)\n\nThe masks of these sprites are respectively:\n\n![](metal_slug_sprite_detection_coloring.png)\n\n## Installation\n\nInstall the **Sprite Sheet Python Library** with [`pip`](https://pip.pypa.io/en/stable/):\n\n```bash\n$ pip install sprite-sheet\n```\n\n## Usage\n\nFor example, let's consider the image file [sprite_example.png](metal_slug_single_sprite.png) zoomed-in hereafter:\n\n![](metal_slug_single_sprite_large.png)\n\n```python\n>>> from spriteutil.spritesheet import SpriteSheet\n>>> sprite_sheet = SpriteSheet('metal_slug_single_sprite.png')\n>>> sprites, label_map = sprite_sheet.find_sprites(background_color=(255, 255, 255))\n>>> len(sprites)\n1\n>>> for label, sprite in sprites.items():\n... print(f\"Sprite ({label}): [{sprite.top_left}, {sprite.bottom_right}] {sprite.width}x{sprite.height}\")\nSprite (1): [(0, 0), (29, 37)] 30x38\n>>> import pprint\n>>> pprint.pprint(label_map, width=120)\n[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0],\n [0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0],\n [0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0],\n [0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0],\n [0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0],\n [0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,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content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "spriteutil", "package_url": "https://pypi.org/project/spriteutil/", "platform": "any", "project_url": "https://pypi.org/project/spriteutil/", "project_urls": null, "release_url": "https://pypi.org/project/spriteutil/1.2.5/", "requires_dist": [ "numpy", "pillow", "pipfile", "setuptools", "wheel", "twine" ], "requires_python": ">=3.6", "summary": "Sprite Detection Python Library", "version": "1.2.5", "yanked": false, "yanked_reason": null }, "last_serial": 7367679, "releases": { "1.2.5": [ { "comment_text": "", "digests": { "md5": "d228f4533caf87e175dda80a8d8235c8", "sha256": "cc5142a334e7ca44ad05b37d7bb34b1f5a41d6e6d36343aadf681c2f4f605c3f" }, "downloads": -1, "filename": "spriteutil-1.2.5-py3-none-any.whl", "has_sig": false, "md5_digest": "d228f4533caf87e175dda80a8d8235c8", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 11254, "upload_time": "2020-06-01T03:23:22", "upload_time_iso_8601": "2020-06-01T03:23:22.338843Z", "url": "https://files.pythonhosted.org/packages/5a/49/11ba3f8e51861186a7058faca79a31eb55647163d36ea71294390a61364e/spriteutil-1.2.5-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "0118dbc656ab29a08724f4d4bf4e21f0", "sha256": "54a103af158ada994175285cca8be7e8229488bdd8ba9dfef380acd5ff690085" }, "downloads": -1, "filename": "spriteutil-1.2.5.tar.gz", "has_sig": false, "md5_digest": "0118dbc656ab29a08724f4d4bf4e21f0", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 11966, "upload_time": "2020-06-01T03:23:24", "upload_time_iso_8601": "2020-06-01T03:23:24.323293Z", "url": "https://files.pythonhosted.org/packages/18/9c/7fcb0f7020c2b7c28cdc1f00c352635f1176ab07b6abae6bf57f3ac302a7/spriteutil-1.2.5.tar.gz", "yanked": false, "yanked_reason": null } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d228f4533caf87e175dda80a8d8235c8", "sha256": "cc5142a334e7ca44ad05b37d7bb34b1f5a41d6e6d36343aadf681c2f4f605c3f" }, "downloads": -1, "filename": "spriteutil-1.2.5-py3-none-any.whl", "has_sig": false, "md5_digest": "d228f4533caf87e175dda80a8d8235c8", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 11254, "upload_time": "2020-06-01T03:23:22", "upload_time_iso_8601": "2020-06-01T03:23:22.338843Z", "url": "https://files.pythonhosted.org/packages/5a/49/11ba3f8e51861186a7058faca79a31eb55647163d36ea71294390a61364e/spriteutil-1.2.5-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "0118dbc656ab29a08724f4d4bf4e21f0", "sha256": "54a103af158ada994175285cca8be7e8229488bdd8ba9dfef380acd5ff690085" }, "downloads": -1, "filename": "spriteutil-1.2.5.tar.gz", "has_sig": false, "md5_digest": "0118dbc656ab29a08724f4d4bf4e21f0", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 11966, "upload_time": "2020-06-01T03:23:24", "upload_time_iso_8601": "2020-06-01T03:23:24.323293Z", "url": "https://files.pythonhosted.org/packages/18/9c/7fcb0f7020c2b7c28cdc1f00c352635f1176ab07b6abae6bf57f3ac302a7/spriteutil-1.2.5.tar.gz", "yanked": false, "yanked_reason": null } ], "vulnerabilities": [] }