[−][src]Module rmicrobit::graphics::scrolling
Support for scrolling sequences of 5×5 images horizontally.
Each kind of scrolling sequence is represented by a type implementing
Animate
(for controlling the sequence) and Render
(for displaying
it).
To create a new kind of scrolling sequence, make a new implementation of
Scrollable
.
The ScrollingImages
implementation can be used for static slices of
any type implementing Render
.
See scrolling_text
for scrolling text strings.
Example
ⓘThis example is not tested
use rmicrobit::prelude::*; use rmicrobit::display::{MicrobitDisplay, MicrobitFrame}; use rmicrobit::graphics::scrolling::ScrollingImages; const BLANK: BitImage = BitImage::blank(); const HEART: BitImage = BitImage::new(&[ [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], ]); let mut display = MicrobitDisplay::new(...); let mut scroller = ScrollingImages::default(); let frame = MicrobitFrame::default(); scroller.set_images(&[&HEART, &BLANK, &HEART]); while !scroller.is_finished() { // every 50ms or so scroller.tick(); frame.set(scroller); display.set_frame(frame); }
See examples/scroll_images.rs for a complete example.
Structs
ScrollingImages | A |
ScrollingState | Data needed to record the state of a scrolling animation. |
Traits
Animate | The state of an animation. |
Scrollable | A horizontally scrolling sequence of 5×5 images. |