{"id":19330019,"url":"https://github.com/amethyst/sheep","last_synced_at":"2025-09-11T17:49:24.012Z","repository":{"id":35015186,"uuid":"159885043","full_name":"amethyst/sheep","owner":"amethyst","description":"Modular and lightweight spritesheet packer 🐑","archived":false,"fork":false,"pushed_at":"2023-06-13T20:27:30.000Z","size":101,"stargazers_count":90,"open_issues_count":15,"forks_count":12,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-05T14:36:25.949Z","etag":null,"topics":["amethyst","spritesheet"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amethyst.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-30T22:23:47.000Z","updated_at":"2025-03-09T11:55:16.000Z","dependencies_parsed_at":"2024-11-10T02:34:50.818Z","dependency_job_id":"a8ec8bf9-ac39-4936-88e6-bb6f058e32e5","html_url":"https://github.com/amethyst/sheep","commit_stats":{"total_commits":56,"total_committers":10,"mean_commits":5.6,"dds":0.3392857142857143,"last_synced_commit":"58798f288dd625318892e89d74e991c0be140836"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amethyst%2Fsheep","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amethyst%2Fsheep/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amethyst%2Fsheep/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amethyst%2Fsheep/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amethyst","download_url":"https://codeload.github.com/amethyst/sheep/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248036067,"owners_count":21037092,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["amethyst","spritesheet"],"created_at":"2024-11-10T02:33:21.403Z","updated_at":"2025-04-09T12:09:03.825Z","avatar_url":"https://github.com/amethyst.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sheep 🐑\n\n[![Build Status](https://travis-ci.org/amethyst/sheep.svg?branch=master)](https://travis-ci.org/amethyst/sheep)\n[![Crates.io](https://img.shields.io/crates/v/sheep)](https://crates.io/crates/sheep)\n\n`sheep` (Sprite**shee**t **p**acker) is a lightweight and modular library used to create spritesheets. It aims to impose as little restrictions as possible on the usage of its API so that it can be used in asset pipelines.\n\nThe project is in heavy development and the API might change a few times until we reach a stable version, but the general flow of inputting bytes and receiving metadata and a byte vec will remain the same.\n\n## Usage\n\nTo use the CLI, simply install it with cargo:\n\n```\ncargo install sheep_cli\n```\n\nUsagen hints are provided. To see all options, simply run the command with no arguments. Options can be passed to the packers using the `--options` flag, as space separated `key=value` pairs.\nBy default, the `maxrects` packer will be used, see [packers](#Packers) for more information.\n\n**Example:**\n\n```\nsheep pack --options max_width=1024 max_height=1024 sprites/*.png\n```\n\nIf you want to use the CLI from source, simple clone the repo and run `cargo run -- ...`. For an example on how to use the library directly, please see the `simple_pack` example in the `sheep/examples` directory.\n\n## Implementing your own `Packer` and `Format`\n\nSheep achieves its modularity by letting you choose the implementation it will use for packing the sprites and encoding the metadata. Right now, two common packing algorithms are provided (`SimplePacker` and `MaxrectsPacker`, see [packers](#Packers)), as well as the data format used by the [amethyst engine](https://github.com/amethyst/amethyst) (`AmethystFormat`). There will be more in the future, however, you can also choose your own packing algorithm and format:\n\n#### Implementing `Packer`\n\n```rust\npub struct MyPacker;\n\nimpl Packer for MyPacker {\n    fn pack(sprites: \u0026[SpriteData]) -\u003e PackerResult {\n        // Spritedata contains an id for the sprite to reference back\n        // to it, and the dimensions of the sprite.\n\n        // The expected output is the dimensions of the resulting spritesheet,\n        // as well as all the anchors for the sprites (i.e. their positions).\n        PackerResult { dimensions, anchors }\n    }\n}\n```\n\n#### Implementing `Format`\n\n```rust\npub struct MyFormat;\n\n// This is the format that will be output by encode, and you'll probably want\n// to serialize later.\n#[derive(Serialize)]\npub struct Foo {}\n\nimpl Format for AmethystFOrmat {\n    type Data = Foo;\n\n    fn encode(dimensions: (u32, u32), sprites: \u0026[SpriteAnchor]) -\u003e Self::Data {\n        // Encode the spritesheet dimensions and sprite positions into\n        // your chosen data format here.\n\n        Foo {}\n    }\n}\n```\n\n#### Using your custom `impl`s\n\nTo use custom packers or formatters, simply pass them as type parameters when calling the functions:\n\n```rust\nlet sprite_sheet = sheep::pack::\u003cMyPacker\u003e(sprites, 4);\nlet meta = sheep::encode::\u003cMyFormat\u003e(\u0026sprite_sheet);\n```\n\n## Packers\n\nRight now, there are two implementations to choose from:\n\n- MAXRECTS (**recommended**)\n\nImplementation of the maxrects sprite packing algorithm. The paper and original implementation used as a reference for this can be found [here](https://github.com/juj/RectangleBinPack). This algorithm should yield optimal results in most scenarios.\n\n- simple\n\nA naive implementation that will sort the sprites by area and then pack them all into a single texture. This won't scale very well since you can't limit the maximum size of the resulting sprite sheet, but can be quicker than maxrects in simple scenarios.\n\n## Roadmap\n\nHere are the planned features for `sheep`:\n\n- ~~Support for multiple output textures (bins)~~\n- ~~Smart output texture sizing~~\n- More packing algorithms\n  - ~~MAXRECTS~~\n  - Skyline\n- More meta formats\n- More image formats\n\n## License\n\n`sheep` is dual licensed under MIT and Apache, see `COPYING`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famethyst%2Fsheep","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famethyst%2Fsheep","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famethyst%2Fsheep/lists"}