-
Notifications
You must be signed in to change notification settings - Fork 5
atlas.um
Marek Maskarinec edited this page Oct 9, 2022
·
2 revisions
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*(i: image.Image, dm: th.Vf2): Atlas {
i: source image dm: amount of cells
fn (a: ^Atlas) coords*(n: int): th.Vf2 {
returns the coordinates of the nth tile
fn (a: ^Atlas) cropSource*(at: th.Vf2) {
Crops the sourse image to only show a wanted tile
fn (a: ^Atlas) draw*(at: th.Vf2, t: th.Transform) {
Draws the tile at at