Skip to content

atlas.um

Marek Maskarinec edited this page Oct 9, 2022 · 2 revisions

atlas.um

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 coords*

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

returns the coordinates of the nth tile

fn cropSource*

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

Crops the sourse image to only show a wanted tile

fn draw*

fn (a: ^Atlas) draw*(at: th.Vf2, t: th.Transform) {

Draws the tile at at

Clone this wiki locally