Coldwave Read the docs

drawing#

Part of the scripting reference, written by the engine so it matches your frost. Start with your first game if you are new.

Use when drawing 2D sprites, rectangles or tilemaps, moving a camera, changing colour, layers, rotation or scale.

In a scriptDoes
frame.size()The frame's width and height: [window] size, or the screen's shape for a game that fills (fit = "fill"), as its recording says
placed(entity)Where an entity is in the world: its own Transform composed with its parents' when it is under a thing with a Transform (its own fields are local to that one, and get reads them). Three numbers in 2D, x, y and its angle; seven in 3D, x, y, z and its turn. What a camera that follows a thing under a parent reads. In 2D too

What is drawn#

An entity is drawn when it has a Transform and one or more of Rect, Sprite, Text and Tilemap. These are the components the engine declares; a game declares its own in the project file's [components] table, and scripts read and write both kinds the same way.

ComponentFieldTypeDefaultMeaning
Transformxnumber0The centre of what is drawn, in world units from the left edge
Transformynumber0The centre of what is drawn, in world units from the bottom edge
Rectwnumber1Width in world units
Recthnumber1Height in world units
Rectcolorwhole number0xffffffThe colour as 0xRRGGBB: red, green and blue, two hex digits each. Higher bits are ignored
Rectlayerwhole number0Drawing order: a higher layer is drawn over a lower one
Spriteimagetext""The picture: a PNG file's path, relative to the project file, or an atlas's (a .atlas.toml file). Empty draws nothing
Spriteframetext""The frame to show of an atlas image (see Atlases); src_* then cut a part of it, stopping at its edge. Unknown: E0531
Spritewnumber0Width in world units. 0 is the width of the part shown, one unit to an image pixel
Spritehnumber0Height in world units. 0 is the height of the part shown
Spritesrc_xwhole number0The left edge of the part shown, in image pixels from the image's left
Spritesrc_ywhole number0The top edge of the part shown, in image pixels from the image's top
Spritesrc_wwhole number0The width of the part shown, in image pixels. 0 is everything to the right of src_x
Spritesrc_hwhole number0The height of the part shown, in image pixels. 0 is everything below src_y
Spritetintwhole number0xffffffA colour as 0xRRGGBB that every pixel is multiplied by. White leaves the picture as it is
Spriteflip_xtrue or falsefalseMirror the picture left to right
Spriteflip_ytrue or falsefalseMirror the picture top to bottom
Spritelayerwhole number0Drawing order, shared with Rect and Text
Tilemapimagetext""The tileset: a PNG file's path. It is cut into cells, counted along its rows from the top-left
Tilemaptilewhole number16The width of a cell in image pixels, and of a tile in world units
Tilemaptile_hwhole number0The height of both. 0: the same as tile, a square
Tilemaplegendtext""Which character draws which cell: the first character the first cell, and so on. A character that is not here draws nothing
Tilemaprowstext""The map: one line of characters a row of tiles, the top row first
Tilemaplayerwhole number0Drawing order, shared with the others
Camerazoomnumber1How many frame units one world unit covers. Not above 0 is 1
Passoftext""The pass's name in [render]: bright, add, panini, aces: these read numbers (frost check warns of another, W0457)
Passthresholdnumber0.6Its threshold, as the pass's own
Passstrengthnumber1Bloom strength, Panini distance or ACES exposure
ScreenKeeps the entity in place on the frame: the camera does not move it
Opacityalphanumber1How much of what the entity draws covers what is behind: 1 all of it, 0.5 half. Not above 0 hides the entity: nothing is drawn for it. Above 1 is 1
Tintcolorwhole number0xffffffThe colour multiplied by; white changes nothing
Rotationanglenumber0How far the entity's rectangle and sprite are turned about Transform, in degrees, anticlockwise
Pivotxnumber0The point of the entity's rectangle and sprite that stands on Transform, in units right of their centre
Pivotynumber0The same point, in units above their centre
Blendaddnumber1How much the entity is added to what is behind it instead of covering it: 1 all light, 0 the usual covering. Outside 0 to 1 is the nearer end
Sliceleftwhole number0How many pixels at the left of the sprite's picture are a border that keeps its size
Slicerightwhole number0The same at the right
Slicetopwhole number0The same at the top
Slicebottomwhole number0The same at the bottom
YSortfootnumber0The entity sorts by height within its layer: this is where its feet are, in units above Transform (below is negative)
Scalexnumber1How many times wider everything the entity draws is. Below 0 mirrors it
Scaleynumber1How many times taller
Shapekindtext"ring""ring": a band inside the ellipse the rectangle holds; "disc": all of it; "line": a line along the rectangle's width, through its middle
Shapewnumber1The rectangle's width in world units: a circle's diameter
Shapehnumber1Its height. Unequal to w, a ring is an ellipse
Shapewidthnumber1How thick a ring's band or a line is, in world units
Shapefromnumber0Where a ring or a disc starts, in degrees anticlockwise from the right: with to below a whole turn on, a ring is an arc and a disc a wedge
Shapetonumber360Where it ends
Shapedashnumber0Dashes this long with gaps as long, round a ring or along a line, in world units. 0: unbroken
Shapecolorwhole number0xffffffThe colour as 0xRRGGBB
Shapelayerwhole number0Drawing order, shared with the others
RepeatRepeats the sprite's picture where its part (src_x to src_x + src_w, and down) runs past the picture's edge, instead of stretching the edge: a scrolling belt, a tiled floor. Move src_x to scroll it. The whole picture repeats, not a frame of it
  • Axes. A game sees its whole frame, with the origin at the bottom-left corner, x growing to the right and y growing up, and one world unit to one pixel of the frame ([window] size, 960 by 540 when left out).

  • Anchor. Transform is the centre of a rectangle and of a sprite: each covers x - w/2 to x + w/2 and y - h/2 to y + h/2. For text it is the middle of the block's height, and align says where along a line it is. There is no scale.

  • Order. Lower layers first; layers may be negative. Within one layer the order is by entity slot, which a game does not choose: give things that overlap different layers. An entity with several of the three is drawn rectangle, sprite, then text.

  • Colour. sRGB bytes, written to the picture unchanged: 0xf2364b reads back from a captured frame as exactly (0xf2, 0x36, 0x4b). A picture's own alpha is respected. A colour has no alpha of its own: see-through is the entity's Opacity.

  • Rotation. An entity with Rotation draws its rectangle and its sprite turned by angle about their centre: 90 stands a bar on end, a negative angle turns clockwise. Text and tilemaps are not turned. To point one thing at another: set(e, "Rotation", "angle", math.deg(math.atan2(dy, dx))) for a picture drawn facing right. A Collider on the entity is turned with it (see Physics), and physics gives a body that turns a Rotation of its own; a script that tests overlaps itself decides what a turned thing touches. Like Opacity, a script cannot add it later: give Rotation = {} in the scene file or when spawning. the engine's turn example draws the same picture, pixel for pixel, on Metal and in both web builds; a turned edge falls between pixels, so that is measured there and not promised for every graphics adapter.

  • Shadow. An entity with Shadow draws its text twice: first a copy in the shadow's colour, moved by x and y, then the text over it, so a banner stands off whatever is behind it without a second entity kept in step. It does nothing for a rectangle, a sprite or a tilemap. Give it in the scene file or when spawning: Shadow = {} is black, 2 right and 2 down.

  • Pivot. A rectangle or a sprite stands with its centre on Transform. With Pivot another point of it does, and Rotation turns it about that point: Pivot = { x = -10 } on a bar 20 long holds it by its left end, like an arm at the shoulder or a door at its hinge. The point is counted on the picture as drawn before it is turned. It is in units, not a share of the size, so it does not follow a size that changes: for a bar that empties towards one end, hold it by that end with Pivot once and shrink it with Scale.x (0 to 1), rather than writing Rect.w and Pivot.x together.

  • Blend. An entity with Blend is added to what is behind it: its colours make the picture lighter and hide nothing, which is how a glow, a flame, a spark or a beam of light is drawn. Black adds nothing, so a picture of light on black needs no alpha. add between 0 and 1 mixes adding with covering; Opacity still scales how much is drawn. Draw order is unchanged: layers, then entities. A tint can only darken a picture. To flash a sprite bright when it is hit, spawn a second entity on it with the same Sprite and Blend = {} for a few steps: the picture is added to itself, towards white. It is not a flat white shape.

  • Scale. An entity with Scale draws everything it draws that many times larger, across (x) and up (y), about the point that stands on Transform: a rectangle or a sprite about its centre or its Pivot, a text from where it starts, a tilemap from its corner. Below 0 mirrors. It is how a thing pops, squashes or breathes without its w and h being touched: set(coin, "Scale", "x", 1.3).

  • Slice. A sprite with Slice is cut in nine: the four corners are drawn one unit a pixel, the edges stretch along their length and the middle fills the rest. One small picture of a frame then makes a panel, a button or a speech bubble of any w and h. src_* still picks the part of a sheet, and flips and Rotation work as on any sprite.

  • YSort. In a game seen from above, who is in front depends on who stands lower. Entities with YSort in one layer are drawn from the highest to the lowest, by Transform.y + foot, after the layer's entities that have none (the floor). Give a tall sprite its feet: YSort = { foot = -12 }.

  • Opacity. Everything drawn (rectangle, sprite, text, tilemap, 3D Mesh) uses its picture's alpha times alpha times every ancestor's Opacity (Parent): one root write fades a figure's parts. Below 1, 3D things join the see-through ones after opaque things, farthest first, revealing what's behind; shadows stay whole. Hide with set(e, "Opacity", "alpha", 0); restore to 1. Hidden entities cost nothing to draw but still move, collide and can be found. Without Opacity, an entity draws in full. Scripts cannot add it later: give anything that will fade or hide Opacity = {} in its scene or when spawning.

  • Numbers. A number field is a 32-bit float. A scene file or a script may give it any number and gets the nearest 32-bit float back (0.1 reads back as 0.10000000149011612). A whole-number field holds 32 bits with a sign and refuses a fraction.

  • Camera. With no Camera the world and the frame are the same: the origin is the frame's bottom-left corner. An entity with a Camera and a Transform is the camera: its Transform is the world point at the middle of the frame, and zoom scales the world about that point. With several, the one in the lowest entity slot is used. The camera is world state like any other: a script moves it with set. The renderer does not round: for sharp pixel art keep the camera, and what moves, on whole units.

  • Screen. A score, a title or a backdrop that must stay put has Screen: its Transform is then in frame units from the frame's bottom-left corner, whatever the camera does. Layers order world and screen entities together.

  • An entity without a Transform is not drawn. A rectangle or sprite with a width or height of zero draws nothing.

In a scene file:

TOML
[player]
Transform = { x = 120, y = 118 }
Rect = { w = 36, h = 36, color = 0xf2364b, layer = 2 }

[coin]
Transform = { x = 300, y = 200 }
Sprite = { image = "art/coins.png", src_w = 16, src_h = 16, w = 32, h = 32, layer = 3 }

[score]
Transform = { x = 480, y = 500 }
Text = { text = "0", size = 4, color = 0xd9b98a, layer = 9 }

Sprites#

A sprite's picture is a PNG file named by its path, relative to the project file. Every sprite of one picture shares it. Animation is a script changing src_x and src_y to another part of one sheet. Pictures are sampled the way the project file's [window] filter says, the same for all of them: "nearest" for pixel art, which is the default, or "linear".

Atlases#

NAME.atlas.toml puts pictures on one page of at most 4096 by 4096, each a frame with a name: pictures = ["hero/*.png"] packs the PNG files its patterns match (* is any run of a file's name in one folder; hero/run_0.png is the frame run_0), or sheet = "coins.png", grid = [8, 8], names = [...] cuts one sheet. Errors: E0530 frames that do not fit, E0532 a pattern that matches nothing, E0533 a frame on a sprite with a Repeat. More: docs/atlases.md.

Tilemaps#

A tilemap draws a level from text. Its Transform is the bottom-left corner of the grid (not its centre): the last line of rows is the bottom row, and each character is one square of tile units, or tile wide and tile_h high when tile_h is set (bricks: tile = 16, tile_h = 8).

TOML
[ground]
Transform = { x = 0, y = 0 }

[ground.Tilemap]
image = "tiles.png"
tile = 16
legend = "#=^"
rows = """
..........
....C.....
...===..^.
##########
"""

Here # draws the first cell of tiles.png, = the second and ^ the third. . and C are not in the legend, so they draw nothing: a game's script can read rows (it is a field like any other) and put a coin where it finds a C, test what character is under a foot, or change a character with set to break a block. Lines may differ in length. The legend and the rows are ASCII. Only the tiles the camera sees are sent to the device, and a whole map is one draw call.

Cost#

The whole world goes to the device as one batch. Rectangles and text cost nothing extra in draw calls beyond a change of picture: quads that follow each other in drawing order and share a picture, or have none, are one draw call. The frames of one atlas are one picture; other pictures interleaved on one layer cost a call each.

Generated from Coldwave 0.0.1 r289, 2026-11-30 by the binary itself: do not edit by hand.