tiler

package
v0.0.0-...-179ce65 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package tiler converts a standard image.Image to a tiled representation. Tiles are read as 8x8 pixel images starting a the top-left of the image (0,0).

This package is currently marked as 'internal' as it has very rough and untested code. Once this has been improved, and its API has been better defined, it may be moved to a public package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Orientation

type Orientation uint16

Orientation is used to indicate what flipped/rotated orientation a duplicate tile has.

const (
	OrientationNormal Orientation = iota
	OrientationFlippedV
	OrientationFlippedH
	OrientationFlippedVH
)

type Palette

type Palette map[string]color.Color

type Tile

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

Tile is an 8x8 pixel image tile.

func New

func New(row, col, tileSize int, palette Palette, tileImage image.Image) *Tile

func NewWithOrientations

func NewWithOrientations(row, col, tileSize int, palette Palette, tileImage image.Image) *Tile

NewWithOrientations a new tile, with all its different flipped orientations generated

func (*Tile) AddDuplicateInfo

func (t *Tile) AddDuplicateInfo(row, col int, orientation Orientation)

AddDuplicateInfo tile to the duplicates slice.

func (Tile) Col

func (i Tile) Col() int

func (*Tile) ColPosInPixels

func (t *Tile) ColPosInPixels() int

ColPosInPixels is the tile column location in pixels, as located in the source image.

func (*Tile) DuplicateCount

func (t *Tile) DuplicateCount() int

DuplicateCount returns number of duplicates for the tile.

func (*Tile) GetDuplicateInfo

func (t *Tile) GetDuplicateInfo(id int) (*info, error)

GetDuplicateInfo returns the duplicate at the given index number.

func (*Tile) IsDuplicate

func (t *Tile) IsDuplicate(tile *Tile) (Orientation, bool)

IsDuplicate tests the tile image for matching colours. If no match is found, then the image is flipped vertically, horizontally, and in both planes, and tested again after each.

func (Tile) Orientation

func (i Tile) Orientation() Orientation

func (*Tile) OrientationAt

func (t *Tile) OrientationAt(y, x int, orientation Orientation) (color.Color, error)

func (*Tile) Palette

func (t *Tile) Palette() (colours []color.Color)

func (Tile) Row

func (i Tile) Row() int

func (*Tile) RowPosInPixels

func (t *Tile) RowPosInPixels() int

RowPosInPixels is the tile row location in pixels, as located in the source image.

func (*Tile) Size

func (t *Tile) Size() int

Size is the number of width/height pixels of the tile; usually 8x8.

type Tiled

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

Tiled represents a tiled version of a the original image, consisting of unique 8x8 tiles.

func FromImage

func FromImage(img image.Image, tileSize int) *Tiled

FromImage returns a new tile set from the given image data. The tile size is the width/height of a tile in pixels, and must in be multiples of 8px.

func (*Tiled) ColourCount

func (b *Tiled) ColourCount() int

ColourCount is the total number of unique colours in the image.

func (*Tiled) GetTile

func (b *Tiled) GetTile(id int) (*Tile, error)

GetTile returns the tile for the given index number.

func (*Tiled) Height

func (b *Tiled) Height() int

func (*Tiled) TileCount

func (b *Tiled) TileCount() int

TileCount is the total number of unique tiles in the background image.

func (*Tiled) ToImage

func (b *Tiled) ToImage() (image.Image, error)

ToImage converts the tiled data to a new NRGBA image, with all tiles mapped back to their original positions.

func (*Tiled) Width

func (b *Tiled) Width() int

Jump to

Keyboard shortcuts

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