struct Atlas

type Atlas* = struct {
	i: image::Image // source image
	cs: th::Vf2 // size of a cell in pixels
	dm: th::Vf2 // amount of cells in image
}

Atlas is an image containing tiles in a square grid.

fn mk

fn mk*(i: image::Image, dm: th::Vf2): Atlas {

i: source image dm: amount of cells

fn mk2

fn mk2*(i: image::Image, cs: th::Vf2): Atlas {

i: source image cs: size of a cell in pixels

fn Atlas.coords

fn (a: ^Atlas) coords*(n: int): th::Vf2 {

returns the coordinates of the nth tile

fn Atlas.rect

fn (a: ^Atlas) rect*(n: int): rect::Rect {

returns the rectangle of the nth tile

fn Atlas.index

fn (a: ^Atlas) index*(at: th::Vf2): int {

returns the index of the tile at the given coordinates

fn Atlas.has

fn (a: ^Atlas) has*(at: th::Vf2): bool {

returns true if the tile at the given coordinates exists

fn Atlas.hasIndex

fn (a: ^Atlas) hasIndex*(n: int): bool {

returns true if the tile at the given index exists

fn Atlas.cropSource

fn (a: ^Atlas) cropSource*(at: th::Vf2) {

Crops the sourse image to only show a wanted tile

enum PackStrategy

type PackStrategy = enum {
	square
	row
	column
}

fn pack

fn pack*(images: []image::Image, strategy: PackStrategy): (Atlas, std::Err) {

Packs an array of images into an atlas

fn Atlas.draw

fn (a: ^Atlas) draw*(at: th::Vf2, t: th::Transform, tint: uint32 = 0xFFFFFFFF) {

Draws the tile at at