Struct rten_imageproc::Painter
source · pub struct Painter<'a, T> { /* private fields */ }
Expand description
Painter is a context for drawing into an image tensor.
Painter uses a mutable tensor with [channel, height, width]
dimensions as
the drawing surface. It has a current drawing state with properties such as
stroke color and width and allows states to be saved to and restored from
a stack.
Drawing currently operates in the first 3 channels of the surface, which are assumed to represent red, green and blue colors.
Implementations§
source§impl<'a, T: Copy + Default> Painter<'a, T>
impl<'a, T: Copy + Default> Painter<'a, T>
sourcepub fn new(surface: NdTensorViewMut<'a, T, 3>) -> Painter<'a, T>
pub fn new(surface: NdTensorViewMut<'a, T, 3>) -> Painter<'a, T>
Create a Painter which draws into the CHW tensor surface
.
sourcepub fn restore(&mut self)
pub fn restore(&mut self)
Pop and apply a drawing style from the stack created with Painter::save.
sourcepub fn with_save<F: Fn(&mut Self)>(&mut self, f: F)
pub fn with_save<F: Fn(&mut Self)>(&mut self, f: F)
Save the current drawing style, run f(self)
and then restore the saved
style.
This avoids the need to manually save and restore state with Painter::save and Painter::restore.
sourcepub fn set_stroke(&mut self, stroke: Rgb<T>)
pub fn set_stroke(&mut self, stroke: Rgb<T>)
Set the RGB color values used by the draw_*
methods.
pub fn set_stroke_width(&mut self, width: u32)
sourcepub fn draw_polygon(&mut self, points: &[Point])
pub fn draw_polygon(&mut self, points: &[Point])
Draw a polygon into the surface.