Skip to main content

Module api

Module api 

Source
Expand description

The library for Rust: the same functions a JavaScript or Python profile calls, as methods. Handles are typed (Features, Area, Lines); options are objects (crate::obj!), with the keys the library documents (drawland.d.ts, the reference at draw.land/docs).

use drawland_graph::{obj, Graph};

let mut g = Graph::new(Some((37.8053, -122.4436)));
g.output(obj! { "width" => "6in", "height" => "4in", "scale" => "1:10000" })?;
let water = g.features().tiles(&["water"])?;
let sea = g.areas().polygons(&water)?;
let waves = g.fills().fill(obj! { "in" => &sea, "pattern" => "waves", "spacing" => "0.8mm" })?;
g.draw(obj! { "id" => "water", "from" => &waves })?;
let centre = g.world().center()?;
assert!((centre.0 - 37.8053).abs() < 1e-9);

Structs§

Area
An area (areas.*, page.frame, a module’s area).
AreasApi
areas.*: shapes on the page.
ComposeApi
compose.*: stacking, masks, and the plotter’s steps.
Features
A set of map features (features.*).
FeaturesApi
features.*: what to read from the map.
FillsApi
fills.*: patterns inside areas.
Lines
Lines (lines.*, fills.fill, a module’s output).
LinesApi
lines.*: strokes.
Module
modules.labels(…) or a graticule: parts made when asked for with Module::area, [Module::part]…
ModulesApi
modules.*: roads, labels, graticules.
PageApi
page.*: the paper, in mm from its top left.
Roads
modules.roads(…): what the roads module publishes.
WorldApi
world.*: the ground under the page.