Skip to content

Files

Latest commit

3ef67f3 · Jan 19, 2024

History

History
116 lines (71 loc) · 3.29 KB

README.md

File metadata and controls

116 lines (71 loc) · 3.29 KB

s4c-scripts

A collection of sprite helpers for using ncurses with C.

Made for use with sprites4curses.

Table of Contents

Prerequisites

You need Pillow installed to use the CLI. Run:

PY_VENV_BIN_PATH=your/venv/bin/path make

To install dependencies.

Installaton

Run:

PY_VENV_BIN_PATH=your/venv/bin/path make install

To install the package with pip.

Scripts usage

To run the cli wrapper:

  • python -m s4c.s4c_cli <subcommand> <subcommand_args>

  • Some commands may be more useful when their output is redirected: python -m s4c.s4c_cli <subcommand> <subcommand_args> > file.txt

To run the subcommands directly:

  • python -m s4c.core.<SCRIPT> <subcommand_args>

If you successfull installed the package with pip, you will get a s4c executable that calls the s4c_cli.py script.

Scripts

s4c_cli.py

This is a wrapper script that imports the local scripts and enables calling their main as a subcommand.

Subscripts

sprites

This is a python script that converts PNG's to a char representation. The output text should be a valid C declaration for a 3D char array.

It expects as arguments:

  • A mode of operation: s4c-file, C-impl , C-header.
  • A directory with the images to convert.

sheet_converter

This is a python script that converts a single PNG spritesheet to a char representation. The output text should be a valid C declaration for a 3D char array.

It expects as arguments:

  • A mode of operation: s4c-file, C-impl , C-header.
  • The spritesheet file name
  • The sprite width
  • The sprite height
  • The thickness of the separator between sprites
  • The start coordinate (aka, the first sprite's left corner).

cut_sheet

This is a python script that cuts a single PNG spritesheet to a number of sprites, and puts them in the passed directory.

It expects as arguments:

  • The spritesheet file name
  • The output directory name
  • The sprite width
  • The sprite height
  • The thickness of the separator between sprites
  • The start coordinate (aka, the first sprite's left corner).

png_resize

This is a python script that resizess PNG's to a desired size.

It expects as arguments:

  • A directory with the images to resize
  • Two ints for width and height of the resulting PNGs.

palette

This is a python script that generates C files from a palette.gpl file.

It expects as arguments:

  • A mode of operation: C-impl , C-header.
  • The palette file
  • The relative path to the sprites4curses directory, so that the generated header can correctly include animate.h