Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bin

type Bin struct {
	Width  float64
	Height float64
	X      float64
	Y      float64
	Object interface{}
	// Packable    BinPackable
	Rotated     bool // if true this should be rotated by 90deg
	HasObject   bool
	HasChildren bool
	LeftChild   *Bin
	RightChild  *Bin
}

func NewBin

func NewBin(x float64, y float64, width float64, height float64, rotated bool) *Bin

func (*Bin) Insert

func (b *Bin) Insert(object interface{}, boundary BinBoundary) (bool, *Bin)

    Recursively attempts to add the packable in the bin returns (true, bin) or (false, nil)

    func (*Bin) IsHorizontalSplit

    func (b *Bin) IsHorizontalSplit() bool

      is this split on the horizontal axis: i.e. left means top, right means bottom

      type BinBoundary

      type BinBoundary interface {
      	GetWidth() float64
      	GetHeight() float64
      }

      type Container

      type Container struct {
      	Root   *Bin
      	Width  float64
      	Height float64
      	X      float64
      	Y      float64
      }

      func NewContainer

      func NewContainer(x float64, y float64, width float64, height float64) *Container

      func NewSingleObjectContainer

      func NewSingleObjectContainer(obj interface{}, x float64, y float64, width float64, height float64) *Container

        creates a new container with a single element. It will not be possible to add to this container.

        func (*Container) GetEmptyArea

        func (c *Container) GetEmptyArea() float64

          returns the total area in unit^2 of emptyness

          func (*Container) GetEmptyBins

          func (c *Container) GetEmptyBins() []*Bin

            finds all the empty bins, useful for finding how much space is left over

            func (*Container) Insert

            func (c *Container) Insert(object interface{}, boundary BinBoundary) (bool, Bin)

              Inserts the packable into the container and returns the bin it was placed in if possible

              func (*Container) InsertWithPadding

              func (c *Container) InsertWithPadding(object interface{}, boundary BinBoundary, padding float64) (bool, Bin)

                inserts into the container with the specified padding on all sides

                func (*Container) IsEmpty

                func (c *Container) IsEmpty() bool

                Source Files