[−][src]Trait plotters::drawing::backend::DrawingBackend
The drawing backend trait, which implements the low-level drawing APIs.
This trait has a set of default implementation. And the minimal requirement of
implementing a drawing backend is implementing the draw_pixel
function.
If the drawing backend supports vector graphics, the other drawing APIs should be override by the backend specific implementation. Otherwise, the default implementation will use the pixel-based approach to draw other types of low-level shapes.
Associated Types
Loading content...Required methods
fn get_size(&self) -> (u32, u32)
Get the dimension of the drawing backend in pixels
fn ensure_prepared(&mut self) -> Result<(), DrawingErrorKind<Self::ErrorType>>
Ensure the backend is ready to draw
fn present(&mut self) -> Result<(), DrawingErrorKind<Self::ErrorType>>
Finalize the drawing step and present all the changes.
This is used as the real-time rendering support.
The backend may implement in the following way, when ensure_prepared
is called
it checks if it needs a fresh buffer and present
is called rendering all the
pending changes on the screen.
fn draw_pixel(
&mut self,
point: BackendCoord,
color: &RGBAColor
) -> Result<(), DrawingErrorKind<Self::ErrorType>>
&mut self,
point: BackendCoord,
color: &RGBAColor
) -> Result<(), DrawingErrorKind<Self::ErrorType>>
Draw a pixel on the drawing backend
point
: The backend pixel-based coordinate to drawcolor
: The color of the pixel
Provided methods
fn draw_line<S: BackendStyle>(
&mut self,
from: BackendCoord,
to: BackendCoord,
style: &S
) -> Result<(), DrawingErrorKind<Self::ErrorType>>
&mut self,
from: BackendCoord,
to: BackendCoord,
style: &S
) -> Result<(), DrawingErrorKind<Self::ErrorType>>
Draw a line on the drawing backend
from
: The start point of the lineto
: The end point of the linestyle
: The style of the line
fn draw_rect<S: BackendStyle>(
&mut self,
upper_left: BackendCoord,
bottom_right: BackendCoord,
style: &S,
fill: bool
) -> Result<(), DrawingErrorKind<Self::ErrorType>>
&mut self,
upper_left: BackendCoord,
bottom_right: BackendCoord,
style: &S,
fill: bool
) -> Result<(), DrawingErrorKind<Self::ErrorType>>
Draw a rectangle on the drawing backend
upper_left
: The coordinate of the upper-left corner of the rectbottom_right
: The coordinate of the bottom-right corner of the rectstyle
: The stylefill
: If the rectangle should be filled
fn draw_path<S: BackendStyle, I: IntoIterator<Item = BackendCoord>>(
&mut self,
path: I,
style: &S
) -> Result<(), DrawingErrorKind<Self::ErrorType>>
&mut self,
path: I,
style: &S
) -> Result<(), DrawingErrorKind<Self::ErrorType>>
Draw a path on the drawing backend
path
: The iterator of key points of the pathstyle
: The style of the path
fn draw_circle<S: BackendStyle>(
&mut self,
center: BackendCoord,
radius: u32,
style: &S,
fill: bool
) -> Result<(), DrawingErrorKind<Self::ErrorType>>
&mut self,
center: BackendCoord,
radius: u32,
style: &S,
fill: bool
) -> Result<(), DrawingErrorKind<Self::ErrorType>>
Draw a circle on the drawing backend
center
: The center coordinate of the circleradius
: The radius of the circlestyle
: The style of the shapefill
: If the circle should be filled
fn fill_polygon<S: BackendStyle, I: IntoIterator<Item = BackendCoord>>(
&mut self,
vert: I,
style: &S
) -> Result<(), DrawingErrorKind<Self::ErrorType>>
&mut self,
vert: I,
style: &S
) -> Result<(), DrawingErrorKind<Self::ErrorType>>
fn draw_text(
&mut self,
text: &str,
style: &TextStyle,
pos: BackendCoord
) -> Result<(), DrawingErrorKind<Self::ErrorType>>
&mut self,
text: &str,
style: &TextStyle,
pos: BackendCoord
) -> Result<(), DrawingErrorKind<Self::ErrorType>>
Draw a text on the drawing backend
text
: The text to drawstyle
: The text stylepos
: The text anchor point
fn estimate_text_size<'a>(
&self,
text: &str,
font: &FontDesc<'a>
) -> Result<(u32, u32), DrawingErrorKind<Self::ErrorType>>
&self,
text: &str,
font: &FontDesc<'a>
) -> Result<(u32, u32), DrawingErrorKind<Self::ErrorType>>
Estimate the size of the horizontal text if rendered on this backend. This is important because some of the backend may not have font ability. Thus this allows those backend reports proper value rather than ask the font rasterizer for that.
text
: The text to estimatefont
: The font to estimate- Returns The estimated text size
fn blit_bitmap<'a>(
&mut self,
pos: BackendCoord,
(iw, ih): (u32, u32),
src: &'a [u8]
) -> Result<(), DrawingErrorKind<Self::ErrorType>>
&mut self,
pos: BackendCoord,
(iw, ih): (u32, u32),
src: &'a [u8]
) -> Result<(), DrawingErrorKind<Self::ErrorType>>
Blit a bitmap on to the backend.
text
: pos the left upper conner of the bitmap to blitsrc
: The source of the image
TODO: The default implementation of bitmap blitting assumes that the bitmap is RGB, but this may not be the case. But for bitmap backend it's actually ok if we use the bitmap element that matches the pixel format, but we need to fix this.
Implementors
impl<'a> DrawingBackend for SVGBackend<'a>
[src]
type ErrorType = Error
fn get_size(&self) -> (u32, u32)
[src]
fn ensure_prepared(&mut self) -> Result<(), DrawingErrorKind<Error>>
[src]
fn present(&mut self) -> Result<(), DrawingErrorKind<Error>>
[src]
fn draw_pixel(
&mut self,
point: BackendCoord,
color: &RGBAColor
) -> Result<(), DrawingErrorKind<Error>>
[src]
&mut self,
point: BackendCoord,
color: &RGBAColor
) -> Result<(), DrawingErrorKind<Error>>
fn draw_line<S: BackendStyle>(
&mut self,
from: BackendCoord,
to: BackendCoord,
style: &S
) -> Result<(), DrawingErrorKind<Self::ErrorType>>
[src]
&mut self,
from: BackendCoord,
to: BackendCoord,
style: &S
) -> Result<(), DrawingErrorKind<Self::ErrorType>>
fn draw_rect<S: BackendStyle>(
&mut self,
upper_left: BackendCoord,
bottom_right: BackendCoord,
style: &S,
fill: bool
) -> Result<(), DrawingErrorKind<Self::ErrorType>>
[src]
&mut self,
upper_left: BackendCoord,
bottom_right: BackendCoord,
style: &S,
fill: bool
) -> Result<(), DrawingErrorKind<Self::ErrorType>>
fn draw_path<S: BackendStyle, I: IntoIterator<Item = BackendCoord>>(
&mut self,
path: I,
style: &S
) -> Result<(), DrawingErrorKind<Self::ErrorType>>
[src]
&mut self,
path: I,
style: &S
) -> Result<(), DrawingErrorKind<Self::ErrorType>>
fn fill_polygon<S: BackendStyle, I: IntoIterator<Item = BackendCoord>>(
&mut self,
path: I,
style: &S
) -> Result<(), DrawingErrorKind<Self::ErrorType>>
[src]
&mut self,
path: I,
style: &S
) -> Result<(), DrawingErrorKind<Self::ErrorType>>
fn draw_circle<S: BackendStyle>(
&mut self,
center: BackendCoord,
radius: u32,
style: &S,
fill: bool
) -> Result<(), DrawingErrorKind<Self::ErrorType>>
[src]
&mut self,
center: BackendCoord,
radius: u32,
style: &S,
fill: bool
) -> Result<(), DrawingErrorKind<Self::ErrorType>>
fn draw_text(
&mut self,
text: &str,
style: &TextStyle,
pos: BackendCoord
) -> Result<(), DrawingErrorKind<Self::ErrorType>>
[src]
&mut self,
text: &str,
style: &TextStyle,
pos: BackendCoord
) -> Result<(), DrawingErrorKind<Self::ErrorType>>
fn blit_bitmap<'b>(
&mut self,
pos: BackendCoord,
(w, h): (u32, u32),
src: &'b [u8]
) -> Result<(), DrawingErrorKind<Self::ErrorType>>
[src]
&mut self,
pos: BackendCoord,
(w, h): (u32, u32),
src: &'b [u8]
) -> Result<(), DrawingErrorKind<Self::ErrorType>>
impl<'a, P: PixelFormat> DrawingBackend for BitMapBackend<'a, P>
[src]
type ErrorType = BitMapBackendError
fn get_size(&self) -> (u32, u32)
[src]
fn ensure_prepared(
&mut self
) -> Result<(), DrawingErrorKind<BitMapBackendError>>
[src]
&mut self
) -> Result<(), DrawingErrorKind<BitMapBackendError>>
fn present(&mut self) -> Result<(), DrawingErrorKind<BitMapBackendError>>
[src]
fn draw_pixel(
&mut self,
point: BackendCoord,
color: &RGBAColor
) -> Result<(), DrawingErrorKind<BitMapBackendError>>
[src]
&mut self,
point: BackendCoord,
color: &RGBAColor
) -> Result<(), DrawingErrorKind<BitMapBackendError>>
fn draw_line<S: BackendStyle>(
&mut self,
from: (i32, i32),
to: (i32, i32),
style: &S
) -> Result<(), DrawingErrorKind<Self::ErrorType>>
[src]
&mut self,
from: (i32, i32),
to: (i32, i32),
style: &S
) -> Result<(), DrawingErrorKind<Self::ErrorType>>
fn draw_rect<S: BackendStyle>(
&mut self,
upper_left: (i32, i32),
bottom_right: (i32, i32),
style: &S,
fill: bool
) -> Result<(), DrawingErrorKind<Self::ErrorType>>
[src]
&mut self,
upper_left: (i32, i32),
bottom_right: (i32, i32),
style: &S,
fill: bool
) -> Result<(), DrawingErrorKind<Self::ErrorType>>
fn blit_bitmap<'b>(
&mut self,
pos: BackendCoord,
(sw, sh): (u32, u32),
src: &'b [u8]
) -> Result<(), DrawingErrorKind<Self::ErrorType>>
[src]
&mut self,
pos: BackendCoord,
(sw, sh): (u32, u32),
src: &'b [u8]
) -> Result<(), DrawingErrorKind<Self::ErrorType>>