atlas

package
v0.0.0-...-d322e89 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2018 License: BSD-2-Clause Imports: 2 Imported by: 3

Documentation

Overview

Package atlas provides a packing algorithm for creating atlases of 2D textures.

The current implementation is based on the algorithm presented by Jim Scott in:

http://blackpawn.com/texts/lightmaps/default.html

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Atlas

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

An Atlas contains the mapping information to pack a set of images into an array of bigger textures (called bins).

func New

func New(width, height int16) *Atlas

New returns a new (empty) Atlas. The width and height describe the shape of the bins.

func (*Atlas) BinCount

func (a *Atlas) BinCount() int16

BinCount returns the number of bins currently in the atlas.

func (*Atlas) BinSize

func (a *Atlas) BinSize() (width, height int16)

BinSize returns the width and height of the bins managed by the atlas.

func (*Atlas) Pack

func (a *Atlas) Pack(rectangles []uint32, size SizeFn, put PutFn)

Pack fits all the rectangles in the atlas. New bins are added when needed. It calls the Put method of each image with the corresponding mapping information.

func (*Atlas) Paint

func (a *Atlas) Paint(bin int16, dest interface{}, paint PaintFn) error

Paint iterates on all images mapped to the specified bin, and call their own Paint method.

func (*Atlas) Unused

func (a *Atlas) Unused() int

Unused returns the number of unused pixels (i.e. not allocated to any image) in the atlas.

type PaintFn

type PaintFn func(rect uint32, dest interface{}) error

type PutFn

type PutFn func(rect uint32, bin int16, x, y int16)

type SizeFn

type SizeFn func(rect uint32) (int16, int16)

Jump to

Keyboard shortcuts

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