rle

package
v0.0.0-...-1f00af5 Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package rle contains support for Run-Length Encoding of level chunks.

Index

Constants

View Source
const NullColor = 0xFFFF

Variables

This section is empty.

Functions

func Alphabetize

func Alphabetize(value *uint64) string

Alphabetize converts a palette index value into a single character for Visualize to display.

It supports up to 36 palette indexes before it will wrap back around and begin reusing symbols.

Types

type Grid

type Grid [][]*uint64

Grid is a 2D array of nullable integers to store a flat bitmap of a chunk.

func MustGrid

func MustGrid(size int) Grid

func NewGrid

func NewGrid(size int) (Grid, error)

NewGrid will return an initialized 2D grid of equal dimensions of the given size.

The grid is indexed in [Y][X] notation, or: by row first and then column.

func (Grid) Compress

func (g Grid) Compress() ([]byte, error)

Compress the grid into a byte stream of RLE compressed data.

The compressed format is a stream of:

- A Uvarint for the palette index (0-255) or 0xffff (65535) for null. - A Uvarint for how many pixels to repeat that color.

func (Grid) Decompress

func (g Grid) Decompress(compressed []byte) error

Decompress the RLE byte stream back into a populated 2D grid.

func (Grid) Size

func (g Grid) Size() int

Size of the grid.

func (Grid) Visualize

func (g Grid) Visualize() string

Visualize the state of the 2D grid.

type Pixel

type Pixel struct {
	Point   render.Point
	Palette int
}

Jump to

Keyboard shortcuts

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