A clip made of two PixelFrame
s.
In horizontal clips, frames are placed side-by-side, and a Clip
is specified
using either Offset::Right(_)
, or Offset::Left(_)
with the Clip::offset
method.
|---------------|
| Right(8) |
|---------------|
|---------------| |
| Right(7) | |
|---------------| |
|---------------| | |
| Right(6) | | |
|---------------| | |
|---------------| | | |
| Right(5) | | | |
|---------------| | | |
|---------------| | | | |
| Right(4) | | | | |
|---------------| | | | |
|---------------| | | | | |
| Right(3) | | | | | |
|---------------| | | | | |
|---------------| | | | | | |
| Right(2) | | | | | | |
|---------------| | | | | | |
|---------------| | | | | | | |
| Right(1) | | | | | | | |
|---------------| | | | | | | |
|---------------| | | | | | | | |
| Right(0) | | | | | | | | |
|---------------| | | | | | | | |
| | | | | | | | |
|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| <- individual frame COLUMN index
|---------------|---------------|
| frame 1 | frame 2 |
|---------------|---------------|
extern crate sensehat_screen;
use sensehat_screen::{Clip, PixelColor, PixelFrame};
use sensehat_screen::Offset;
fn main() {
let frame_1 = PixelFrame::new(&[PixelColor::YELLOW; 64]);
let frame_2 = PixelFrame::new(&[PixelColor::BLUE; 64]);
let clip = Clip::new(frame_1, frame_2);
assert_eq!(clip.offset(Offset::Right(0)), frame_1);
let offset_2_cols = clip.offset(Offset::Right(2)).as_columns();
let expected_cols = &[
[PixelColor::BLUE; 8],
[PixelColor::BLUE; 8],
[PixelColor::YELLOW; 8],
[PixelColor::YELLOW; 8],
[PixelColor::YELLOW; 8],
[PixelColor::YELLOW; 8],
[PixelColor::YELLOW; 8],
[PixelColor::YELLOW; 8],
];
assert_eq!(&offset_2_cols, expected_cols);
assert_eq!(clip.offset(Offset::Right(8)), frame_2);
}
|---------------|
| Left(0) |
|---------------|
|---------------| |
| Left(1) | |
|---------------| |
|---------------| | |
| Left(2) | | |
|---------------| | |
|---------------| | | |
| Left(3) | | | |
|---------------| | | |
|---------------| | | | |
| Left(4) | | | | |
|---------------| | | | |
|---------------| | | | | |
| Left(5) | | | | | |
|---------------| | | | | |
|---------------| | | | | | |
| Left(6) | | | | | | |
|---------------| | | | | | |
|---------------| | | | | | | |
| Left(7) | | | | | | | |
|---------------| | | | | | | |
|---------------| | | | | | | | |
| Left(8) | | | | | | | | |
|---------------| | | | | | | | |
| | | | | | | | |
|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| <- individual frame COLUMN index
|---------------|---------------|
| frame 2 | frame 1 |
|---------------|---------------|
extern crate sensehat_screen;
use sensehat_screen::{Clip, PixelColor, PixelFrame};
use sensehat_screen::Offset;
fn main() {
let frame_1 = PixelFrame::new(&[PixelColor::YELLOW; 64]);
let frame_2 = PixelFrame::new(&[PixelColor::BLUE; 64]);
let clip = Clip::new(frame_1, frame_2);
assert_eq!(clip.offset(Offset::Left(0)), frame_1);
let offset_4_cols = clip.offset(Offset::Left(4)).as_columns();
let expected_cols = &[
[PixelColor::YELLOW; 8],
[PixelColor::YELLOW; 8],
[PixelColor::YELLOW; 8],
[PixelColor::YELLOW; 8],
[PixelColor::BLUE; 8],
[PixelColor::BLUE; 8],
[PixelColor::BLUE; 8],
[PixelColor::BLUE; 8],
];
assert_eq!(&offset_4_cols, expected_cols);
assert_eq!(clip.offset(Offset::Left(8)), frame_2);
}
In vertical clips, frames are placed above-and-belowe each other, and a Clip
is specified
using either Offset::Bottom(_)
, or Offset::Top(_)
with the Clip::offset
method.
|---------------|
| Bottom(0) |
|---------------|
|---------------| |
| Bottom(1) | |
|---------------| |
|---------------| | |
| Bottom(2) | | |
|---------------| | |
|---------------| | | |
| Bottom(3) | | | |
|---------------| | | |
|---------------| | | | |
| Bottom(4) | | | | |
|---------------| | | | |
|---------------| | | | | |
| Bottom(5) | | | | | |
|---------------| | | | | |
|---------------| | | | | | |
| Bottom(6) | | | | | | |
|---------------| | | | | | |
|---------------| | | | | | | |
| Bottom(7) | | | | | | | |
|---------------| | | | | | | |
|---------------| | | | | | | | |
| Bottom(8) | | | | | | | | |
|---------------| | | | | | | | |
| | | | | | | | |
|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| <- individual frame ROW index
|---------------|---------------|
| frame 2 | frame 1 |
|---------------|---------------|
extern crate sensehat_screen;
use sensehat_screen::{Clip, PixelColor, PixelFrame};
use sensehat_screen::Offset;
fn main() {
let frame_1 = PixelFrame::new(&[PixelColor::MAGENTA; 64]);
let frame_2 = PixelFrame::new(&[PixelColor::WHITE; 64]);
let clip = Clip::new(frame_1, frame_2);
assert_eq!(clip.offset(Offset::Bottom(0)), frame_1);
let offset_2_rows = clip.offset(Offset::Bottom(2)).as_rows();
let expected_rows = &[
[PixelColor::WHITE; 8],
[PixelColor::WHITE; 8],
[PixelColor::MAGENTA; 8],
[PixelColor::MAGENTA; 8],
[PixelColor::MAGENTA; 8],
[PixelColor::MAGENTA; 8],
[PixelColor::MAGENTA; 8],
[PixelColor::MAGENTA; 8],
];
assert_eq!(&offset_2_rows, expected_rows);
assert_eq!(clip.offset(Offset::Bottom(8)), frame_2);
}
|---------------|
| Top(8) |
|---------------|
|---------------| |
| Top(7) | |
|---------------| |
|---------------| | |
| Top(6) | | |
|---------------| | |
|---------------| | | |
| Top(5) | | | |
|---------------| | | |
|---------------| | | | |
| Top(4) | | | | |
|---------------| | | | |
|---------------| | | | | |
| Top(3) | | | | | |
|---------------| | | | | |
|---------------| | | | | | |
| Top(2) | | | | | | |
|---------------| | | | | | |
|---------------| | | | | | | |
| Top(1) | | | | | | | |
|---------------| | | | | | | |
|---------------| | | | | | | | |
| Top(0) | | | | | | | | |
|---------------| | | | | | | | |
| | | | | | | | |
|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| <- individual frame ROW index
|---------------|---------------|
| frame 1 | frame 2 |
|---------------|---------------|
extern crate sensehat_screen;
use sensehat_screen::{Clip, PixelColor, PixelFrame};
use sensehat_screen::Offset;
fn main() {
let frame_1 = PixelFrame::new(&[PixelColor::GREEN; 64]);
let frame_2 = PixelFrame::new(&[PixelColor::BLACK; 64]);
let clip = Clip::new(frame_1, frame_2);
assert_eq!(clip.offset(Offset::Top(0)), frame_1);
let offset_7_rows = clip.offset(Offset::Top(7)).as_rows();
let expected_rows = &[
[PixelColor::GREEN; 8],
[PixelColor::BLACK; 8],
[PixelColor::BLACK; 8],
[PixelColor::BLACK; 8],
[PixelColor::BLACK; 8],
[PixelColor::BLACK; 8],
[PixelColor::BLACK; 8],
[PixelColor::BLACK; 8],
];
assert_eq!(&offset_7_rows, expected_rows);
assert_eq!(clip.offset(Offset::Left(8)), frame_2);
}