Skip to main content

Graph

Struct Graph 

Source
pub struct Graph {
    pub at: Option<At>,
    /* private fields */
}
Expand description

A draw.land graph, built a call at a time.

The library’s functions are Graph::call by name ("areas.union"), as JavaScript and Python call them, or the typed methods of crate::api for Rust. Graph::finish gives the graph the engine draws.

Fields§

§at: Option<At>

Where in the script the call being made is, for the graph’s nodes and for errors: set by the caller before each call.

Implementations§

Source§

impl Graph

Source

pub fn features(&mut self) -> FeaturesApi<'_>

Source

pub fn areas(&mut self) -> AreasApi<'_>

Source

pub fn lines(&mut self) -> LinesApi<'_>

Source

pub fn fills(&mut self) -> FillsApi<'_>

Source

pub fn modules(&mut self) -> ModulesApi<'_>

Source

pub fn compose(&mut self) -> ComposeApi<'_>

Source

pub fn page(&mut self) -> PageApi<'_>

Source

pub fn world(&mut self) -> WorldApi<'_>

Source

pub fn output(&mut self, spec: Obj) -> Result<()>

Where the map is and on what paper: { lat, lng, width, height, scale, bearing, projection, padding, slices, warp, tileZoom }. A remap warp is a function of page points: Graph::output_remap.

Source

pub fn output_remap( &mut self, spec: Obj, remaps: &mut [&mut dyn FnMut(&mut Graph, [f64; 2]) -> Result<[f64; 2]>], ) -> Result<()>

output with remaps[i] the function of the i-th remap warp in spec.warp (written { "remap": true, "grid": 64 }): each runs on a grid of page points, and may read the ground under one with g.page().to_world(p) (through the warps before it).

Source

pub fn title(&mut self, text: &str) -> Result<()>

The map’s title, for the SVG and the files.

Source

pub fn draw(&mut self, spec: Obj) -> Result<String>

Draw lines as a group (a pen): { id, from, stroke }. Its group id.

Source

pub fn view( &mut self, spec: Obj, style: impl FnOnce(&mut Graph) -> Result<()>, ) -> Result<String>

Another place drawn into a rectangle of the page: { id, at, size, lat, lng, scale, … }, its graph built by style. Its id.

Source§

impl Graph

Source

pub fn new(place: Option<(f64, f64)>) -> Graph

An empty graph. place ((lat, lng)) goes over whatever place the output asks: world answers for it.

Source

pub fn draft(place: Option<(f64, f64)>) -> Graph

A draft graph, for a page following a drag: output leaves its remap warps out, since sampling one runs a function hundreds of times. Graph::drafted says whether one was.

Source

pub fn drafted(&self) -> bool

Whether a draft left a remap out.

Source

pub fn wanted_address(&self) -> Option<&str>

The address the script needed coordinates for, if it asked world about an output that names only one.

Source

pub fn error(&self, message: impl Into<String>) -> Error

An error at the call being made.

Source

pub fn current_output(&self, asked: &str) -> Result<OutputSpec>

The output page and world describe: the script’s own, or inside a view whose style never called output, the view’s keys.

Source

pub fn frame(&mut self, asked: &str) -> Result<Frame>

The frame world and the conversions answer from, worked out once per output.

Source

pub fn view_begin(&mut self, spec: &Arg) -> Result<()>

view({ … }, style) begins: the calls until Graph::view_end build the view’s own graph.

Source

pub fn view_end(&mut self, ok: bool) -> Result<Arg>

The view’s graph is done: it joins the page’s views (ok), or is dropped (its style failed). Its id.

Source

pub fn view_id(&self) -> Option<&str>

The id of the view being built, if any.

Source

pub fn finish(self) -> Result<Grammar>

The graph built: validated, ready for the engine.

Source§

impl Graph

Source

pub fn call(&mut self, name: &str, args: &[Arg]) -> Result<Arg>

Call the library’s function name ("areas.union") with args.

Source

pub fn get_property(&mut self, name: &str) -> Result<Arg>

The value of page.width, world.center and the like.

Source

pub fn get(&mut self, of: &Arg, part: &str) -> Result<Arg>

A module’s part made when it is first asked for: graticule.keys, labels.area, a label rule’s lines. The same part every time.

Source

pub fn parts(of: &Lazy) -> Vec<String>

The parts a lazy module part has, for a binding to expose.

Source

pub fn output_begin(&mut self, spec: &Obj) -> Result<bool>

output with its remap warps still to sample: the output set with none, and whether to sample them (not in a draft, which leaves them out and keeps the others).

Source

pub fn output_warps(&mut self, done: &[Arg]) -> Result<()>

The warps done so far set on the output, so page.toWorld answers through them while the next remap is sampled.

Source

pub fn remap_grid( &self, warp: &Obj, n: usize, ) -> Result<(usize, usize, Vec<[f64; 2]>)>

The page points the remap warp at n (its { remap, grid }) is sampled at: (grid + 1)² of them, row by row.

Source

pub fn remap_mesh( &self, n: usize, columns: usize, rows: usize, points: &[[f64; 2]], went: &[Arg], ) -> Result<Arg>

The remap warp at n as the engine draws it: a mesh of where each sampled point went. went[i] is what the function gave for points[i].

Trait Implementations§

Source§

impl Default for Graph

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Forget for Graph

§

impl Freeze for Graph
where *const u8 is !null: Freeze, PhantomData<Builder>: Freeze, PhantomData<u8>: Freeze,

§

impl Move for Graph

§

impl RefUnwindSafe for Graph

§

impl Send for Graph
where RawVecInner: Send, RawTable<usize>: Send, BoxRaw<Op>: Send, NodeRef<Owned, String, Value, LeafOrInternal>: Send, BoxRaw<(String, Value)>: Send, NodeRef<Owned, String, Name, LeafOrInternal>: Send, BoxRaw<(String, Name)>: Send, NodeRef<Owned, String, RoadClassSpec, LeafOrInternal>: Send, BoxRaw<(String, RoadClassSpec)>: Send, &'static str: Send, BoxRaw<Expr>: Send, Arc<Mutex<HashMap<String, Option<Look>>>>: Send, BoxRaw<Grammar>: Send, BoxRaw<Proj>: Send, RawTable<(String, Arg)>: Send,

§

impl Sync for Graph
where RawVecInner: Sync, RawTable<usize>: Sync, BoxRaw<Op>: Sync, NodeRef<Owned, String, Value, LeafOrInternal>: Sync, BoxRaw<(String, Value)>: Sync, NodeRef<Owned, String, Name, LeafOrInternal>: Sync, BoxRaw<(String, Name)>: Sync, NodeRef<Owned, String, RoadClassSpec, LeafOrInternal>: Sync, BoxRaw<(String, RoadClassSpec)>: Sync, BoxRaw<Expr>: Sync, Arc<Mutex<HashMap<String, Option<Look>>>>: Sync, BoxRaw<Grammar>: Sync, BoxRaw<Proj>: Sync, RawTable<(String, Arg)>: Sync,

§

impl Unpin for Graph
where *const u8 is !null: Unpin, Box<Op>: Unpin, *const LeafNode<String, Value> is !null: Unpin, Box<(String, Value)>: Unpin, *const LeafNode<String, Name> is !null: Unpin, Box<(String, Name)>: Unpin, *const LeafNode<String, RoadClassSpec> is !null: Unpin, Box<(String, RoadClassSpec)>: Unpin, &'static str: Unpin, Box<Expr>: Unpin, Arc<Mutex<HashMap<String, Option<Look>>>>: Unpin, Box<Grammar>: Unpin, Box<Proj>: Unpin,

§

impl UnsafeUnpin for Graph

§

impl UnwindSafe for Graph

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool