cargo fmt
This commit is contained in:
parent
972d713cf1
commit
8307354a58
14 changed files with 293 additions and 100 deletions
|
@ -23,7 +23,14 @@ fn main() {
|
|||
|
||||
loop {
|
||||
connection
|
||||
.send(Command::BitmapLinearWin(Origin::top_left(), field.clone(), CompressionCode::Bzip2).into())
|
||||
.send(
|
||||
Command::BitmapLinearWin(
|
||||
Origin::top_left(),
|
||||
field.clone(),
|
||||
CompressionCode::Bzip2,
|
||||
)
|
||||
.into(),
|
||||
)
|
||||
.expect("could not send");
|
||||
thread::sleep(Duration::from_millis(30));
|
||||
field = iteration(field);
|
||||
|
@ -37,7 +44,10 @@ fn iteration(field: PixelGrid) -> PixelGrid {
|
|||
let old_state = field.get(x, y);
|
||||
let neighbors = count_neighbors(&field, x as i32, y as i32);
|
||||
|
||||
let new_state = matches!((old_state, neighbors), (true, 2) | (true, 3) | (false, 3));
|
||||
let new_state = matches!(
|
||||
(old_state, neighbors),
|
||||
(true, 2) | (true, 3) | (false, 3)
|
||||
);
|
||||
next.set(x, y, new_state);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,10 @@ use std::time::Duration;
|
|||
|
||||
use clap::Parser;
|
||||
|
||||
use servicepoint2::{Command, CompressionCode, Connection, Origin, PIXEL_HEIGHT, PIXEL_WIDTH, PixelGrid};
|
||||
use servicepoint2::{
|
||||
Command, CompressionCode, Connection, Origin, PixelGrid, PIXEL_HEIGHT,
|
||||
PIXEL_WIDTH,
|
||||
};
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
struct Cli {
|
||||
|
@ -24,7 +27,14 @@ fn main() {
|
|||
pixels.set((y + x_offset) % PIXEL_WIDTH as usize, y, true);
|
||||
}
|
||||
connection
|
||||
.send(Command::BitmapLinearWin(Origin::top_left(), pixels.clone(), CompressionCode::Lzma).into())
|
||||
.send(
|
||||
Command::BitmapLinearWin(
|
||||
Origin::top_left(),
|
||||
pixels.clone(),
|
||||
CompressionCode::Lzma,
|
||||
)
|
||||
.into(),
|
||||
)
|
||||
.unwrap();
|
||||
thread::sleep(Duration::from_millis(14));
|
||||
}
|
||||
|
|
|
@ -3,8 +3,11 @@ use std::time::Duration;
|
|||
use clap::Parser;
|
||||
use rand::Rng;
|
||||
|
||||
use servicepoint2::{
|
||||
ByteGrid, CompressionCode, Connection, Origin, PixelGrid, TILE_HEIGHT,
|
||||
TILE_WIDTH,
|
||||
};
|
||||
use servicepoint2::Command::{BitmapLinearWin, Brightness, CharBrightness};
|
||||
use servicepoint2::{ByteGrid, CompressionCode, Connection, Origin, PixelGrid, TILE_HEIGHT, TILE_WIDTH};
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
struct Cli {
|
||||
|
@ -27,9 +30,13 @@ fn main() {
|
|||
if cli.enable_all {
|
||||
let mut filled_grid = PixelGrid::max_sized();
|
||||
filled_grid.fill(true);
|
||||
connection
|
||||
.send(BitmapLinearWin(Origin::top_left(), filled_grid, CompressionCode::Lzma).into())
|
||||
.unwrap();
|
||||
|
||||
let command = BitmapLinearWin(
|
||||
Origin::top_left(),
|
||||
filled_grid,
|
||||
CompressionCode::Lzma,
|
||||
);
|
||||
connection.send(command.into()).expect("send failed");
|
||||
}
|
||||
|
||||
// set all pixels to the same random brightness
|
||||
|
@ -54,7 +61,9 @@ fn main() {
|
|||
}
|
||||
}
|
||||
|
||||
connection.send(CharBrightness(origin, luma).into()).unwrap();
|
||||
connection
|
||||
.send(CharBrightness(origin, luma).into())
|
||||
.unwrap();
|
||||
std::thread::sleep(wait_duration);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,10 @@ use std::time::Duration;
|
|||
|
||||
use clap::Parser;
|
||||
|
||||
use servicepoint2::{BitVec, Command, CompressionCode, Connection, PIXEL_HEIGHT, PIXEL_WIDTH, PixelGrid};
|
||||
use servicepoint2::{
|
||||
BitVec, Command, CompressionCode, Connection, PixelGrid, PIXEL_HEIGHT,
|
||||
PIXEL_WIDTH,
|
||||
};
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
struct Cli {
|
||||
|
@ -34,7 +37,10 @@ fn main() {
|
|||
let bit_vec = BitVec::from(&*pixel_data);
|
||||
|
||||
connection
|
||||
.send(Command::BitmapLinearAnd(0, bit_vec, CompressionCode::Lzma).into())
|
||||
.send(
|
||||
Command::BitmapLinearAnd(0, bit_vec, CompressionCode::Lzma)
|
||||
.into(),
|
||||
)
|
||||
.unwrap();
|
||||
thread::sleep(sleep_duration);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue