https://github.com/samdze/spriterot
Command line utility to create spritesheets of rotated sprites.
https://github.com/samdze/spriterot
command-line command-line-tool gamedev nim nim-lang rotate-image sprites spritesheet
Last synced: 11 months ago
JSON representation
Command line utility to create spritesheets of rotated sprites.
- Host: GitHub
- URL: https://github.com/samdze/spriterot
- Owner: samdze
- License: mit
- Created: 2023-02-07T17:46:36.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-28T12:58:40.000Z (over 3 years ago)
- Last Synced: 2025-04-04T13:35:51.970Z (about 1 year ago)
- Topics: command-line, command-line-tool, gamedev, nim, nim-lang, rotate-image, sprites, spritesheet
- Language: Nim
- Homepage:
- Size: 20.5 KB
- Stars: 32
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# spriterot 
Command line utility to create spritesheets of rotated sprites.
## Features
- By default, generates spritesheets wasting as little space as possible.
- 4 rendering algorithms: RotSprite, shearing, nearest, linear.
- Resizes the sprite to make the rotations non-transparent pixels fit just right.
- Configurable (min, max, clamp, exact value) number of rows and columns in the generated spritesheet.
- Configurable number of frames to generate and range of the rotation.
- Overridable width and height for generated frames, or force keeping the same size.
- Configurable margin around generated frames.
- Verbose output to get info about the generated spritesheet.
- Can resolve the number of rotations to generate from the image filename: e.g. image`-rotations-36`.png for 36 frames.
## Usage
```
spriterot --help
spriterot
Usage:
[options] source
Arguments:
source Image to generate the rotations of.
Options:
-h, --help
-v, --verbose Show details about the image(s) being processed.
-k, --keep-size Keep the size of the source image for generated rotations, could lead to cropped frames.
--columns=COLUMNS Configure the number of columns the generated spritesheet should have. Could lead to wasted space or a cropped spritesheet. Possible values: [min:, max:, clamp:-, ]
--rows=ROWS Configure the number of rows the generated spritesheet should have. Could lead to wasted space or a cropped spritesheet. Possible values: [min:, max:, clamp:-, ]
--width=WIDTH Manual width of each generated frame. Could lead to wasted space or cropped frames.
--height=HEIGHT Manual height of each generated frame. Could lead to wasted space or cropped frames.
-m, --margin=MARGIN Margin around frames, in pixels. Inapplicable when --width or --height are manually set or when --keep-size is enabled. (default: 0)
-a, --algorithm=ALGORITHM Algorithm used to rotate the image. Possible values: [rotsprite, shearing, nearest, linear] (default: rotsprite)
-r, --rotations=ROTATIONS Amount of rotations to generate.
-f, --from=FROM Angle in degrees from which to start generating rotations. (default: 0)
-t, --to=TO Angle in degrees up to which to generate rotations. (default: 360)
-o, --output=OUTPUT Output filename.
```
## Examples
Create a spritesheet containing 9 frames of `input_image.png`, from 0 to 90 degrees, with a margin of 1 pixel around each frame.
```bash
spriterot -r 9 -f 0 -t 90 -m 1 -o output_image_from_0_to_90.png input_image.png
```
Create a spritesheet containing 20 frames of `input_image.png`, from 0 to 360 degrees, in a 2 columns grid. Verbose output.
```bash
spriterot -v --columns 2 -r 20 -o output_image_from_0_to_90.png input_image.png
```
Create a spritesheet containing 36 frames of `input_image.png`, from 0 to 360 degrees, keeping the size of the original source image for generated frames (could lead to cropped frames).
```bash
spriterot -r 36 --keep-size -o output_image_from_0_to_90.png input_image.png
```
## Outputs
`rotsprite`: best results for standard pixel art.

`shearing`: best results for keeping shades of dither patterns, e.g. Playdate graphics with dithering.

`nearest`: standard algorithm, nothing special.

`linear`: best results for conventional graphics, not pixel art.
