pub struct Filter { /* private fields */ }Expand description
A Filter is a set of LEDs that can be obtained via one of Sled’s getter-type methods.
They are particularly useful for scenarios when you have computationally expensive calculations and you want to limit which LEDs those calculations are run on. Once you’ve created a filter, you can save it to Data for use in draw/compute stages. Using this pattern, we can pre-compute important sets at startup and then store them to the driver for later usage.
driver.set_startup_commands(|sled, data| {
let area: Filter = sled.within_dist_from(
5.0, Vec2::new(-0.25, 1.5)
);
data.set("area_of_effect", area);
Ok(())
});
driver.set_draw_commands(|sled, data, _| {
let area_filter = data.get("area_of_effect")?;
sled.modulate_filter(area_filter, |led| {
// expensive computation
});
Ok(())
});Implementations§
Trait Implementations§
Source§impl Extend<u16> for Filter
impl Extend<u16> for Filter
Source§fn extend<T: IntoIterator<Item = u16>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = u16>>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one)Reserves capacity in a collection for the given number of additional elements. Read more
Source§impl FromIterator<u16> for Filter
impl FromIterator<u16> for Filter
Source§impl IntoIterator for &Filter
impl IntoIterator for &Filter
Source§impl IntoIterator for Filter
impl IntoIterator for Filter
impl Eq for Filter
impl StructuralPartialEq for Filter
Auto Trait Implementations§
impl Freeze for Filter
impl RefUnwindSafe for Filter
impl Send for Filter
impl Sync for Filter
impl Unpin for Filter
impl UnwindSafe for Filter
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