pub struct Scroll(/* private fields */);Expand description
A type representing a collection of PixelFrames that may be scrolled.
Implementations§
Source§impl Scroll
impl Scroll
Sourcepub fn new(frames: &[PixelFrame]) -> Self
pub fn new(frames: &[PixelFrame]) -> Self
Creates a new scroll from a slice of PixelFrames.
§Panics
The scroll needs at least 2 PixelFrames to be created.
Examples found in repository?
examples/scroll-bottom-top.rs (line 26)
13fn main() {
14 // Connect to our LED Matrix screen.
15 let mut screen = Screen::open("/dev/fb1").unwrap();
16
17 // Get the default `FontCollection`.
18 let fonts = FontCollection::new();
19 // Create a sanitized `FontString`.
20 let sanitized = fonts.sanitize_str(" ^^^123^^^ ").unwrap();
21 // Render the `FontString` as a vector of pixel frames, with
22 // a stroke color of CYAN and a BLACK background.
23 let pixel_frames = sanitized.pixel_frames(PixelColor::CYAN, PixelColor::BLACK);
24
25 // Create a `Scroll` from the pixel frame vector.
26 let scroll = Scroll::new(&pixel_frames);
27
28 // Consume the `FrameSequence` returned by the `bottom_to_top` method.
29 scroll.bottom_to_top().for_each(|frame| {
30 println!("Now printing:");
31 println!("{:?}", frame);
32 screen.write_frame(&frame.frame_line());
33 ::std::thread::sleep(::std::time::Duration::from_millis(250));
34 });
35}More examples
examples/scroll-left-right.rs (line 26)
13fn main() {
14 // Connect to our LED Matrix screen.
15 let mut screen = Screen::open("/dev/fb1").unwrap();
16
17 // Get the default `FontCollection`.
18 let fonts = FontCollection::new();
19 // Create a sanitized `FontString`.
20 let sanitized = fonts.sanitize_str(" >>>123>>> ").unwrap();
21 // Render the `FontString` as a vector of pixel frames, with
22 // a stroke color of YELLOW and a BLACK background.
23 let pixel_frames = sanitized.pixel_frames(PixelColor::YELLOW, PixelColor::BLACK);
24
25 // Create a `Scroll` from the pixel frame vector.
26 let scroll = Scroll::new(&pixel_frames);
27
28 // Consume the `FrameSequence` returned by the `left_to_right` method.
29 scroll.left_to_right().for_each(|frame| {
30 println!("Now printing:");
31 println!("{:?}", frame);
32 screen.write_frame(&frame.frame_line());
33 ::std::thread::sleep(::std::time::Duration::from_millis(250));
34 });
35}examples/scroll-top-bottom.rs (line 26)
13fn main() {
14 // Connect to our LED Matrix screen.
15 let mut screen = Screen::open("/dev/fb1").unwrap();
16
17 // Get the default `FontCollection`.
18 let fonts = FontCollection::new();
19 // Create a sanitized `FontString`.
20 let sanitized = fonts.sanitize_str(" vvv123vvv ").unwrap();
21 // Render the `FontString` as a vector of pixel frames, with
22 // a stroke color of YELLOW and a BLACK background.
23 let pixel_frames = sanitized.pixel_frames(PixelColor::YELLOW, PixelColor::BLACK);
24
25 // Create a `Scroll` from the pixel frame vector.
26 let scroll = Scroll::new(&pixel_frames);
27
28 // Consume the `FrameSequence` returned by the `top_to_bottom` method.
29 scroll.top_to_bottom().for_each(|frame| {
30 println!("Now printing:");
31 println!("{:?}", frame);
32 screen.write_frame(&frame.frame_line());
33 ::std::thread::sleep(::std::time::Duration::from_millis(250));
34 });
35}examples/scroll-right-left.rs (line 26)
13fn main() {
14 // Connect to our LED Matrix screen.
15 let mut screen = Screen::open("/dev/fb1").unwrap();
16
17 // Get the default `FontCollection`.
18 let fonts = FontCollection::new();
19 // Create a sanitized `FontString`.
20 let sanitized = fonts.sanitize_str(" «««123««« ").unwrap();
21 // Render the `FontString` as a vector of pixel frames, with
22 // a stroke color of GREEN and a BLACK background.
23 let pixel_frames = sanitized.pixel_frames(PixelColor::GREEN, PixelColor::BLACK);
24
25 // Create a `Scroll` from the pixel frame vector.
26 let scroll = Scroll::new(&pixel_frames);
27
28 // Consume the `FrameSequence` returned by the `right_to_left` method.
29 scroll.right_to_left().for_each(|frame| {
30 println!("Now printing:");
31 println!("{:?}", frame);
32 screen.write_frame(&frame.frame_line());
33 ::std::thread::sleep(::std::time::Duration::from_millis(250));
34 });
35}Sourcepub fn frames(&self) -> &[PixelFrame]
pub fn frames(&self) -> &[PixelFrame]
Returns &[PixelFrame] with the pixel frames that constitute this scroll.
Sourcepub fn clips(&self) -> Vec<Clip>
pub fn clips(&self) -> Vec<Clip>
Returns Vec<Clip> with the pixel frames clips that may be rendered.
Sourcepub fn right_to_left(&self) -> FrameSequence ⓘ
pub fn right_to_left(&self) -> FrameSequence ⓘ
Returns a FrameSequence iterator that moves the frames from the right to the left.
Examples found in repository?
examples/scroll-right-left.rs (line 29)
13fn main() {
14 // Connect to our LED Matrix screen.
15 let mut screen = Screen::open("/dev/fb1").unwrap();
16
17 // Get the default `FontCollection`.
18 let fonts = FontCollection::new();
19 // Create a sanitized `FontString`.
20 let sanitized = fonts.sanitize_str(" «««123««« ").unwrap();
21 // Render the `FontString` as a vector of pixel frames, with
22 // a stroke color of GREEN and a BLACK background.
23 let pixel_frames = sanitized.pixel_frames(PixelColor::GREEN, PixelColor::BLACK);
24
25 // Create a `Scroll` from the pixel frame vector.
26 let scroll = Scroll::new(&pixel_frames);
27
28 // Consume the `FrameSequence` returned by the `right_to_left` method.
29 scroll.right_to_left().for_each(|frame| {
30 println!("Now printing:");
31 println!("{:?}", frame);
32 screen.write_frame(&frame.frame_line());
33 ::std::thread::sleep(::std::time::Duration::from_millis(250));
34 });
35}Sourcepub fn left_to_right(&self) -> FrameSequence ⓘ
pub fn left_to_right(&self) -> FrameSequence ⓘ
Returns a FrameSequence iterator that moves the frames from the left to the right.
Examples found in repository?
examples/scroll-left-right.rs (line 29)
13fn main() {
14 // Connect to our LED Matrix screen.
15 let mut screen = Screen::open("/dev/fb1").unwrap();
16
17 // Get the default `FontCollection`.
18 let fonts = FontCollection::new();
19 // Create a sanitized `FontString`.
20 let sanitized = fonts.sanitize_str(" >>>123>>> ").unwrap();
21 // Render the `FontString` as a vector of pixel frames, with
22 // a stroke color of YELLOW and a BLACK background.
23 let pixel_frames = sanitized.pixel_frames(PixelColor::YELLOW, PixelColor::BLACK);
24
25 // Create a `Scroll` from the pixel frame vector.
26 let scroll = Scroll::new(&pixel_frames);
27
28 // Consume the `FrameSequence` returned by the `left_to_right` method.
29 scroll.left_to_right().for_each(|frame| {
30 println!("Now printing:");
31 println!("{:?}", frame);
32 screen.write_frame(&frame.frame_line());
33 ::std::thread::sleep(::std::time::Duration::from_millis(250));
34 });
35}Sourcepub fn top_to_bottom(&self) -> FrameSequence ⓘ
pub fn top_to_bottom(&self) -> FrameSequence ⓘ
Returns a FrameSequence iterator that moves the frames from the top to the bottom.
Examples found in repository?
examples/scroll-top-bottom.rs (line 29)
13fn main() {
14 // Connect to our LED Matrix screen.
15 let mut screen = Screen::open("/dev/fb1").unwrap();
16
17 // Get the default `FontCollection`.
18 let fonts = FontCollection::new();
19 // Create a sanitized `FontString`.
20 let sanitized = fonts.sanitize_str(" vvv123vvv ").unwrap();
21 // Render the `FontString` as a vector of pixel frames, with
22 // a stroke color of YELLOW and a BLACK background.
23 let pixel_frames = sanitized.pixel_frames(PixelColor::YELLOW, PixelColor::BLACK);
24
25 // Create a `Scroll` from the pixel frame vector.
26 let scroll = Scroll::new(&pixel_frames);
27
28 // Consume the `FrameSequence` returned by the `top_to_bottom` method.
29 scroll.top_to_bottom().for_each(|frame| {
30 println!("Now printing:");
31 println!("{:?}", frame);
32 screen.write_frame(&frame.frame_line());
33 ::std::thread::sleep(::std::time::Duration::from_millis(250));
34 });
35}Sourcepub fn bottom_to_top(&self) -> FrameSequence ⓘ
pub fn bottom_to_top(&self) -> FrameSequence ⓘ
Returns a FrameSequence iterator that moves the frames from the bottom to the bottom.
Examples found in repository?
examples/scroll-bottom-top.rs (line 29)
13fn main() {
14 // Connect to our LED Matrix screen.
15 let mut screen = Screen::open("/dev/fb1").unwrap();
16
17 // Get the default `FontCollection`.
18 let fonts = FontCollection::new();
19 // Create a sanitized `FontString`.
20 let sanitized = fonts.sanitize_str(" ^^^123^^^ ").unwrap();
21 // Render the `FontString` as a vector of pixel frames, with
22 // a stroke color of CYAN and a BLACK background.
23 let pixel_frames = sanitized.pixel_frames(PixelColor::CYAN, PixelColor::BLACK);
24
25 // Create a `Scroll` from the pixel frame vector.
26 let scroll = Scroll::new(&pixel_frames);
27
28 // Consume the `FrameSequence` returned by the `bottom_to_top` method.
29 scroll.bottom_to_top().for_each(|frame| {
30 println!("Now printing:");
31 println!("{:?}", frame);
32 screen.write_frame(&frame.frame_line());
33 ::std::thread::sleep(::std::time::Duration::from_millis(250));
34 });
35}Trait Implementations§
impl StructuralPartialEq for Scroll
Auto Trait Implementations§
impl Freeze for Scroll
impl RefUnwindSafe for Scroll
impl Send for Scroll
impl Sync for Scroll
impl Unpin for Scroll
impl UnwindSafe for Scroll
Blanket Implementations§
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