packages

plot::scene

On this page

A rendered figure as drawing primitives in px (y down), the one input of every backend. Layout makes it once; SVG writes it, the rasterizer paints it, the terminal approximates it.

Structs

StrokeSource

pub struct Stroke

How a line is drawn.

nabi
let s = try plot::line([0, 1], [0, 1]).figure().scene();
assert(s.items.len() > 0);
  • pub color: Color§

    Source
  • pub width: f64§

    Source
  • pub dash: List<f64>§

    Source

    Dash and gap lengths in px; empty for solid.

  • pub round: bool§

    Source

    Round ends and joins instead of butt ends and miter joins.

RectSource

pub struct Rect

A clip rectangle.

nabi
let r = plot::scene::Rect { x: 1.0, y: 2.0, w: 3.0, h: 4.0 };
assert(r.right() == 4.0 && r.bottom() == 6.0);
  • pub x: f64§

    Source
  • pub y: f64§

    Source
  • pub w: f64§

    Source
  • pub h: f64§

    Source
  • pub fn right(self) -> f64§

    Source

    The right edge.

    nabi
    assert(plot::scene::Rect { x: 1.0, y: 0.0, w: 2.0, h: 1.0 }.right() == 3.0);
    
  • pub fn bottom(self) -> f64§

    Source

    The bottom edge.

    nabi
    assert(plot::scene::Rect { x: 0.0, y: 1.0, w: 1.0, h: 2.0 }.bottom() == 3.0);
    

SceneSource

pub struct Scene

A figure ready for a backend.

nabi
let s = try plot::line([0, 1], [0, 1]).figure().scene();
assert(s.clips.len() >= 2);

Enums

AnchorSource

pub enum Anchor

Where a text item's x is: at its start, middle or end.

nabi
use plot::scene::Anchor;

assert(Anchor::Start != Anchor::End);

ItemSource

pub enum Item

One drawing primitive. clip indexes Scene::clips, 0 for none.

nabi
use plot::scene::Item;

let s = try plot::scatter([0, 1], [0, 1]).figure().scene();
assert(s.items.iter().any(|it| it is Item::Markers));
  • A filled path (nonzero winding).

  • A stroked path.

  • Markers§

    Source

    Markers of one shape centred at (xs[i], ys[i]), sizes[i] px across and filled with fills[i]; a list of one applies to all.

  • Text with its baseline at y, rotated rotate degrees counterclockwise about (x, y).

  • An RGBA image of cols x rows pixels (top row first) stretched over the rectangle, drawn without smoothing.