Qu

capture

Builtin index · Plotting

result = capture("fn", [args...])

Input: "fn", args... · Output: result

What it is

Runs the named drawing function "fn" (string, a function you defined) into a scratch panel, passing along any further positional args..., and keeps what it drew as a value (a "layer"). See Layers, near the top of this chapter.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = capture("fn", [args...])
"fn" stringnot documented yet
args... string, optional, repeatablenot documented yet
result —
Returns a layer value.

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

function sensor()
    circle(0, 0, 0.28, fill = "#4169e1", alpha = 0.9)
    circle(0, 0, 0.44, color = "#4169e1", width = 1.2)
    plot([0, 0], [-0.44, -0.9], color = "#4169e1", width = 1.2)
end function

s = capture("sensor")
stamp(s, 2, 5)
stamp(s, 6, 5, scale = 0.7)
stamp(s, 10, 5, rotate = 180)

not run by the build — this one needs something the repository cannot supply · from plotting

How it works

── layers ────────────────────────────────────────────────── capture("draw_leaf") runs your function into a scratch panel and keeps what it drew, as a VALUE. stamp(l, x, y) puts a transformed copy on the real panel. A value rather than a mode, deliberately: a layer can be passed, returned, held in a list, and duplicated by ordinary assignment, where a stateful recorder with a begin and an end is one more thing to forget to close. It separates WHAT is drawn from WHERE, which is the whole point -- a sensor symbol, a leaf, a bolt described once and placed forty times.

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.