Plotter

Struct Plotter 

Source
pub struct Plotter<P>
where P: Pixel<Chan = Ch8, Alpha = Premultiplied, Gamma = Linear>,
{ /* private fields */ }
Expand description

Plotter for 2D vector paths.

This is a software vector rasterizer featuring anti-aliasing. The plotter contains a raster, which is drawn by fill and stroke calls.

§Example

use footile::{Path2D, Plotter};
use pix::rgb::Rgba8p;
use pix::Raster;

let path = Path2D::default()
    .pen_width(3.0)
    .move_to(50.0, 34.0)
    .cubic_to(4.0, 16.0, 16.0, 28.0, 0.0, 32.0)
    .cubic_to(-16.0, -4.0, -4.0, -16.0, 0.0, -32.0)
    .close()
    .finish();
let mut p = Plotter::new(Raster::with_clear(100, 100));
p.stroke(&path, Rgba8p::new(255, 128, 0, 255));

Implementations§

Source§

impl<P> Plotter<P>
where P: Pixel<Chan = Ch8, Alpha = Premultiplied, Gamma = Linear>,

Source

pub fn new(raster: Raster<P>) -> Self

Create a new plotter.

  • raster Raster to draw.
Source

pub fn width(&self) -> u32

Get width in pixels.

Source

pub fn height(&self) -> u32

Get height in pixels.

Source

pub fn set_tolerance(&mut self, t: f32) -> &mut Self

Set tolerance threshold for curve decomposition.

Source

pub fn set_transform(&mut self, t: Transform<f32>) -> &mut Self

Set the transform.

Source

pub fn set_join(&mut self, js: JoinStyle) -> &mut Self

Set stroke join style.

  • js Join style.
Source

pub fn fill<T>(&mut self, rule: FillRule, ops: T, clr: P) -> &mut Raster<P>
where T: IntoIterator, T::Item: Borrow<PathOp>,

Fill path onto the raster.

  • rule Fill rule.
  • ops PathOp iterator.
  • clr Color to fill.
Source

pub fn stroke<T>(&mut self, ops: T, clr: P) -> &mut Raster<P>
where T: IntoIterator, T::Item: Borrow<PathOp>,

Stroke path onto the raster.

  • ops PathOp iterator.
  • clr Color to stroke.
Source

pub fn raster(&self) -> &Raster<P>

Get a reference to the raster.

Source

pub fn raster_mut(&mut self) -> &mut Raster<P>

Get a mutable reference to the raster.

Source

pub fn into_raster(self) -> Raster<P>

Consume the plotter and get the raster.

Auto Trait Implementations§

§

impl<P> Freeze for Plotter<P>

§

impl<P> RefUnwindSafe for Plotter<P>
where P: RefUnwindSafe,

§

impl<P> Send for Plotter<P>
where P: Send,

§

impl<P> Sync for Plotter<P>
where P: Sync,

§

impl<P> Unpin for Plotter<P>

§

impl<P> UnwindSafe for Plotter<P>
where P: UnwindSafe,

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.