Coldwave Read the docs

Atlases: frames by name#

Draw many different sprites for the cost of one. An atlas is many pictures on one, each a frame with a name: a sprite gives the atlas as its image and the frame as its frame. Every sprite of an atlas is one picture to the device, so sprites of one atlas on a layer are one draw call, wherever they are. An atlas is a file of its own, NAME.atlas.toml, in one of two forms:

TOML
# art/hero.atlas.toml: the PNG files the patterns match, packed onto one page; each
# frame is named by its file's name without .png (hero/run_0.png is "run_0").
pictures = ["hero/*.png"]
TOML
# art/coins.atlas.toml: one sheet cut into cells, row by row from the top left; each
# name is the next cell's.
sheet = "coins.png"
grid = [8, 8]
names = ["turn_0", "turn_1", "turn_2", "turn_3"]

Patterns#

Paths are from the atlas file's folder. In a pattern, * is any run of a file's name in one folder, and nothing else is special: no **, no ?, no braces, no * in a folder's name. Matches are taken in sorted order; a pattern that matches nothing is E0532, and frost check prints what each pattern matched.

The page#

The pictures go whole onto one page of at most 4096 by 4096, tallest first, shelf by shelf; frames that do not fit are E0530, which says how many do. Nothing is trimmed: a frame's rectangle is its picture's. Each picture's edge pixels are copied once outward, so a frame draws the pixels its picture draws alone: exactly with filter = "nearest"; with "linear" a scaled frame may differ from its picture alone by one step in a few pixels. A sheet is kept as it is.

A sprite on a frame#

With a frame, src_x, src_y, src_w and src_h cut a part of the frame, from its top left, a width or height of 0 being the rest of it; a part that would reach past the frame's edge stops at it, so a sprite never shows its neighbour on the page (and never stretches the frame's edge the way a part past a picture's own edge does). A name the atlas does not have is E0531, which says the three nearest. A sprite with a frame and a Repeat is refused (E0533): a repeat reads the whole page, so a repeating sprite needs a picture of its own. It is refused whichever came first and whenever they meet: at load; when the editor puts a Repeat on a sprite with a frame (world.insert is refused and the world stays as it was); and at the end of the step in which a script spawns such a sprite or a frame is written on a repeating one, by a script or by world.set (the step stops with E0533, shown where the game shows errors, as a picture that was not loaded is with E0420). Until then such a sprite is not drawn at all: never drawn wrong. A Clip writes src_* of the whole picture, so a sprite that plays one leaves frame empty; a script that changes frame animates an atlas's sprite.

Cooked and exported#

frost cook FILE.atlas.toml prints each frame's size and place. The editor reads the same through assets.cooked {path}: the page's size and every frame's {name, x, y, w, h}. An exported game carries each atlas cooked, NAME.atlas.toml.vatl, and not the pictures packed in it.