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>

source

pub fn new(surface: NdTensorViewMut<'a, T, 3>) -> Painter<'a, T>

Create a Painter which draws into the CHW tensor surface.

source

pub fn save(&mut self)

Save the current drawing style on a stack.

source

pub fn restore(&mut self)

Pop and apply a drawing style from the stack created with Painter::save.

source

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.

source

pub fn set_stroke(&mut self, stroke: Rgb<T>)

Set the RGB color values used by the draw_* methods.

source

pub fn set_stroke_width(&mut self, width: u32)

source

pub fn draw_polygon(&mut self, points: &[Point])

Draw a polygon into the surface.

Auto Trait Implementations§

§

impl<'a, T> Freeze for Painter<'a, T>
where T: Freeze,

§

impl<'a, T> RefUnwindSafe for Painter<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> Send for Painter<'a, T>
where T: Send,

§

impl<'a, T> Sync for Painter<'a, T>
where T: Sync,

§

impl<'a, T> Unpin for Painter<'a, T>
where T: Unpin,

§

impl<'a, T> !UnwindSafe for Painter<'a, T>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.