Skip to main content

Crate drawland_script

Crate drawland_script 

Source
Expand description

draw.land profiles in JavaScript.

A profile is a script that calls our library (library.js, over the natives below); running it builds the operation graph the engine draws. The script never touches geometry: by the time anything is drawn, the interpreter is gone and only the graph is left.

const bldg = features.osm({ building: true })
const foot = areas.polygons(bldg)
draw({ id: "bldg_fill", from: fills.fill({ in: foot, pattern: "zigzag", spacing: "0.5mm", per: "feature" }) })

Every node remembers the script line that made it, and every error (a syntax error, a wrong argument, a bad reference found by validation) comes back as line N column M: …, the form the web editor underlines.

The sandbox is the bare language plus the library: no network, files, timers or console, no Date or Math.random (the same script always draws the same map), and loops and recursion are capped.

Structs§

Host
What the host lends a run: a place over the one the script’s output gives ((lat, lng): the command line’s --lat/--lng and --address; world answers for it), the styles views can name, and whether the script is TypeScript.
ScriptError

Constants§

LIBRARY
The library’s JavaScript face: a function of the library’s calls (dl) that returns the namespaces a script calls. The Node package runs it too.
LOOP_LIMIT
The most loop iterations one loop may run, and the deepest recursion: a mistaken while (true) ends with an error instead of hanging the page.
RECURSION_LIMIT
SCRIPT_PATH
The name scripts run under; positions in other sources (the library) are not the user’s.

Functions§

evaluate
Run source and return the graph it built, validated. The place is the one its own output gives, and views can name no style.
evaluate_draft
A draft of source’s graph, for a page following a drag: the same graph but with every remap warp left out, since sampling one runs the script’s function hundreds of times. true with it when something was left out, so the page knows to run the script in full once the drag settles.
evaluate_in
Run source with what host lends it.
library_names
Every function the library defines, as areas.union or draw, sorted (properties such as page.width are not calls, and not listed): what drawland.d.ts must declare, read from the library as a script sees it.
run_into
Run source into graph, as more calls to the same graph: how a Python or Rust profile draws a view in a JavaScript style by name. The graph back, and whether the script ran.
strip_types
source without its TypeScript types: the same text where they were blanks, so positions in it are positions in the original (drawland-ts).

Type Aliases§

Styles
Where view(spec, "name") finds the script that draws in style name: the host’s own (the command line reads name.js beside the profile, the web page its presets). Err says why there is none.