pub trait Canvas {
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
sourcefn new(desc: CanvasDescriptor) -> Result<Self, DrawError>where
Self: Sized,
fn new(desc: CanvasDescriptor) -> Result<Self, DrawError>where
Self: Sized,
The main constructor.
sourcefn draw_shape(&mut self, desc: ShapeDescriptor<'_>) -> Result<(), DrawError>
fn draw_shape(&mut self, desc: ShapeDescriptor<'_>) -> Result<(), DrawError>
Draws a shape described by a ShapeDescriptor
.
sourcefn draw_line(&mut self, desc: LineDescriptor<'_>) -> Result<(), DrawError>
fn draw_line(&mut self, desc: LineDescriptor<'_>) -> Result<(), DrawError>
Draws a line described by a LineDescriptor
.
sourcefn draw_curve(&mut self, desc: CurveDescriptor<'_>) -> Result<(), DrawError>
fn draw_curve(&mut self, desc: CurveDescriptor<'_>) -> Result<(), DrawError>
Draws a curve described by a CurveDescriptor
.
sourcefn fill_region(&mut self, desc: FillDescriptor) -> Result<(), DrawError>
fn fill_region(&mut self, desc: FillDescriptor) -> Result<(), DrawError>
Draws color in a closed, arbitrary region described by a FillDescriptor
.
sourcefn draw_text(&mut self, desc: TextDescriptor) -> Result<(), DrawError>
fn draw_text(&mut self, desc: TextDescriptor) -> Result<(), DrawError>
Draws text described by a TextDescriptor
.
sourcefn text_size(&mut self, desc: TextDescriptor) -> Result<Size, DrawError>
fn text_size(&mut self, desc: TextDescriptor) -> Result<Size, DrawError>
Returns a Size
representing the extent of the text described by a TextDescriptor
.