packages

plot::raster

On this page

The rasterizer behind PNG output. Paths fill by exact area coverage (signed-area accumulation per scanline, as font-rs does), which anti-aliases every edge; strokes become fills (stroke.nabi); markers are drawn once per size and quarter-pixel phase and stamped; text fills the built-in font's outlines. Colours blend in sRGB as browsers do, premultiplied, with straight-alpha output.

Structs

ImageSource

pub struct Image

A rendered image: width x height RGBA pixels, top row first.

nabi
let img = plot::raster::render(try plot::axes().size_px(8.0, 6.0).figure().scene(), 1.0);
assert(img.width == 8 && img.rgba.len() == 8 * 6 * 4);
  • pub width: usize§

    Source
  • pub height: usize§

    Source
  • pub rgba: List<u8>§

    Source
  • pub fn at(self, x: usize, y: usize) -> Color§

    Source

    The pixel at (x, y) as a colour.

    nabi
    let img = plot::raster::render(try plot::axes().size_px(20.0, 10.0).figure().scene(), 1.0);
    assert(img.at(0, 0) == plot::Theme::light().background);
    

Functions

renderSource

pub fn render(s: Scene, scale: f64) -> Image

Paints a scene at scale device pixels per px.

nabi
let s = try plot::line([0, 1], [0, 1]).size_px(50.0, 40.0).figure().scene();
assert(plot::raster::render(s, 2.0).height == 80);