reference
Read a picture the page must match, inspect cropped pixels, grid coordinates and sample colors, then compare the open page's render against it.
Instructions
Reads a reference picture the page should match (a photo, artwork, mockup or screenshot in the project, e.g. refs/01.jpg) at full resolution, in one call and with no page open: crop [left, top, right, bottom] in the picture's pixels, enlarged up to 4× to fit 1280 px, with grid lines every N px labelled in the picture's own pixel coordinates (positions read off it go straight into the next call or the scene), and sample points, each answered as #rrggbb. With the page open, compare: true puts the picture, the page's look (from camera when given) and a difference picture side by side and says what share of pixels differ, overall and in a grid of regions (cells per side, 4 by default), with each sample point's colour on both, or that the canvas aspect is not the picture's. Use it to read a picture the page should match and to check the page against it.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cwd | Yes | The game project's folder. | |
| crop | No | [left, top, right, bottom] in the picture's pixels ([x, y, width, height] is read as such when right < left or bottom < top), trimmed to the picture; the whole picture when left out. With compare: that region of the picture and the same region of the page, enlarged side by side with their differences. | |
| file | Yes | The picture's path, relative to cwd, or the name of a baseline saved with look { save } (compare the page with its earlier look). | |
| game | No | The name the game was opened under with the `open` tool, to act on ("main" by default; a subagent uses its own). | |
| grid | No | Gridline spacing in the picture's pixels (100 on a whole picture, 10 to 50 on a crop); none when left out. | |
| cells | No | Regions per side for compare's differing-share grid (4 by default). | |
| camera | No | For compare: the page's look from this position (looking at lookAt) or from a camera by name, as `look`'s camera; left out, the picture's entry in refs/cameras.json when there is one, else the page's own camera. | |
| sample | No | Points [x, y] in the picture's pixels whose colour to return (the mean of 5 × 5 pixels); with compare, the page's colour at the same point too. | |
| compare | No | Put the open page's look beside the picture with their differences; needs `open` first, and a canvas with the picture's aspect for the pixel comparison. |