Documentation
¶
Overview ¶
Package sheetfile is the grid sheet format, *.sheet.json: fixed-size cells over one image (doc/guide/engine/asset-kinds.md#grid-sheet). The atlas loader in package render and the sheet tool of wpix-editor both use it, so the tool shows exactly the frames the loader makes. It imports the standard library only.
Index ¶
Constants ¶
const Suffix = ".sheet.json"
Suffix is the file name suffix of a grid sheet.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type File ¶
type File struct {
// Image is the texture, relative to the sheet's folder.
Image string `json:"image"`
// FrameW and FrameH are the size of one cell in pixels, at least 1.
FrameW int `json:"frameW"`
FrameH int `json:"frameH"`
// Margin is the border around the grid in pixels, Spacing the gap
// between cells; neither is negative.
Margin int `json:"margin,omitempty"`
Spacing int `json:"spacing,omitempty"`
// Pivot is nil for the default pivot.
Pivot *Pivot `json:"pivot,omitempty"`
}
File is a grid sheet. Frames are named "0", "1", ... left to right, top to bottom.
func Decode ¶
Decode parses the text of a sheet and checks it with File.Validate. All problems of a well-formed file are reported together.
func Starter ¶
Starter returns the sheet a new sheet tool starts from: 16 pixel cells, or the whole image when it is smaller, no margin and no spacing.
type Grid ¶
type Grid struct {
File *File
// Cols and Rows are the cells that fit; both are 0 when not even one
// does.
Cols, Rows int
// Size is the image size.
Size image.Point
}
Grid is the layout of a valid sheet over an image of a given size.
func (Grid) At ¶
At returns the frame under the image pixel p. It reports false for a pixel in the margin, in the spacing between cells or outside the grid.