binpack

package
v0.0.0-...-b05aa3b Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2019 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package binpack implement a 2D bin packing algorithm.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

type Node struct {
	Rect
	Sub0  *Node // left or top child
	Sub1  *Node // right or bottom child
	Split int32 // split position
	Vert  bool  // split vertically
}

type Packer

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

func New

func New(rect Rect) *Packer

func (*Packer) Pack

func (p *Packer) Pack(width, height int32) (rect Rect, ok bool)

Pack a bin

func (*Packer) Unpack

func (p *Packer) Unpack(rect Rect) bool

Unpack a bin, the rect must be one of the valid rects return by previous Pack call. for minimize fragments, it is recommand to unpack rects in reverse order.

type Rect

type Rect struct{ L, T, R, B int32 }

func (Rect) H

func (rect Rect) H() int32

func (Rect) W

func (rect Rect) W() int32

Jump to

Keyboard shortcuts

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