Checks and helpers
Check a design, preview it, and compute numbers, text sizes, paths and positions instead of guessing.
check_layout
Layout problems after layout: text over other text, layers cut off by a clipping frame or running off the canvas, text too small for the size the design is seen at, and text with too little contrast on what is behind it.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
page_id | string | Yes | — | The page. |
display_width | number | No | See note | How wide the design is seen on screen, px; sets the smallest readable text and what counts as large text. |
margin | number | [l, t, r, b] | No | — | Report layers whose painted extent, strokes included, crosses this content margin. |
allow_bleed | string[] | No | — | Layers (and their children) that run past the page or their clipping frame on purpose. |
ignore | [string, string][] | No | — | Pairs of layer ids whose overlap is on purpose. |
craft | boolean | No | false | Run every craft check: orphan, near_touch, raw_hex, empty_frame, chrome_drift, sliver, empty_band (all info). |
checks | string[] | No | — | Craft checks to run, by name. |
skip | string[] | No | — | Issue kinds that are on purpose, left out of the report so ok can be true (empty_first_frame for a reveal at the end, small_text for a fine-print line). |
display_width defaults to 400 for 1080-wide square or portrait posts, 1280 for 1920 × 1080, else the page width.
- Returns: Each issue with the layers it names and a severity,
errororinfo(info is often on purpose).
Text cut by max_lines is reported as truncated (info). Text that shrink_to_fit already fits is not reported as overflow. off_page and near_touch judge a cut-out by its visible box, not its whole image.
It reads laid-out boxes, not pixels, and does not find text too long for a fixed box: confirm issues with render_design, and test the longest copy by rendering it.
render_design
A PNG of the page as it will export, for the agent to look at.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
page_id | string | Yes | — | The page (or give page_ids). |
page_ids | string[] | No | — | Up to 5 pages to draw with the same settings, each labelled with its page. Each page is charged as its own render. |
max_size | integer | No | 800 | Longest side in px, at most 800. |
sizes | integer[] | No | — | 1 to 4 pictures in one call, each at most 800 px, in place of max_size. |
node_id | string | No | — | Zoom into a layer: its laid-out box grown by padding. |
padding | number | No | 24 | Space around node_id's box, in page px. |
region | [x, y, w, h] | No | — | Zoom into this part of the page, in page px. |
node_ids | string[] | No | — | Zoom into several layers, one picture each, grown by padding. |
regions | [x, y, w, h][] | No | — | Several close-ups in one call, in page px. With node_ids, at most 4 pictures, each max_size. |
time | number | No | 0 | The second of the animation to show. |
hide | string[] | No | — | Hide these layers for this picture only. |
only | string[] | No | — | Show only these layers, with their children. |
modes | string[] | No | — | 1 to 3 of "color", "grey" and "silhouette", one picture each, in place of mode. |
mode | string | No | "color" | "color", "grey" for a value study, or "silhouette" to judge a shape (with only). |
sample_points | [x, y][] | No | — | Up to 64 points, in page px, whose colour to read, returned as {x, y, hex, alpha}. Not together with regions or node_ids. |
- Returns: The PNG, with a faint repeating "Kalpana preview" mark that is never in the design, its exports or batch renders.
sample_pointsread the design's own colours.
calculate
Exact arithmetic: + - * / % ^, parentheses, pi, trigonometry in radians (rad() and deg() convert), sqrt, abs, min, max, round, floor, ceil, clamp, lerp, pow, hypot, atan2, ln, log10, exp.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
expression | string | One of these | — | One expression, e.g. "1080 / 3 - 24" or "sin(rad(30)) * r". |
expressions | {name, expression}[] | One of these | — | Several named expressions; later ones may use earlier names. |
variables | Record<string, number> | No | {} | Values for names used in the expressions. |
series | object | No | — | Evaluate expression over a range: variable, from, to and steps (values = steps + 1, at most 2000). |
measure_text
The real size of text as the renderer lays it out, or the largest size that fits a box.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
text | string | No | "" | The text to measure (or give texts or runs). |
texts | string[] | No | — | Measure many texts in one call, with the same font, size and width. |
runs | text run[] | No | — | Text in differently styled runs, as create_layers takes them, in place of text. |
font_family, font_style | string | No | — | The font, e.g. "Bold" for the style. |
font_size | number | No | — | Measure at this size, px. |
width | number | No | One line | Wrap within this width, px. |
fit_height | number | No | — | Find the largest size in [min_size, max_size] whose text fits width × fit_height. |
min_size, max_size | number | No | — | The range fit_height searches. |
line_height, letter_spacing | number | string | No | — | As create_layers takes them. |
wrap | string | No | — | "normal", "balance" or "pretty". |
min_last_line_words | integer | No | — | Fewest words a wrapped paragraph may end on. |
page_id, layer_id | string | No | — | Measure a text layer of a page as it is set; font_size and width then try other values. |
pack | object | No | — | With texts: lay them out as chips in rows with no overlaps. x, y, width (required), gap ([16, 16]), padding ([24, 12]), align (left, center, right). |
- Returns: Each line and its width, the height, and whether the last line is a widow; with
fit_height, the size that fits; withpack, each chip's box ready forcreate_layers.
shape_path
Exact SVG path data for a shape, with the box it sits in. Angles are degrees, 0 at twelve o'clock, clockwise.
kind | Fields | Gives |
|---|---|---|
arc | radius, start, end | An open arc for a stroke, such as a gauge track. |
sector | radius, start, end, inner_radius (0) | A filled wedge; with inner_radius, a ring segment. |
ring | radius, inner_radius | A circle with a hole. |
polygon | sides, radius, corner (0) | A regular polygon with rounded corners. |
star | points, radius, inner_ratio (0.5), corner (0) | A star. |
spiral | radius, turns (3) | An Archimedean spiral. |
wave | width, amplitude, wavelength, form (sine, zigzag, square) | A wave across width. |
gear | teeth, radius, depth | A cog. |
arrow | from, to, bend (0), head (12) | An arrow between two points; the result says where to place it. |
blob | radius, points (6), wobble (0.3), seed (0) | An organic blob; the same seed gives the same blob. |
text_arc | radius, position (top or bottom), sweep (180) | An arc for text_path: curved badge text, upright at the top or bottom of a circle. sweep is its angle in degrees, above 0 and at most 360. Text on the bottom arc stands inside it. |
burst | radius, points, inner_ratio, jitter (0 to 1), seed (0), aspect (1) | A sale-badge burst of jagged spikes; the same seed gives the same burst. |
points | points ([x, y][]), smooth, closed | A line through your points. |
function | expression (in x), x_from, x_to, width, height, samples (200), y_min, y_max | The graph of y = f(x), scaled into the box. |
outline | paths, width, join, cap | The filled outline of a stroke along paths. |
combine | paths, op (union, intersect, subtract, exclude) | Paths combined in order. |
gap | a, b (path data lists) | The smallest gap between two shapes; 0 when they overlap. |
layer_gap | page_id, a, b (layer ids) | The smallest gap between two placed layers. |
- Returns:
paths,widthandheightfor avectorlayer increate_layers.
place_items
Where to put N items, with each centre, the top-left for an item of item_size, and the rotation that faces along the layout. Free.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
count | integer | Yes | — | How many places. |
layout | object | Yes | — | The layout, by kind: circle (center, radius, start 0 = top), arc (center, radius, start, end), grid (origin, columns, cell, gap), line (from, to) or path (points, closed). |
item_size | [w, h] | No | — | The items' size, to also get each top-left x/y. |
Updated 5 Nov 2026