[][src]Struct launchy::PaddingCanvas

pub struct PaddingCanvas<C: Canvas> { /* fields omitted */ }

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]

pub fn from(inner: C) -> Self[src]

Wrap the given canvas in a PaddingCanvas

Trait Implementations

impl<C: Canvas> Canvas for PaddingCanvas<C>[src]

impl<C: Canvas> DrawTarget<Rgb888> for PaddingCanvas<C>[src]

type Error = ()

Error type to return when a drawing operation fails. Read more

impl<C: Canvas> Index<Pad> for PaddingCanvas<C>[src]

type Output = Color

The returned type after indexing.

impl<C: Canvas> IndexMut<Pad> for PaddingCanvas<C>[src]

Auto Trait Implementations

impl<C> RefUnwindSafe for PaddingCanvas<C> where
    C: RefUnwindSafe

impl<C> Send for PaddingCanvas<C> where
    C: Send

impl<C> Sync for PaddingCanvas<C> where
    C: Sync

impl<C> Unpin for PaddingCanvas<C> where
    C: Unpin

impl<C> UnwindSafe for PaddingCanvas<C> where
    C: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.