Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrCroppingUnsupported error = errors.New("image does not support cropping")
var ErrSubTextureDoesNotExist error = errors.New("sub-texture does not exist")
Functions ¶
This section is empty.
Types ¶
type SubTexture ¶
type SubTexture struct {
Name string `xml:"name,attr"`
X int `xml:"x,attr"`
Y int `xml:"y,attr"`
Width int `xml:"width,attr"`
Height int `xml:"height,attr"`
FrameX int `xml:"frameX,attr"`
FrameY int `xml:"frameY,attr"`
FrameWidth int `xml:"frameWidth,attr"`
FrameHeight int `xml:"frameHeight,attr"`
}
func NewSubTexture ¶
func NewSubTexture(name string, x, y, width, height int) *SubTexture
NewSubTexture returns a new SubTexture.
func NewSubTextureFromRect ¶
func NewSubTextureFromRect(name string, r image.Rectangle) *SubTexture
NewSubTextureFromRect returns a new SubTexture from r.
func (*SubTexture) Image ¶
Image returns an true, cropped image representing the portion of the image i visible through the st's rect.
func (*SubTexture) MustImage ¶
func (st *SubTexture) MustImage(i image.Image) image.Image
MustImage simply calls Image and returns nil if an error occurs.
func (*SubTexture) Rect ¶
func (st *SubTexture) Rect() image.Rectangle
Rect returns the st's uncropped rect.
type TextureAtlas ¶
type TextureAtlas struct {
ImagePath string `xml:"imagePath,attr"`
SubTextures []*SubTexture `xml:"SubTexture"`
}
func NewTextureAtlas ¶
func NewTextureAtlas() *TextureAtlas
NewTextureAtlas returns a new TextureAtlas.
func ParseTextureAtlas ¶
func ParseTextureAtlas(xmlData []byte) (*TextureAtlas, error)
ParseTextureAtlas parses a Sparrow v2 texture atlas in XML format.
func ParseTextureAtlasFromFS ¶ added in v1.1.0
func ParseTextureAtlasFromFS(fsys fs.FS, path string) (*TextureAtlas, error)
ParseTextureAtlasFromFS parses a Sparrow v2 texture atlas in XML format from a filesystem.
func (*TextureAtlas) Encode ¶
func (ta *TextureAtlas) Encode() ([]byte, error)
Encode encodes a TextureAtlas as XML.
func (*TextureAtlas) EnumerateSubTextures ¶ added in v1.1.0
func (ta *TextureAtlas) EnumerateSubTextures() map[string]*SubTexture
EnumerateSubTextures returns a map that contains all sub-textures.
func (*TextureAtlas) GetSubTexture ¶ added in v1.1.0
func (ta *TextureAtlas) GetSubTexture(name string) (*SubTexture, error)
GetSubTexture finds and returns a SubTexture with the specified name.
func (*TextureAtlas) MustGetSubTexture ¶ added in v1.1.0
func (ta *TextureAtlas) MustGetSubTexture(name string) *SubTexture
MustGetSubTexture simplay calls GetSubTexture and returns nil if an error occurs.