use Origin::ZERO constant

This commit is contained in:
Vinzenz Schroeter 2024-10-16 19:21:45 +02:00
parent 97a994fca2
commit cbadd85f07
9 changed files with 12 additions and 12 deletions

View file

@ -46,6 +46,6 @@ fn main() {
let cp437_grid = Cp437Grid::from(&grid); let cp437_grid = Cp437Grid::from(&grid);
connection connection
.send(Command::Cp437Data(Origin::new(0, 0), cp437_grid)) .send(Command::Cp437Data(Origin::ZERO, cp437_grid))
.expect("sending text failed"); .expect("sending text failed");
} }

View file

@ -19,7 +19,7 @@ fn main() {
pixels.fill(true); pixels.fill(true);
let command = Command::BitmapLinearWin( let command = Command::BitmapLinearWin(
Origin::new(0, 0), Origin::ZERO,
pixels, pixels,
CompressionCode::Uncompressed, CompressionCode::Uncompressed,
); );
@ -33,6 +33,6 @@ fn main() {
} }
connection connection
.send(Command::CharBrightness(Origin::new(0, 0), brightnesses)) .send(Command::CharBrightness(Origin::ZERO, brightnesses))
.expect("send failed"); .expect("send failed");
} }

View file

@ -24,7 +24,7 @@ fn main() {
loop { loop {
let command = Command::BitmapLinearWin( let command = Command::BitmapLinearWin(
Origin::new(0, 0), Origin::ZERO,
field.clone(), field.clone(),
CompressionCode::Lzma, CompressionCode::Lzma,
); );

View file

@ -25,7 +25,7 @@ fn main() {
} }
let command = Command::BitmapLinearWin( let command = Command::BitmapLinearWin(
Origin::new(0, 0), Origin::ZERO,
pixels.clone(), pixels.clone(),
CompressionCode::Lzma, CompressionCode::Lzma,
); );

View file

@ -32,7 +32,7 @@ fn main() {
filled_grid.fill(true); filled_grid.fill(true);
let command = BitmapLinearWin( let command = BitmapLinearWin(
Origin::new(0, 0), Origin::ZERO,
filled_grid, filled_grid,
CompressionCode::Lzma, CompressionCode::Lzma,
); );

View file

@ -114,7 +114,7 @@ pub enum Command {
/// ///
/// // create command to send pixels /// // create command to send pixels
/// let command = Command::BitmapLinearWin( /// let command = Command::BitmapLinearWin(
/// servicepoint::Origin::new(0, 0), /// servicepoint::Origin::ZERO,
/// pixels, /// pixels,
/// CompressionCode::Uncompressed /// CompressionCode::Uncompressed
/// ); /// );
@ -588,7 +588,7 @@ mod tests {
compression, compression,
)); ));
round_trip(Command::BitmapLinearWin( round_trip(Command::BitmapLinearWin(
Origin::new(0, 0), Origin::ZERO,
Bitmap::max_sized(), Bitmap::max_sized(),
compression, compression,
)); ));

View file

@ -6,11 +6,11 @@
/// # use servicepoint::{Command, CompressionCode, Origin, Bitmap}; /// # use servicepoint::{Command, CompressionCode, Origin, Bitmap};
/// // create command without payload compression /// // create command without payload compression
/// # let pixels = Bitmap::max_sized(); /// # let pixels = Bitmap::max_sized();
/// _ = Command::BitmapLinearWin(Origin::new(0, 0), pixels, CompressionCode::Uncompressed); /// _ = Command::BitmapLinearWin(Origin::ZERO, pixels, CompressionCode::Uncompressed);
/// ///
/// // create command with payload compressed with lzma and appropriate header flags /// // create command with payload compressed with lzma and appropriate header flags
/// # let pixels = Bitmap::max_sized(); /// # let pixels = Bitmap::max_sized();
/// _ = Command::BitmapLinearWin(Origin::new(0, 0), pixels, CompressionCode::Lzma); /// _ = Command::BitmapLinearWin(Origin::ZERO, pixels, CompressionCode::Lzma);
/// ``` /// ```
#[repr(u16)] #[repr(u16)]
#[derive(Debug, Clone, Copy, PartialEq)] #[derive(Debug, Clone, Copy, PartialEq)]

View file

@ -26,7 +26,7 @@
//! //!
//! // create command to send pixels //! // create command to send pixels
//! let command = Command::BitmapLinearWin( //! let command = Command::BitmapLinearWin(
//! servicepoint::Origin::new(0, 0), //! servicepoint::Origin::ZERO,
//! pixels, //! pixels,
//! CompressionCode::Uncompressed //! CompressionCode::Uncompressed
//! ); //! );

View file

@ -12,7 +12,7 @@ pub struct Origin<Unit: DisplayUnit> {
} }
impl<Unit: DisplayUnit> Origin<Unit> { impl<Unit: DisplayUnit> Origin<Unit> {
/// Top-left. Equivalent to `Origin::new(0, 0)`. /// Top-left. Equivalent to `Origin::ZERO`.
pub const ZERO: Self = Self { pub const ZERO: Self = Self {
x: 0, x: 0,
y: 0, y: 0,