Skip to content

Create scaled, vertical and horizontal sprite sheets from PNG images.

License

Notifications You must be signed in to change notification settings

VictorWesterlund/pysheeter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PySheeter

GitHub release (latest by date including pre-releases) GitHub last commit Maintenance

Lightweight Pillow Python package to create and scale sprite sheets from individual PNGs or whole folders

Get started / Basic usage

  1. Download and install the latest version of Python 3 for your architecture
  2. Install the latest build of PySheeter with pip3
$ python3 -m pip install pysheeter

Sprite sheet from folder

  1. Import Sheet from pysheeter
from pysheeter import PySheeter
  1. Initialize the class with a path to your PNG-folder
spritesheet = PySheeter.Sheet("example/")
  1. Create a sprite sheet with put()
spritesheet.put("example_v1616.png",(16,16)) 
# Creates a vertical spritesheet named 'example_v1616.png' with the dimensions 16x16px (scaled automatically)

Example usage:

# from 'example.py'
from pysheeter import PySheeter

# Load sprites from './files/' (all sprites are 64x64)
spritesheet = PySheeter.Sheet("example")

# Create a vertical spritesheet with the dimensions 16x16 (scaled)
spritesheet.put("example_v1616.png",(16,16))

# Create a horizontal spritesheet with the dimensions 16x32 (scaled & stretched)
spritesheet.put("example_h1632.png",(16,32),False)

Example 1 Example 2

Sprite sheet from individual PNG-images

  1. Import Sheet from pysheeter
from pysheeter import PySheeter
  1. Initialize the class without any arguments
spritesheet = PySheeter.Sheet()
  1. Add PNG-images with add()
spritesheet.add("example/1.png")
spritesheet.add("example/2.png")
spritesheet.add("example/3.png")
...
  1. Remove PNG-images with remove()
spritesheet.remove("example/2.png")
  1. Create a sprite sheet with put()
spritesheet.put("example_v1616.png",(16,16)) 
# Creates a vertical spritesheet named 'example_v1616.png' with the dimensions 16x16px (scaled automatically)

Example usage:

from pysheeter import PySheeter

# Load sprites from 'example/'
spritesheet = PySheeter.Sheet()

# Add PNG-images
spritesheet.add("example/1.png")
spritesheet.add("example/2.png")
spritesheet.add("example/3.png")
spritesheet.add("example/7.png")
spritesheet.add("example/5.png")
spritesheet.add("example/9.png")

# Create a vertical spritesheet with the dimensions 16x16
spritesheet.put("example_v1616.png",(16,16))

# Create a horizontal spritesheet with the dimensions 16x32
spritesheet.put("example_h1632.png",(16,32),False)

Example 1 Example 2