| Name | skinpy JSON |
| Version |
0.0.4
JSON |
| download |
| home_page | None |
| Summary | A Python library for Minecraft skins |
| upload_time | 2024-08-02 04:26:59 |
| maintainer | None |
| docs_url | None |
| author | None |
| requires_python | >=3.9 |
| license | MIT |
| keywords |
|
| VCS |
 |
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
# Skinpy
<p align="center">
<img src="https://raw.githubusercontent.com/t-mart/skinpy/master/examples/render/lab_space.png" alt="isometric render" height=300>
</p>
A Python library for Minecraft skins.
- Load skins from a file, or start from scratch
- Index with 3D coordinates to get/set skin pixel color
- Operate at the skin level, the body part level, or even just one face
- Generate skin images for use in-game
- Render isometric ("angled/tilted view", like above) images of your skin
TODO: Add support for second layer
## Installation
```shell
pip install skinpy
```
## Quickstart
### Creating/Loading/Saving a skin
```python
from skinpy import Skin
# make a new skin
new_skin = Skin.new()
new_skin.to_image().save("blank.png")
# or load a skin from disk
loaded_skin = Skin.from_path("my_skin.png")
loaded_skin.to_image().save("copy.png")
```
### Rendering Isometric Images
You can render isometric images with the CLI tool:
```shell
skinpy render steve.png -o render.png
# see help with `skinpy render --help`
```
Or, here'e the API interface:
```python
from skinpy import Skin, Perspective
skin = Skin.from_path("steve.png")
# create a perspective from which to view the render
perspective = Perspective(
x="left",
y="front",
z="up",
scaling_factor=5, # bigger numbers mean bigger image
)
# save the render
skin.to_isometric_image(perspective).save("render.png")
```
Outputted file:

### Pixel Indexing
```python
from skinpy import Skin
skin = Skin.from_path("steve.png")
magenta = (211, 54, 130, 255) # RGBA
# get/set using entire skin's 3D coordinates
color = skin.get_color(4, 2, 0, "front") # somewhere on steve's right foot
print(f"Skin pixel at (4, 2, 0, 'front') was {color}")
skin.set_color(4, 2, 0, "front", magenta)
# get/set on just a head. coordinates become relative to just that part
color = skin.head.get_color(0, 1, 2, "left")
print(f"Head pixel at (0, 1, 2, 'left') was {color}")
skin.head.set_color(0, 1, 2, "left", magenta)
# or finally, just on one face. faces only have two dimensions
# NOTE: Face does not necessarily mean just a character's face! It just
# refers to the side of a cubiod, which all body parts are in Minecraft
color = skin.left_arm.up.get_color(5, 5)
print(f"Left arm up pixel at (5, 5) was {color}")
skin.head.set_color(0, 1, 2, "left", magenta)
skin.to_image().save("some_magenta.png")
```
Here's an animated visualization of equivalent ways to access a certain pixel:
<p>
<img src="https://github.com/t-mart/skinpy/raw/master/examples/render/steve-index.gif" alt="indexing" height=500>
</p>
(This image was made with `examples/index.py`.)
### Pixel Enumeration
```python
from skinpy import Skin
skin = Skin.from_path("steve.png")
for (x, y, z), body_part_id, face_id, color in skin.enumerate_color():
print(f"{x=}, {y=}, {z=}, {body_part_id=}, {face_id=}, {color=}")
for (x, y, z), face_id, color in skin.torso.enumerate_color():
print(f"{x=}, {y=}, {z=}, {face_id=}, {color=}")
for (x, y), face_id, color in skin.torso.back.enumerate_color():
print(f"{x=}, {y=}, {color=}")
```
## Coordinate system
Skinpy uses a coordinate system with the origin at the left-down-front of the
skin **from the perspective of an observer looking at the skin**.

## `FaceId`
In some methods, a `FaceId` type is asked for or provided. These are string literals:
- `up`
- `down`
- `left`
- `right`
- `front`
- `back`
## `BodyPartId`
Similarly, body parts are string literals under `BodyPartId`:
- `head`
- `torso`
- `right_arm`
- `left_arm`
- `right_leg`
- `left_leg`
Body parts that are "left" or "right" follow the same perspective as before: from the observer's point of view.
## Examples
You can find the skins/renders, and the code to produced them, in
[examples](./examples).
Raw data
{
"_id": null,
"home_page": null,
"name": "skinpy",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": "Tim Martin <tim@timmart.in>, Steven Van Ingelgem <steven@vaningelgem.be>",
"download_url": "https://files.pythonhosted.org/packages/4f/8f/a1f62d01b30c526fb1f1e814b5138b1e8b93f08de3d08ad55758a4411952/skinpy-0.0.4.tar.gz",
"platform": null,
"description": "# Skinpy\n\n<p align=\"center\">\n <img src=\"https://raw.githubusercontent.com/t-mart/skinpy/master/examples/render/lab_space.png\" alt=\"isometric render\" height=300>\n</p>\n\nA Python library for Minecraft skins.\n\n- Load skins from a file, or start from scratch\n- Index with 3D coordinates to get/set skin pixel color\n- Operate at the skin level, the body part level, or even just one face\n- Generate skin images for use in-game\n- Render isometric (\"angled/tilted view\", like above) images of your skin\n\nTODO: Add support for second layer\n\n## Installation\n\n```shell\npip install skinpy\n```\n\n## Quickstart\n\n### Creating/Loading/Saving a skin\n\n```python\nfrom skinpy import Skin\n\n# make a new skin\nnew_skin = Skin.new()\nnew_skin.to_image().save(\"blank.png\")\n\n# or load a skin from disk\nloaded_skin = Skin.from_path(\"my_skin.png\")\nloaded_skin.to_image().save(\"copy.png\")\n```\n\n### Rendering Isometric Images\n\nYou can render isometric images with the CLI tool:\n\n```shell\nskinpy render steve.png -o render.png\n# see help with `skinpy render --help`\n```\n\nOr, here'e the API interface:\n\n```python\nfrom skinpy import Skin, Perspective\n\nskin = Skin.from_path(\"steve.png\")\n\n# create a perspective from which to view the render\nperspective = Perspective(\n x=\"left\",\n y=\"front\",\n z=\"up\",\n scaling_factor=5, # bigger numbers mean bigger image\n)\n\n# save the render\nskin.to_isometric_image(perspective).save(\"render.png\")\n```\n\nOutputted file:\n\n\n\n### Pixel Indexing\n\n```python\nfrom skinpy import Skin\n\nskin = Skin.from_path(\"steve.png\")\nmagenta = (211, 54, 130, 255) # RGBA\n\n# get/set using entire skin's 3D coordinates\ncolor = skin.get_color(4, 2, 0, \"front\") # somewhere on steve's right foot\nprint(f\"Skin pixel at (4, 2, 0, 'front') was {color}\")\nskin.set_color(4, 2, 0, \"front\", magenta)\n\n# get/set on just a head. coordinates become relative to just that part\ncolor = skin.head.get_color(0, 1, 2, \"left\")\nprint(f\"Head pixel at (0, 1, 2, 'left') was {color}\")\nskin.head.set_color(0, 1, 2, \"left\", magenta)\n\n# or finally, just on one face. faces only have two dimensions\n# NOTE: Face does not necessarily mean just a character's face! It just\n# refers to the side of a cubiod, which all body parts are in Minecraft\ncolor = skin.left_arm.up.get_color(5, 5)\nprint(f\"Left arm up pixel at (5, 5) was {color}\")\nskin.head.set_color(0, 1, 2, \"left\", magenta)\n\nskin.to_image().save(\"some_magenta.png\")\n```\n\nHere's an animated visualization of equivalent ways to access a certain pixel:\n\n<p>\n <img src=\"https://github.com/t-mart/skinpy/raw/master/examples/render/steve-index.gif\" alt=\"indexing\" height=500>\n</p>\n\n(This image was made with `examples/index.py`.)\n\n### Pixel Enumeration\n\n```python\nfrom skinpy import Skin\n\nskin = Skin.from_path(\"steve.png\")\n\nfor (x, y, z), body_part_id, face_id, color in skin.enumerate_color():\n print(f\"{x=}, {y=}, {z=}, {body_part_id=}, {face_id=}, {color=}\")\n\nfor (x, y, z), face_id, color in skin.torso.enumerate_color():\n print(f\"{x=}, {y=}, {z=}, {face_id=}, {color=}\")\n\nfor (x, y), face_id, color in skin.torso.back.enumerate_color():\n print(f\"{x=}, {y=}, {color=}\")\n```\n\n## Coordinate system\n\nSkinpy uses a coordinate system with the origin at the left-down-front of the\nskin **from the perspective of an observer looking at the skin**.\n\n\n\n## `FaceId`\n\nIn some methods, a `FaceId` type is asked for or provided. These are string literals:\n\n- `up`\n- `down`\n- `left`\n- `right`\n- `front`\n- `back`\n\n## `BodyPartId`\n\nSimilarly, body parts are string literals under `BodyPartId`:\n\n- `head`\n- `torso`\n- `right_arm`\n- `left_arm`\n- `right_leg`\n- `left_leg`\n\nBody parts that are \"left\" or \"right\" follow the same perspective as before: from the observer's point of view.\n\n## Examples\n\nYou can find the skins/renders, and the code to produced them, in\n[examples](./examples).\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A Python library for Minecraft skins",
"version": "0.0.4",
"project_urls": {
"Repository": "https://github.com/t-mart/skinpy"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "dedfb60c920ecbb9df1e5a473db830f01ac90e152657b9a0ae35c67975b5b7c7",
"md5": "cc85139a0fe087bd998feba838a01a34",
"sha256": "7edd5c68dc6de9696562b619aaa9a2b405ebbd3f8aae86bb218e1e34c864330b"
},
"downloads": -1,
"filename": "skinpy-0.0.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "cc85139a0fe087bd998feba838a01a34",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 10967,
"upload_time": "2024-08-02T04:26:57",
"upload_time_iso_8601": "2024-08-02T04:26:57.789039Z",
"url": "https://files.pythonhosted.org/packages/de/df/b60c920ecbb9df1e5a473db830f01ac90e152657b9a0ae35c67975b5b7c7/skinpy-0.0.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "4f8fa1f62d01b30c526fb1f1e814b5138b1e8b93f08de3d08ad55758a4411952",
"md5": "8a6e3ca082f8cb93991f7d557603b766",
"sha256": "9bf65567dc7dc9d853fa80387ea47395e5b9b84caef14cd901d127d42308248f"
},
"downloads": -1,
"filename": "skinpy-0.0.4.tar.gz",
"has_sig": false,
"md5_digest": "8a6e3ca082f8cb93991f7d557603b766",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 236427,
"upload_time": "2024-08-02T04:26:59",
"upload_time_iso_8601": "2024-08-02T04:26:59.713277Z",
"url": "https://files.pythonhosted.org/packages/4f/8f/a1f62d01b30c526fb1f1e814b5138b1e8b93f08de3d08ad55758a4411952/skinpy-0.0.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-02 04:26:59",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "t-mart",
"github_project": "skinpy",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "skinpy"
}