Canvas

Trait Canvas 

Source
pub trait Canvas {
    // Required methods
    fn new(desc: CanvasDescriptor) -> Result<Self, DrawError>
       where Self: Sized;
    fn draw_shape(&mut self, desc: ShapeDescriptor<'_>) -> Result<(), DrawError>;
    fn draw_line(&mut self, desc: LineDescriptor<'_>) -> Result<(), DrawError>;
    fn draw_curve(&mut self, desc: CurveDescriptor<'_>) -> Result<(), DrawError>;
    fn fill_region(&mut self, desc: FillDescriptor) -> Result<(), DrawError>;
    fn draw_text(&mut self, desc: TextDescriptor) -> Result<(), DrawError>;
    fn text_size(&mut self, desc: TextDescriptor) -> Result<Size, DrawError>;
    fn save_file<P: AsRef<Path>>(
        &mut self,
        desc: SaveFileDescriptor<P>,
    ) -> Result<(), DrawError>;
    fn size(&self) -> Result<Size, DrawError>;
}
Expand description

Represents a structure used for drawing.

Required Methods§

Source

fn new(desc: CanvasDescriptor) -> Result<Self, DrawError>
where Self: Sized,

The main constructor.

Source

fn draw_shape(&mut self, desc: ShapeDescriptor<'_>) -> Result<(), DrawError>

Draws a shape described by a ShapeDescriptor.

Source

fn draw_line(&mut self, desc: LineDescriptor<'_>) -> Result<(), DrawError>

Draws a line described by a LineDescriptor.

Source

fn draw_curve(&mut self, desc: CurveDescriptor<'_>) -> Result<(), DrawError>

Draws a curve described by a CurveDescriptor.

Source

fn fill_region(&mut self, desc: FillDescriptor) -> Result<(), DrawError>

Draws color in a closed, arbitrary region described by a FillDescriptor.

Source

fn draw_text(&mut self, desc: TextDescriptor) -> Result<(), DrawError>

Draws text described by a TextDescriptor.

Source

fn text_size(&mut self, desc: TextDescriptor) -> Result<Size, DrawError>

Returns a Size representing the extent of the text described by a TextDescriptor.

Source

fn save_file<P: AsRef<Path>>( &mut self, desc: SaveFileDescriptor<P>, ) -> Result<(), DrawError>

Save the image to a file.

Source

fn size(&self) -> Result<Size, DrawError>

Get canvas size.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§