Skip to main content

Module frame_png

Module frame_png 

Source
Expand description

frame-png: renders a frame of a game in the test Harness to a PNG without a window, for looking at a skin, a picture or a mockup. Never a gate: snapshots stay text.

The command plays a Script of keys, controller buttons, actions by name and waits in the game’s Harness (shuyi_platform::script‘s, the one the live link and the capture plans play), which the game’s GameTools::frame starts with the game’s own options, and writes the picture the game paints of it. A game paints a frame with Painter, or, for a one-bit screen, with the one-bit renderer and one_bit_picture. With --target <id>, a target whose display is black and white gets the picture its device shows (GameTools::frame_one_bit: the frame drawn in its roles’ patterns, ADR-0008 §4). With --debug <channels>, the debug view’s channels are on from the start (a Step::Debug first in the script, ADR-0085): the picture shows what a person sees with the view on.

Painter decodes a game’s font atlas and images from PNG and paints with the raster, shuyi_ui::frame::raster: the reference picture of a frame, which shuyi-app must match. Its module docs say what it draws.

Structs§

Image
An image’s pixels: four bytes each (red, green, blue, alpha), row by row from the top.
Options
The command’s arguments.
Painter
The raster’s raster::Painter, with its font atlas and images decoded from PNG files, ready to render any number of frames (each image is decoded once).
Script
Steps played in order.
Shot
What a game shows of a frame. Build it with Shot::new (ADR-0039).

Enums§

Step
One step of a script, played in the order written.

Constants§

MAX_SCALE
Largest --scale.

Functions§

check
Whether the Harness can play every step of script: each step (Script::check), and waits of at most MAX_WAIT seconds. An error names the step.
decode_image
Decodes PNG file png.
one_bit_picture
frame as a black and white picture, each pixel scale × scale.
parse_args
Parses frame-png’s arguments, the game’s options among them, checking key and button names and waits up front (check) so a typo is an error, not a Harness panic.
parse_step
Reads the script flag flag with its value value, if it is one: --keys (or --script), --pad, --act, --wait or --crank. A step no player can play (Step::check) is an error, not a panic later. The longest wait is the player’s to check (the Harness’s with check), and an action’s name is looked up in the game’s keymap.
run
Runs the command: the game plays the script and paints the frame, as the display of target (the profile of Options::target) shows it, which is written under root (if out is relative); returns what to print.
usage
The usage text, with command as the tool’s name and the game’s own options and notes.