rectpack

package module
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 14, 2021 License: MIT Imports: 8 Imported by: 1

README

rectpack

General purpose rectangle packer for Golang

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoEmptySpace       = errors.New("Couldn't find an empty space")
	ErrSplitFailed        = errors.New("Split failed")
	ErrGrowthFailed       = errors.New("A previously added texture failed to be added after packer growth")
	ErrUnsupportedSaveExt = errors.New("Unsupported save filename extension")
	ErrNotPacked          = errors.New("Packer must be packed")
	ErrNotFoundNoDefault  = errors.New("Id doesn't exist and a default sprite wasn't specified")
	ErrAlreadyPacked      = errors.New("Pack has already been called for this packer")
)

Functions

This section is empty.

Types

type CreateFlags

type CreateFlags uint8

type PackFlags

type PackFlags uint8

type Packer

type Packer struct {
	// contains filtered or unexported fields
}

func NewPacker

func NewPacker(cfg PackerCfg) (pack *Packer)

Creates a new packer instance

func (*Packer) Get

func (pack *Packer) Get(id int) (rect image.Rectangle)

Returns the subimage bounds from the given id

func (*Packer) Image

func (pack *Packer) Image() *image.RGBA

Returns the entire packed image

func (*Packer) Insert

func (pack *Packer) Insert(id int, pic *image.RGBA)

Inserts PictureData into the packer

func (*Packer) InsertFromFile added in v1.1.0

func (pack *Packer) InsertFromFile(id int, filename string) (err error)

Automatically parse and insert image from file.

func (*Packer) Pack

func (pack *Packer) Pack() (err error)

Pack takes the added textures and packs them into the packer texture, growing the texture if necessary.

func (*Packer) Save

func (pack *Packer) Save(filename string) (err error)

Saves the internal texture as a file on disk, the output type is defined by the filename extension

func (*Packer) SetDefaultId added in v1.0.0

func (pack *Packer) SetDefaultId(id int)

Sets the default Id for the packer

If an id doesn't exist in the packer when 'Get' is called, the packer will return this sprite instead.

func (*Packer) SubImage added in v1.0.0

func (pack *Packer) SubImage(id int) (img *image.RGBA)

Returns the subimage, as a copy, from the given id

type PackerCfg added in v1.0.0

type PackerCfg struct {
	Flags CreateFlags
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL