#png #sprite-sheet #ron #image #generate #amethyst #tile

app sprongen

Generate RON files for the given spritesheet PNG images

2 releases

0.0.2 Jan 15, 2020
0.0.1 Jan 15, 2020

#15 in #amethyst

MIT license

18KB
390 lines

sprongen

Spritesheet
RON
Generator

Description

Generates RON spritesheet config files for your spritesheet PNG images.
The spritesheet configs are generated in the format used by the amethyst engine.
Generated RON files are placed next to the corresponding PNG image file. (TODO: make this configurable)

Installation

From crates.io

cargo install sprongen

From source

Clone this repo ...

git clone https://github.com/Noah2610/sprongen

Install with cargo ...

cargo install --path sprongen/ --force

Usage

sprongen --help
sprongen 0.0.1
Generate RON files for the given spritesheet PNG images

USAGE:
    sprongen [FLAGS] [OPTIONS] <FILES>...

FLAGS:
    -h, --help
            Prints help information

    -p, --pretty
            Pretty format the generated RON files.

            Without this, generated RON files will have no new-lines/spacing.
    -V, --version
            Prints version information

    -v, --verbose
            Enable verbose logging.

            Prints information about used options, what PNG files are read, and what RON files are being generated. Is
            printed to stderr.

OPTIONS:
    -s, --tile-size <tile-size>
            Use the given tile size.

            <tile-size> format is `<width>x<height>`, where <width> and <height> are positive integers. [default: 32x32]

ARGS:
    <FILES>...

Examples

Let's say we have a directory spritesheets/ in which we have a bunch of
PNG spritesheet images, for which we want to create RON config files.
Our file structure may look something like this ...

spritesheets/
├── player.png
└── tiles.png

Some meta details about our example spritesheets:

  • player.png
    Sprites in this image all have the size 32x64 pixels.
  • tiles.png
    Sprites/tiles in this image all have the size 16x16 pixels.

Now, we want to generate RON config files, which we will use in our amethyst game.
These config files need to define each sprite's position and size in our spritesheets.

To generate the RON files, keeping our details listed above in mind, use sprongen like so ...

sprongen -vp --tile-size 32x64 spritesheets/player.png
sprongen -vp --tile-size 16x16 spritesheets/tiles.png
Explanation of used command-line options
  • -s or --tile-size
    Sets the target tile size, as we defined above.
    For this example, this is the only necessary option.
  • -v or --verbose
    Verbose logging, outputs information about what's happening.
  • -p or --pretty
    Pretty formatting, generated RON files have pretty formatting,
    containing new-lines and spacing for human-readability.

After this, our new file structure would look something like this ...

spritesheets/
├── player.png
├── player.ron
├── tiles.png
└── tiles.ron

License

Distributed under the terms of the MIT license.

Dependencies

~4.5MB
~78K SLoC