Struct PlottersDrawingArea

Source
pub struct PlottersDrawingArea<'a> { /* private fields */ }
Expand description

An object that can be used as a drawing area by the plotters library.

This is needed because direct 2D needs to wrap the drawing command between a begin_draw and end_draw call but it is impossible to do that within the DrawingBackend trait.

Implementations§

Methods from Deref<Target = DrawingArea<&'a PlottersBackend, Shift>>§

Source

pub fn get_base_pixel(&self) -> (i32, i32)

Get the left upper conner of this area in the drawing backend

Source

pub fn strip_coord_spec(&self) -> DrawingArea<DB, Shift>

Strip the applied coordinate specification and returns a shift-based drawing area

Source

pub fn use_screen_coord(&self) -> DrawingArea<DB, Shift>

Strip the applied coordinate specification and returns a drawing area

Source

pub fn dim_in_pixel(&self) -> (u32, u32)

Get the area dimension in pixel

Source

pub fn relative_to_height(&self, p: f64) -> f64

Compute the relative size based on the drawing area’s height

Source

pub fn relative_to_width(&self, p: f64) -> f64

Compute the relative size based on the drawing area’s width

Source

pub fn get_pixel_range(&self) -> (Range<i32>, Range<i32>)

Get the pixel range of this area

Source

pub fn fill<ColorType>( &self, color: &ColorType, ) -> Result<(), DrawingAreaErrorKind<<DB as DrawingBackend>::ErrorType>>
where ColorType: Color,

Fill the entire drawing area with a color

Source

pub fn draw_pixel<ColorType>( &self, pos: <CT as CoordTranslate>::From, color: &ColorType, ) -> Result<(), DrawingAreaErrorKind<<DB as DrawingBackend>::ErrorType>>
where ColorType: Color,

Draw a single pixel

Source

pub fn present( &self, ) -> Result<(), DrawingAreaErrorKind<<DB as DrawingBackend>::ErrorType>>

Present all the pending changes to the backend

Source

pub fn draw<'a, E, B>( &self, element: &'a E, ) -> Result<(), DrawingAreaErrorKind<<DB as DrawingBackend>::ErrorType>>
where B: CoordMapper, &'a E: PointCollection<'a, <CT as CoordTranslate>::From, B>, E: Drawable<DB, B>,

Draw an high-level element

Source

pub fn map_coordinate(&self, coord: &<CT as CoordTranslate>::From) -> (i32, i32)

Map coordinate to the backend coordinate

Source

pub fn estimate_text_size( &self, text: &str, style: &TextStyle<'_>, ) -> Result<(u32, u32), DrawingAreaErrorKind<<DB as DrawingBackend>::ErrorType>>

Estimate the dimension of the text if drawn on this drawing area. We can’t get this directly from the font, since the drawing backend may or may not follows the font configuration. In terminal, the font family will be dropped. So the size of the text is drawing area related.

  • text: The text we want to estimate
  • font: The font spec in which we want to draw the text
  • return: The size of the text if drawn on this area
Source

pub fn apply_coord_spec<CT>(&self, coord_spec: CT) -> DrawingArea<DB, CT>
where CT: CoordTranslate,

Apply a new coord transformation object and returns a new drawing area

Source

pub fn margin<ST, SB, SL, SR>( &self, top: ST, bottom: SB, left: SL, right: SR, ) -> DrawingArea<DB, Shift>
where ST: SizeDesc, SB: SizeDesc, SL: SizeDesc, SR: SizeDesc,

Create a margin for the given drawing area and returns the new drawing area

Source

pub fn split_vertically<S>( &self, y: S, ) -> (DrawingArea<DB, Shift>, DrawingArea<DB, Shift>)
where S: SizeDesc,

Split the drawing area vertically

Source

pub fn split_horizontally<S>( &self, x: S, ) -> (DrawingArea<DB, Shift>, DrawingArea<DB, Shift>)
where S: SizeDesc,

Split the drawing area horizontally

Source

pub fn split_evenly(&self, _: (usize, usize)) -> Vec<DrawingArea<DB, Shift>>

Split the drawing area evenly

Source

pub fn split_by_breakpoints<XSize, YSize, XS, YS>( &self, xs: XS, ys: YS, ) -> Vec<DrawingArea<DB, Shift>>
where XSize: SizeDesc, YSize: SizeDesc, XS: AsRef<[XSize]>, YS: AsRef<[YSize]>,

Split the drawing area into a grid with specified breakpoints on both X axis and Y axis

Source

pub fn titled<'a, S>( &self, text: &str, style: S, ) -> Result<DrawingArea<DB, Shift>, DrawingAreaErrorKind<<DB as DrawingBackend>::ErrorType>>
where S: Into<TextStyle<'a>>,

Draw a title of the drawing area and return the remaining drawing area

Source

pub fn draw_text( &self, text: &str, style: &TextStyle<'_>, pos: (i32, i32), ) -> Result<(), DrawingAreaErrorKind<<DB as DrawingBackend>::ErrorType>>

Draw text on the drawing area

Source

pub fn as_coord_spec(&self) -> &CT

Returns the coordinates by reference

Trait Implementations§

Source§

impl<'a> Drop for PlottersDrawingArea<'a>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<'a> Deref for PlottersDrawingArea<'a>

Source§

type Target = DrawingArea<&'a PlottersBackend, Shift>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

§

impl<'a> Freeze for PlottersDrawingArea<'a>

§

impl<'a> !RefUnwindSafe for PlottersDrawingArea<'a>

§

impl<'a> !Send for PlottersDrawingArea<'a>

§

impl<'a> !Sync for PlottersDrawingArea<'a>

§

impl<'a> Unpin for PlottersDrawingArea<'a>

§

impl<'a> !UnwindSafe for PlottersDrawingArea<'a>

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.