Struct BouncePattern
pub struct BouncePattern { /* private fields */ }Expand description
A white square bouncing left and right on a background that drifts through the hues.
Motion follows elapsed time rather than a frame count, so
draw returns a consistent picture for any instant. The
square crosses the picture in 1.5 s, the hue cycles every 12 s, and the
pictures are I420. VideoSource::test_bounce
draws it at a fixed rate.
§Examples
use std::time::Duration;
use moq_ext_sources::BouncePattern;
let pattern = BouncePattern::new(moq_video::Size::new(640, 360))?;
let frame = pattern.draw(Duration::from_millis(250))?;
assert_eq!(frame.timestamp.as_micros(), Ok(250_000));Implementations§
§impl BouncePattern
impl BouncePattern
pub fn new(size: Size) -> Result<BouncePattern, Error>
pub fn new(size: Size) -> Result<BouncePattern, Error>
Returns the pattern drawn at size.
§Errors
Fails with Error::InvalidConfig if a dimension of size is zero or
odd, which I420 cannot hold.
pub fn square_left(&self, elapsed: Duration) -> u32
pub fn square_left(&self, elapsed: Duration) -> u32
Returns the left edge of the square elapsed after the start, in pixels.
The square starts at the left edge and bounces between the edges at a constant speed.
Trait Implementations§
§impl Clone for BouncePattern
impl Clone for BouncePattern
§fn clone(&self) -> BouncePattern
fn clone(&self) -> BouncePattern
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for BouncePattern
impl RefUnwindSafe for BouncePattern
impl Send for BouncePattern
impl Sync for BouncePattern
impl Unpin for BouncePattern
impl UnsafeUnpin for BouncePattern
impl UnwindSafe for BouncePattern
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more