The patchwork Reference Manual

This is the patchwork Reference Manual, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Dec 08 19:09:46 2024 GMT+0.

Table of Contents


1 Introduction


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 patchwork

A spritesheet packer for games.

Author

Michael Fiano <>

Home Page

https://git.mfiano.net/mfiano/patchwork

License

MIT

Dependencies
  • binpack (system).
  • mfiano-utils (system).
  • opticl (system).
  • uiop (system).
Source

patchwork.asd.

Child Components

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


3.1 Lisp


3.1.1 patchwork/patchwork.asd

Source

patchwork.asd.

Parent Component

patchwork (system).

ASDF Systems

patchwork.


3.1.2 patchwork/package.lisp

Source

patchwork.asd.

Parent Component

patchwork (system).

Packages

patchwork.


3.1.3 patchwork/packer.lisp

Dependency

package.lisp (file).

Source

patchwork.asd.

Parent Component

patchwork (system).

Public Interface
Internals

3.1.4 patchwork/unpacker.lisp

Dependency

packer.lisp (file).

Source

patchwork.asd.

Parent Component

patchwork (system).

Public Interface

unpack-atlas (function).

Internals

4 Packages

Packages are listed by definition order.


4.1 patchwork

Source

package.lisp.

Use List

common-lisp.

Public Interface
Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


5.1 Public Interface


5.1.1 Ordinary functions

Function: make-atlas (file-spec &key out-file spec-file width height normalize flip-y padding optimize-pack auto-size-granularity-x auto-size-granularity-y)

Pack the sprites defined by FILE-SPEC into a spritesheet.

OUT-FILE: A pathname specifying where to write the image file.

SPEC-FILE: A pathname specifying where to write the metadata file. If unspecified, it is written to the same directory as OUT-FILE.

WIDTH: The width in pixels of the spritesheet. :AUTO to calculate width automatically.

HEIGHT: The height in pixels of the spritesheet. :AUTO to calculate height automatically.

NORMALIZE: Boolean specifying whether to map the metadata’s coordinates to the [0..1] range.

FLIP-Y: Boolean specifying whether to flip the Y axis when writing the metadata.

PADDING: The padding in pixels to use around each sprite in the spritesheet.

OPTIMIZE-PACK: Calculate size automatically, and try multiple sizes to find a better size. (ignores WIDTH, HEIGHT if set)

AUTO-SIZE-GRANULARITY-X, AUTO-SIZE-GRANULARITY-Y: Automatically generated sizes will be multiples of these.

See MAKE-ATLAS-FROM-DIRECTORY if you want to automatically generate FILE-SPEC from the files under a given filesystem path.

Package

patchwork.

Source

packer.lisp.

Function: make-atlas-from-directory (path &key recursive out-file spec-file width height normalize flip-y padding auto-size-granularity-x auto-size-granularity-y optimize-pack)

Pack the sprites located under the given filesystem path, PATH.

RECURSIVE: Boolean specifying whether to scan recursively for files.

OUT-FILE: A pathname specifying where to write the image file.

SPEC-FILE: A pathname specifying where to write the metadata file. If unspecified, it is written to the same directory as OUT-FILE.

WIDTH: The width in pixels of the spritesheet. :AUTO to calculate width automatically.

HEIGHT: The height in pixels of the spritesheet. :AUTO to calculate height automatically.

NORMALIZE: Boolean specifying whether to normalize the metadata’s coordinates in the [0..1] range.

FLIP-Y: Boolean specifying whether to flip the Y axis when writing the metadata.

PADDING: The padding in pixels to use around each sprite in the spritesheet.

OPTIMIZE-PACK: Calculate size automatically, and try multiple sizes to find a better size. (ignores WIDTH, HEIGHT if set)

AUTO-SIZE-GRANULARITY-X, AUTO-SIZE-GRANULARITY-Y: Automatically generated sizes will be multiples of these.

See MAKE-ATLAS if you want to manually specify a file-spec, in case you want to be in control of the names chosen to identify the sprites written to the metadata file.

Package

patchwork.

Source

packer.lisp.

Function: unpack-atlas (atlas-file &key out-path)

Unpack the sprites contained in the image, specified by the filesystem path, ATLAS-FILE. A file of the same name with a "spec" file extension must also exist in the same directory on the filesystem.

OUT-PATH: A pathname specifying a directory to write all the sprite images to.

Package

patchwork.

Source

unpacker.lisp.


5.1.2 Standalone methods

Method: rect-initargs append ((r rect))
Package

binpack/common.

Source

packer.lisp.


5.2 Internals


5.2.1 Ordinary functions

Function: add-padding (rects padding)
Package

patchwork.

Source

packer.lisp.

Function: collect-files (path &key recursive)
Package

patchwork.

Source

packer.lisp.

Function: make-atlas-coords (atlas data)
Package

patchwork.

Source

unpacker.lisp.

Function: make-id (root file)
Package

patchwork.

Source

packer.lisp.

Function: make-rects (files)
Package

patchwork.

Source

packer.lisp.

Function: make-sprite-path (directory id)
Package

patchwork.

Source

unpacker.lisp.

Function: rect (file id x y w h)
Package

patchwork.

Source

packer.lisp.

Function: remove-padding (rects padding)
Package

patchwork.

Source

packer.lisp.

Function: unpack-sprite (atlas data out-path)
Package

patchwork.

Source

unpacker.lisp.

Function: write-atlas (atlas sprite rect)
Package

patchwork.

Source

packer.lisp.

Function: write-metadata (data spec-path)
Package

patchwork.

Source

packer.lisp.

Function: write-sprite (atlas rect out-file)
Package

patchwork.

Source

unpacker.lisp.


5.2.2 Generic functions

Generic Function: %make-atlas-coords (atlas data normalized)
Package

patchwork.

Source

unpacker.lisp.

Methods
Method: %make-atlas-coords (atlas data normalized)
Method: %make-atlas-coords (atlas data (normalized (eql t)))
Generic Reader: file (object)
Package

patchwork.

Methods
Reader Method: file ((rect rect))

automatically generated reader method

Source

packer.lisp.

Target Slot

%file.

Generic Function: make-coords (rect width height normalize flip-y)
Package

patchwork.

Source

packer.lisp.

Methods
Method: make-coords (rect width height normalize flip-y)
Method: make-coords (rect width height (normalize (eql t)) flip-y)

5.2.3 Classes

Class: rect
Package

patchwork.

Source

packer.lisp.

Direct superclasses

rect.

Direct methods
Direct slots
Slot: %file
Initargs

:file

Readers

file.

Writers

This slot is read-only.


Appendix A Indexes


A.1 Concepts


A.2 Functions

Jump to:   %  
A   C   F   G   M   R   U   W  
Index Entry  Section

%
%make-atlas-coords: Private generic functions
%make-atlas-coords: Private generic functions
%make-atlas-coords: Private generic functions

A
add-padding: Private ordinary functions

C
collect-files: Private ordinary functions

F
file: Private generic functions
file: Private generic functions
Function, add-padding: Private ordinary functions
Function, collect-files: Private ordinary functions
Function, make-atlas: Public ordinary functions
Function, make-atlas-coords: Private ordinary functions
Function, make-atlas-from-directory: Public ordinary functions
Function, make-id: Private ordinary functions
Function, make-rects: Private ordinary functions
Function, make-sprite-path: Private ordinary functions
Function, rect: Private ordinary functions
Function, remove-padding: Private ordinary functions
Function, unpack-atlas: Public ordinary functions
Function, unpack-sprite: Private ordinary functions
Function, write-atlas: Private ordinary functions
Function, write-metadata: Private ordinary functions
Function, write-sprite: Private ordinary functions

G
Generic Function, %make-atlas-coords: Private generic functions
Generic Function, file: Private generic functions
Generic Function, make-coords: Private generic functions

M
make-atlas: Public ordinary functions
make-atlas-coords: Private ordinary functions
make-atlas-from-directory: Public ordinary functions
make-coords: Private generic functions
make-coords: Private generic functions
make-coords: Private generic functions
make-id: Private ordinary functions
make-rects: Private ordinary functions
make-sprite-path: Private ordinary functions
Method, %make-atlas-coords: Private generic functions
Method, %make-atlas-coords: Private generic functions
Method, file: Private generic functions
Method, make-coords: Private generic functions
Method, make-coords: Private generic functions
Method, rect-initargs: Public standalone methods

R
rect: Private ordinary functions
rect-initargs: Public standalone methods
remove-padding: Private ordinary functions

U
unpack-atlas: Public ordinary functions
unpack-sprite: Private ordinary functions

W
write-atlas: Private ordinary functions
write-metadata: Private ordinary functions
write-sprite: Private ordinary functions


A.3 Variables

Jump to:   %  
S  
Index Entry  Section

%
%file: Private classes

S
Slot, %file: Private classes