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§

ScriptError

Constants§

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.

Statics§

PRESETS
Built-in presets by id: (id, source).

Functions§

evaluate
Run source and return the graph it built, validated.
library_names
Every function the library defines, as areas.union or draw, sorted: what drawland.d.ts must declare.
preset
The script of the built-in preset id ("city-grain"), if there is one.
preset_ids
The built-in presets’ ids, sorted.