atlas

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Overview

Package atlas packs rectangles into a texture atlas: the placement half of "many small images in one texture" (textures, lightmaps, glyphs, sprites), which a WebGPU program does to bind one texture instead of hundreds. It has no GOOS constraint and no dependency; copying the pixels in (and into the GPU texture) is the caller's.

Index

Constants

This section is empty.

Variables

View Source
var ErrFull = errors.New("atlas: full")

ErrFull is returned by Shelf.Place when the rectangle does not fit.

Functions

This section is empty.

Types

type Rect

type Rect struct{ X, Y, W, H uint32 }

Rect is a placed region of the atlas, in texels.

type Shelf

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

Shelf is a shelf packer: rectangles go left to right in rows (shelves), each as tall as its tallest rectangle; a rectangle that does not fit the row starts the next one. It is simple, fast and tight enough for images of similar height.

func NewShelf

func NewShelf(width, maxHeight int) *Shelf

NewShelf returns a packer for an atlas width texels wide that may grow to maxHeight texels (the device's maxTextureDimension2D bounds it).

func (*Shelf) Height

func (s *Shelf) Height() int

Height is the height used so far: the texture to create is Width x Height.

func (*Shelf) Place

func (s *Shelf) Place(w, h int) (Rect, error)

Place reserves a w x h rectangle. It returns ErrFull for an empty or too wide rectangle and when the atlas would pass its maximum height.

func (*Shelf) Width

func (s *Shelf) Width() int

Width is the atlas width.

Jump to

Keyboard shortcuts

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