Skip to main content

RecordingPainter

Struct RecordingPainter 

Source
pub struct RecordingPainter {
    pub calls: Vec<PaintCall>,
}
Expand description

A Painter that records its calls in calls.

Fields§

§calls: Vec<PaintCall>

Every call made, in order.

Trait Implementations§

Source§

impl Debug for RecordingPainter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RecordingPainter

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Painter for RecordingPainter

Source§

fn cache_policy(&self) -> CachePolicy

Returns the policy of a recording painter.

§Returns

CachePolicy::DirectDraw, since nothing is cached.

Source§

fn fill(&mut self, color: Color)

Records a fill.

§Arguments
  • color - The fill color.
Source§

fn fill_rect(&mut self, bounds: Rect, color: Color)

Records a rectangle fill.

§Arguments
  • bounds - The rectangle.
  • color - The fill color.
Source§

fn rect(&mut self, bounds: Rect, color: Color)

Records a rectangle outline.

§Arguments
  • bounds - The rectangle.
  • color - The line color.
Source§

fn line(&mut self, from: Point, to: Point, color: Color)

Records a line.

§Arguments
  • from - The start point.
  • to - The end point.
  • color - The line color.
Source§

fn text( &mut self, bounds: Rect, style: &TextStyle, color: Color, msg: &str, ) -> Size

Records text.

§Arguments
  • bounds - The rectangle to draw within.
  • style - The font (its size sets the recorded text height).
  • color - The text color.
  • msg - The text.
§Returns

A deterministic size: half the font size per character wide (at most the width of bounds), one font size tall.

Source§

fn line_height(&mut self, style: &TextStyle) -> u32

Returns the line height: the font size.

§Arguments
  • style - The font.
§Returns

The font size in pixels.

Source§

fn text_width(&mut self, style: &TextStyle, msg: &str) -> u32

Measures text the way text sizes it, without recording a call.

§Arguments
  • style - The font (its size sets the width of each character).
  • msg - The text.
§Returns

Half the font size per character.

Source§

fn image(&mut self, path: &str, bounds: Rect) -> Result<(), Error>

Records an image.

§Arguments
  • path - The image path.
  • bounds - The rectangle.
§Returns

Ok(()), always.

§Errors

Never fails.

Source§

fn dither(&mut self, bounds: Rect, first: Color, second: Color)

Records a dither.

§Arguments
  • bounds - The rectangle.
  • first - The corner pixel color.
  • second - The other color.
Source§

fn dither_overlay(&mut self, bounds: Rect, color: Color)

Records a dither overlay.

§Arguments
  • bounds - The rectangle.
  • color - The color to blend.
Source§

fn clip(&mut self, bounds: Option<Rect>)

Records a clip change.

§Arguments
  • bounds - The clip rectangle, or None.

Auto Trait Implementations§

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>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.