Documentation
¶
Index ¶
- Constants
- func CopyFile(src, dst string) error
- func FixPngChecksum(imagePath string) error
- func Gontage(gargs GontageArgs)
- func PreviewFolder(gargs GontageArgs)
- func PreviewSingleImage(gargs GontageArgs)
- func PrintFolderInfo(folderPath string)
- func PrintImageInfo(path string)
- func PrintPresetNames()
- func ResizeSingleImage(gargs GontageArgs)
- type GontageArgs
- type GontageMetadata
- type TrimMeta
Constants ¶
const ( MetaFlagTrimmed = 0x01 MetaFlagPng8 = 0x02 MetaFlagPng8F = 0x04 )
MetaFlag bits for GontageMetadata.Flags.
const (
MetaPixels = 16 // columns reserved in row 0
)
Variables ¶
This section is empty.
Functions ¶
func FixPngChecksum ¶ added in v1.6.0
FixPngChecksum attempts to fix PNG checksum errors by re-encoding the image
func Gontage ¶
func Gontage(gargs GontageArgs)
func PreviewFolder ¶ added in v1.8.0
func PreviewFolder(gargs GontageArgs)
PreviewFolder loads all sprites from the source folder (applying -trim if set) and runs them as a looping terminal flipbook animation.
func PreviewSingleImage ¶ added in v1.8.0
func PreviewSingleImage(gargs GontageArgs)
PreviewSingleImage displays the image as ASCII art, prompts the user for a sprite size (WxH), then runs a flipbook of the cut frames.
func PrintFolderInfo ¶ added in v1.26.0
func PrintFolderInfo(folderPath string)
PrintFolderInfo prints image info for every PNG in folderPath.
func PrintImageInfo ¶ added in v1.26.0
func PrintImageInfo(path string)
PrintImageInfo opens a PNG file and prints its dimensions, colour format, and any gontage pixel-header metadata to stdout.
func PrintPresetNames ¶ added in v1.25.0
func PrintPresetNames()
PrintPresetNames prints the available preset palette names and their sizes.
func ResizeSingleImage ¶
func ResizeSingleImage(gargs GontageArgs)
Types ¶
type GontageArgs ¶
type GontageArgs struct {
Sprite_source_folder string
Image_path string
Hframes int
Sprite_resize_px_resize int
Sprite_resize_percent float64 // -sr 50%: resize to this fraction (0.5 = 50%); 0 means not set
Fade_amount int
Fade_mode string
Normal_map bool
Single_sprites bool
Cut_spritesheet string
Convert_sprites string
Cpu_threads int
Fix_png_checksum bool
Trim bool
TrimCentered bool
TrimPadding int
Preview bool
Meta bool
SpriteResizeOverride bool // -sro: overwrite the source file(s) in-place instead of creating new names
Png8 bool // -png8: quantize to 256-colour adaptive palette, nearest-neighbour
Png8F bool // -png8f: quantize to 256-colour adaptive palette, Floyd-Steinberg dithering
Palette string // -palette: preset name, file path, or "list" (used with -png8/-png8f)
}
type GontageMetadata ¶ added in v1.26.0
type GontageMetadata struct {
OffsetX int16 // Godot texture_offset X (pixels from sprite centre to original centre)
OffsetY int16 // Godot texture_offset Y
HFrames uint16 // horizontal frame count in the spritesheet
FrameCount uint16 // total number of frames
VFrames uint16 // vertical frame count
Flags uint8 // MetaFlag* bitmask
}
GontageMetadata holds spritesheet properties embedded inside the image.
func ReadMetadataFromImage ¶ added in v1.26.0
func ReadMetadataFromImage(img image.Image) (GontageMetadata, bool)
ReadMetadataFromImage extracts GontageMetadata from a decoded image.
For *image.Paletted (PNG8) it reads from palette entries 0–(MetaPixels-1). For *image.NRGBA (PNG32) it reads from the R channels of pixels 0–(MetaPixels-1) in row 0 — all of which must have A=0.
type TrimMeta ¶ added in v1.8.0
type TrimMeta struct {
Applied bool
Mode string // "trim" or "trimc"
OffsetX int // pixels removed from left
OffsetY int // pixels removed from top
OriginalW int // original sprite width (before trim)
OriginalH int // original sprite height (before trim)
SpriteW int // trimmed sprite width
SpriteH int // trimmed sprite height
Padding int
}
TrimMeta holds the trim parameters that were applied to a set of sprites. OffsetX and OffsetY are the pixels removed from the left and top edges respectively; these are the values a game engine needs to restore the original visual position of each frame.