A very simple REST API for Minecraft Spawn Egg preview.
Note
Probably in the future the same logic will be applied to other game elements that use a customizable color matrix (leaves, water etc).
GET
/<base_color>/<overlay_color>
Example: http://localhost:5000/DBCDC2/74A332
Ignore the image size for this example, we are usin a 32px image on the README just to be more simple to visualize.
Returns the full preview of a Spawn Egg. #
is not parsed on the URL! Colors must be F0F0F0
instead of #F0F0F0
. This URL will use the default image size of 128px.
GET
/<size>/<base_color>/<overlay_color>
Ignore the image size for this example, we are usin a 32px image on the README just to be more simple to visualize.
Same as the first endpoint but with specific size. Allowed Sizes: [16, 32, 64, 128, 256, 512]
Any other value will have the following formula applied:
When passing this argument into any endpoint the API will return the JSON data of the Spawn Egg. The response will looks like this:
// http://localhost:5000/64/8073FF/D4FF7A?data=true
{
"base64": "data:image/png;base64,...",
"base_color": {
"hex": "#8073FF",
"matrix": [0.50..., 0, 0, 0, 0, 0, 0.45..., 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0]
},
"overlay_color": {
"hex": "#D4FF7A",
"matrix": [0.83..., 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0.47..., 0, 0, 0, 0, 0, 1, 0]
},
"size": 64,
"filename": "64px-59c8477-c3fa-5bb6-a6ef-b1db4f521e6e.png",
"uuid": "59c8477-c3fa-5bb6-a6ef-b1db4f521e6e"
}
- A Visual Studio Code extension
- The idea is create a side-project using this API to preview the Spawn Egg when hover at
spawn_egg
property from a client-side entity file of Minecraft Bedrock Edition resource pack. Can be util for Add-Ons developers that want to be sure to not repeat colors or put similar colos on base and overlay.
- The idea is create a side-project using this API to preview the Spawn Egg when hover at
The main idea from the API is get the parsed HEX Color and convert into a Color Matrix and merge with Grayscale texture of the Spawn Egg. When both images are created, the system will merge into one and return the buffer as response.
Similarity with the Spawn Egg generated by the game: 99.93%
- Download Python3
- Create a new virtual environment and active
$ py -m venv .venv && .\.venv\Scripts\activate
- Install the dependencies
$ py -m pip install -r requirements.txt
- Execute the app
$ py .\api\app.py