Struct native_windows_gui::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
sourceimpl<'a> PlottersDrawingArea<'a>
impl<'a> PlottersDrawingArea<'a>
pub fn new(
inner: &'a Plotters
) -> Result<PlottersDrawingArea<'a>, PlottersError>
Methods from Deref<Target = DrawingArea<&'a PlottersBackend, Shift>>
sourcepub fn draw_mesh<DrawFunc, YH, XH>(
&self,
draw_func: DrawFunc,
y_count_max: YH,
x_count_max: XH
) -> Result<(), DrawingAreaErrorKind<<DB as DrawingBackend>::ErrorType>>where
YH: KeyPointHint,
XH: KeyPointHint,
DrawFunc: FnMut(&mut DB, MeshLine<'_, X, Y>) -> Result<(), DrawingErrorKind<<DB as DrawingBackend>::ErrorType>>,
pub fn draw_mesh<DrawFunc, YH, XH>(
&self,
draw_func: DrawFunc,
y_count_max: YH,
x_count_max: XH
) -> Result<(), DrawingAreaErrorKind<<DB as DrawingBackend>::ErrorType>>where
YH: KeyPointHint,
XH: KeyPointHint,
DrawFunc: FnMut(&mut DB, MeshLine<'_, X, Y>) -> Result<(), DrawingErrorKind<<DB as DrawingBackend>::ErrorType>>,
Draw the mesh on a area
sourcepub fn get_x_range(&self) -> Range<<X as Ranged>::ValueType>
pub fn get_x_range(&self) -> Range<<X as Ranged>::ValueType>
Get the range of X of the guest coordinate for current drawing area
sourcepub fn get_y_range(&self) -> Range<<Y as Ranged>::ValueType>
pub fn get_y_range(&self) -> Range<<Y as Ranged>::ValueType>
Get the range of Y of the guest coordinate for current drawing area
sourcepub fn get_x_axis_pixel_range(&self) -> Range<i32>
pub fn get_x_axis_pixel_range(&self) -> Range<i32>
Get the range of X of the backend coordinate for current drawing area
sourcepub fn get_y_axis_pixel_range(&self) -> Range<i32>
pub fn get_y_axis_pixel_range(&self) -> Range<i32>
Get the range of Y of the backend coordinate for current drawing area
sourcepub fn get_base_pixel(&self) -> (i32, i32)
pub fn get_base_pixel(&self) -> (i32, i32)
Get the left upper conner of this area in the drawing backend
sourcepub fn strip_coord_spec(&self) -> DrawingArea<DB, Shift>
pub fn strip_coord_spec(&self) -> DrawingArea<DB, Shift>
Strip the applied coordinate specification and returns a shift-based drawing area
sourcepub fn use_screen_coord(&self) -> DrawingArea<DB, Shift>
pub fn use_screen_coord(&self) -> DrawingArea<DB, Shift>
Strip the applied coordinate specification and returns a drawing area
sourcepub fn dim_in_pixel(&self) -> (u32, u32)
pub fn dim_in_pixel(&self) -> (u32, u32)
Get the area dimension in pixel
sourcepub fn relative_to_height(&self, p: f64) -> f64
pub fn relative_to_height(&self, p: f64) -> f64
Compute the relative size based on the drawing area’s height
sourcepub fn relative_to_width(&self, p: f64) -> f64
pub fn relative_to_width(&self, p: f64) -> f64
Compute the relative size based on the drawing area’s width
sourcepub fn fill<ColorType>(
&self,
color: &ColorType
) -> Result<(), DrawingAreaErrorKind<<DB as DrawingBackend>::ErrorType>>where
ColorType: Color,
pub fn fill<ColorType>(
&self,
color: &ColorType
) -> Result<(), DrawingAreaErrorKind<<DB as DrawingBackend>::ErrorType>>where
ColorType: Color,
Fill the entire drawing area with a color
sourcepub fn draw_pixel<ColorType>(
&self,
pos: <CT as CoordTranslate>::From,
color: &ColorType
) -> Result<(), DrawingAreaErrorKind<<DB as DrawingBackend>::ErrorType>>where
ColorType: Color,
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
sourcepub fn present(
&self
) -> Result<(), DrawingAreaErrorKind<<DB as DrawingBackend>::ErrorType>>
pub fn present(
&self
) -> Result<(), DrawingAreaErrorKind<<DB as DrawingBackend>::ErrorType>>
Present all the pending changes to the backend
sourcepub fn draw<'a, E, B>(
&self,
element: &'a E
) -> Result<(), DrawingAreaErrorKind<<DB as DrawingBackend>::ErrorType>>where
B: CoordMapper,
E: Drawable<DB, B>,
&'a E: PointCollection<'a, <CT as CoordTranslate>::From, B>,
pub fn draw<'a, E, B>(
&self,
element: &'a E
) -> Result<(), DrawingAreaErrorKind<<DB as DrawingBackend>::ErrorType>>where
B: CoordMapper,
E: Drawable<DB, B>,
&'a E: PointCollection<'a, <CT as CoordTranslate>::From, B>,
Draw an high-level element
sourcepub fn map_coordinate(&self, coord: &<CT as CoordTranslate>::From) -> (i32, i32)
pub fn map_coordinate(&self, coord: &<CT as CoordTranslate>::From) -> (i32, i32)
Map coordinate to the backend coordinate
sourcepub fn estimate_text_size(
&self,
text: &str,
style: &TextStyle<'_>
) -> Result<(u32, u32), DrawingAreaErrorKind<<DB as DrawingBackend>::ErrorType>>
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 estimatefont
: The font spec in which we want to draw the text- return: The size of the text if drawn on this area
sourcepub fn apply_coord_spec<CT>(&self, coord_spec: CT) -> DrawingArea<DB, CT>where
CT: CoordTranslate,
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
sourcepub 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,
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
sourcepub fn split_vertically<S>(
&self,
y: S
) -> (DrawingArea<DB, Shift>, DrawingArea<DB, Shift>)where
S: SizeDesc,
pub fn split_vertically<S>(
&self,
y: S
) -> (DrawingArea<DB, Shift>, DrawingArea<DB, Shift>)where
S: SizeDesc,
Split the drawing area vertically
sourcepub fn split_horizontally<S>(
&self,
x: S
) -> (DrawingArea<DB, Shift>, DrawingArea<DB, Shift>)where
S: SizeDesc,
pub fn split_horizontally<S>(
&self,
x: S
) -> (DrawingArea<DB, Shift>, DrawingArea<DB, Shift>)where
S: SizeDesc,
Split the drawing area horizontally
sourcepub fn split_evenly(&self, (usize, usize)) -> Vec<DrawingArea<DB, Shift>, Global>
pub fn split_evenly(&self, (usize, usize)) -> Vec<DrawingArea<DB, Shift>, Global>
Split the drawing area evenly
sourcepub fn split_by_breakpoints<XSize, YSize, XS, YS>(
&self,
xs: XS,
ys: YS
) -> Vec<DrawingArea<DB, Shift>, Global>where
XSize: SizeDesc,
YSize: SizeDesc,
XS: AsRef<[XSize]>,
YS: AsRef<[YSize]>,
pub fn split_by_breakpoints<XSize, YSize, XS, YS>(
&self,
xs: XS,
ys: YS
) -> Vec<DrawingArea<DB, Shift>, Global>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
sourcepub fn titled<'a, S>(
&self,
text: &str,
style: S
) -> Result<DrawingArea<DB, Shift>, DrawingAreaErrorKind<<DB as DrawingBackend>::ErrorType>>where
S: Into<TextStyle<'a>>,
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
sourcepub fn as_coord_spec(&self) -> &CT
pub fn as_coord_spec(&self) -> &CT
Returns the coordinates by reference
Trait Implementations
sourceimpl<'a> Deref for PlottersDrawingArea<'a>
impl<'a> Deref for PlottersDrawingArea<'a>
type Target = DrawingArea<&'a PlottersBackend, Shift>
type Target = DrawingArea<&'a PlottersBackend, Shift>
The resulting type after dereferencing.
Auto Trait Implementations
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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more