heavyfishdesign: github.com/dustismo/heavyfishdesign/binpacking Index | Files

package binpacking

import "github.com/dustismo/heavyfishdesign/binpacking"

Index

Package Files

binpacking.go

type Bin Uses

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 Uses

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

func (*Bin) Insert Uses

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 Uses

func (b *Bin) IsHorizontalSplit() bool

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

type BinBoundary Uses

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

type Container Uses

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

func NewContainer Uses

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

func NewSingleObjectContainer Uses

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 Uses

func (c *Container) GetEmptyArea() float64

returns the total area in unit^2 of emptyness

func (*Container) GetEmptyBins Uses

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

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

func (*Container) Insert Uses

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 Uses

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 Uses

func (c *Container) IsEmpty() bool

Package binpacking imports 1 packages (graph) and is imported by 1 packages. Updated 2020-04-13. Refresh now. Tools for package owners.