[−][src]Struct launchy::PaddingCanvas
A canvas wrapper that fills holes and other irregularities to provide a perfectly rectangular grid.
Launchpads traditionally have non-rectangular shapes:
- Most Launchpads are almost 9x9 - just one pixel is missing
- The Launchpad Pro is almost 10x10, except each corner has a pixel missing
- The Launch Control has an even more irregular placement if the four control buttons are included
Or, even worse, when having a multi-Launchpad setup using CanvasLayout - that's even less rectangular; there will be gaps and empty spaces all over the place.
Sometimes it's a pain to deal with those irregular shapes. For that reason, this struct provides
a Canvas
wrapper that inserts 'virtual pixels' into all the gaps so that you can work with the
Launchpad as if it were a perfectly rectangular grid.
Example:
// Create the base canvas let mut canvas = launchy::mk2::Canvas::guess(|msg| {}); // Wrap the holey canvas in `PaddingCanvas` let mut canvas = launchy::PaddingCanvas::from(canvas); // Now you can fearlessly work with the canvas as if it's a rectangle for y in 0..9 { for x in 0..9 { canvas.set(x, y, launchy::Color::WHITE); } }
Implementations
impl<C: Canvas> PaddingCanvas<C>
[src]
Trait Implementations
impl<C: Canvas> Canvas for PaddingCanvas<C>
[src]
fn bounding_box_width(&self) -> u32
[src]
fn bounding_box_height(&self) -> u32
[src]
fn lowest_visible_brightness(&self) -> f32
[src]
fn is_valid(&self, x: u32, y: u32) -> bool
[src]
fn get_old_unchecked_ref(&self, x: u32, y: u32) -> &Color
[src]
fn get_new_unchecked_ref(&self, x: u32, y: u32) -> &Color
[src]
fn get_new_unchecked_mut(&mut self, x: u32, y: u32) -> &mut Color
[src]
fn flush(&mut self) -> Result<(), MidiError>
[src]
fn get(&self, pad: Pad) -> Option<Color>
[src]
fn get_old_unchecked(&self, x: u32, y: u32) -> Color
[src]
fn get_new_unchecked(&self, x: u32, y: u32) -> Color
[src]
fn set_unchecked(&mut self, x: u32, y: u32, color: Color)
[src]
fn get_ref(&self, pad: Pad) -> Option<&Color>
[src]
fn get_mut(&mut self, pad: Pad) -> Option<&mut Color>
[src]
fn get_new(&self, pad: Pad) -> Option<Color>
[src]
fn at_new(&self, pad: Pad) -> Color
[src]
#[must_use]fn set(&mut self, pad: Pad, color: Color) -> Option<()>
[src]
fn iter(&self) -> CanvasIterator
[src]
fn toggle(&mut self, pad: Pad, color: Color) -> Option<()>
[src]
fn clear(&mut self) where
Self: Sized,
[src]
Self: Sized,
fn into_padded(self) -> PaddingCanvas<Self> where
Self: Sized,
[src]
Self: Sized,
impl<C: Canvas> DrawTarget<Rgb888> for PaddingCanvas<C>
[src]
type Error = ()
Error type to return when a drawing operation fails. Read more
fn draw_pixel(&mut self, pixel: Pixel<Rgb888>) -> Result<(), ()>
[src]
fn size(&self) -> Size
[src]
fn draw_iter<T>(&mut self, item: T) -> Result<(), Self::Error> where
T: IntoIterator<Item = Pixel<C>>,
[src]
T: IntoIterator<Item = Pixel<C>>,
fn clear(&mut self, color: C) -> Result<(), Self::Error>
[src]
fn draw_line(
&mut self,
item: &Styled<Line, PrimitiveStyle<C>>
) -> Result<(), Self::Error>
[src]
&mut self,
item: &Styled<Line, PrimitiveStyle<C>>
) -> Result<(), Self::Error>
fn draw_triangle(
&mut self,
item: &Styled<Triangle, PrimitiveStyle<C>>
) -> Result<(), Self::Error>
[src]
&mut self,
item: &Styled<Triangle, PrimitiveStyle<C>>
) -> Result<(), Self::Error>
fn draw_rectangle(
&mut self,
item: &Styled<Rectangle, PrimitiveStyle<C>>
) -> Result<(), Self::Error>
[src]
&mut self,
item: &Styled<Rectangle, PrimitiveStyle<C>>
) -> Result<(), Self::Error>
fn draw_circle(
&mut self,
item: &Styled<Circle, PrimitiveStyle<C>>
) -> Result<(), Self::Error>
[src]
&mut self,
item: &Styled<Circle, PrimitiveStyle<C>>
) -> Result<(), Self::Error>
fn draw_image<'b, I>(
&mut self,
item: &'a Image<'b, I, C>
) -> Result<(), Self::Error> where
C: PixelColor + From<<C as PixelColor>::Raw>,
I: ImageDimensions,
&'b I: IntoPixelIter<C>,
[src]
&mut self,
item: &'a Image<'b, I, C>
) -> Result<(), Self::Error> where
C: PixelColor + From<<C as PixelColor>::Raw>,
I: ImageDimensions,
&'b I: IntoPixelIter<C>,
impl<C: Canvas> Index<Pad> for PaddingCanvas<C>
[src]
impl<C: Canvas> IndexMut<Pad> for PaddingCanvas<C>
[src]
Auto Trait Implementations
impl<C> RefUnwindSafe for PaddingCanvas<C> where
C: RefUnwindSafe,
C: RefUnwindSafe,
impl<C> Send for PaddingCanvas<C> where
C: Send,
C: Send,
impl<C> Sync for PaddingCanvas<C> where
C: Sync,
C: Sync,
impl<C> Unpin for PaddingCanvas<C> where
C: Unpin,
C: Unpin,
impl<C> UnwindSafe for PaddingCanvas<C> where
C: UnwindSafe,
C: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,