reformat with max width

This commit is contained in:
Vinzenz Schroeter 2024-05-11 23:28:08 +02:00
parent 0a3f400e92
commit 362426c758
13 changed files with 225 additions and 122 deletions

View file

@ -1,4 +1,5 @@
use clap::Parser;
use servicepoint2::{ByteGrid, Command, Connection, Origin};
#[derive(Parser, Debug)]
@ -44,5 +45,7 @@ fn main() {
}
}
connection.send(Command::Cp437Data(Origin::top_left(), chars)).unwrap();
connection
.send(Command::Cp437Data(Origin::top_left(), chars))
.unwrap();
}

View file

@ -1,9 +1,11 @@
use std::thread;
use std::time::Duration;
use rand::{distributions, Rng};
use clap::Parser;
use servicepoint2::{Connection, Origin, PixelGrid};
use rand::{distributions, Rng};
use servicepoint2::Command::BitmapLinearWin;
use servicepoint2::{Connection, Origin, PixelGrid};
#[derive(Parser, Debug)]
struct Cli {
@ -23,7 +25,9 @@ fn main() {
let mut field = make_random_field(cli.probability);
loop {
connection.send(BitmapLinearWin(Origin::top_left(), field.clone())).expect("could not send");
connection
.send(BitmapLinearWin(Origin::top_left(), field.clone()))
.expect("could not send");
thread::sleep(Duration::from_millis(14));
field = iteration(field);
}
@ -39,7 +43,7 @@ fn iteration(field: PixelGrid) -> PixelGrid {
(true, 2) => true,
(true, 3) => true,
(false, 3) => true,
_ => false
_ => false,
};
next.set(x, y, new_state);
}
@ -55,7 +59,11 @@ fn count_neighbors(field: &PixelGrid, x: i32, y: i32) -> i32 {
continue; // the cell itself does not count
}
if nx < 0 || ny < 0 || nx >= field.width as i32 || ny >= field.height as i32 {
if nx < 0
|| ny < 0
|| nx >= field.width as i32
|| ny >= field.height as i32
{
continue; // pixels outside the grid do not count
}

View file

@ -1,8 +1,10 @@
use std::thread;
use std::time::Duration;
use clap::Parser;
use servicepoint2::{Connection, Origin, PIXEL_HEIGHT, PIXEL_WIDTH, PixelGrid};
use servicepoint2::Command::BitmapLinearWin;
use servicepoint2::{Connection, Origin, PixelGrid, PIXEL_HEIGHT, PIXEL_WIDTH};
#[derive(Parser, Debug)]
struct Cli {
@ -24,7 +26,9 @@ fn main() {
for y in 0..PIXEL_HEIGHT as usize {
pixels.set((y + x_offset) % PIXEL_WIDTH as usize, y, true);
}
connection.send(BitmapLinearWin(Origin::top_left(), pixels.clone())).unwrap();
connection
.send(BitmapLinearWin(Origin::top_left(), pixels.clone()))
.unwrap();
thread::sleep(Duration::from_millis(14));
}
}

View file

@ -1,8 +1,12 @@
use std::time::Duration;
use clap::Parser;
use rand::Rng;
use servicepoint2::{ByteGrid, Connection, Origin, PixelGrid, TILE_HEIGHT, TILE_WIDTH};
use servicepoint2::Command::{Brightness, CharBrightness, BitmapLinearWin};
use servicepoint2::Command::{BitmapLinearWin, Brightness, CharBrightness};
use servicepoint2::{
ByteGrid, Connection, Origin, PixelGrid, TILE_HEIGHT, TILE_WIDTH,
};
#[derive(Parser, Debug)]
struct Cli {
@ -27,7 +31,9 @@ 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)).unwrap();
connection
.send(BitmapLinearWin(Origin::top_left(), filled_grid))
.unwrap();
}
// set all pixels to the same random brightness

View file

@ -3,8 +3,10 @@ use std::time::Duration;
use clap::Parser;
use servicepoint2::{BitVec, CompressionCode, Connection, PIXEL_HEIGHT, PIXEL_WIDTH, PixelGrid};
use servicepoint2::Command::BitmapLinearAnd;
use servicepoint2::{
BitVec, CompressionCode, Connection, PixelGrid, PIXEL_HEIGHT, PIXEL_WIDTH,
};
#[derive(Parser, Debug)]
struct Cli {
@ -21,7 +23,8 @@ fn main() {
let connection = Connection::open(cli.destination).unwrap();
let sleep_duration = Duration::from_millis(cli.time / PIXEL_WIDTH as u64);
let mut enabled_pixels = PixelGrid::new(PIXEL_WIDTH as usize, PIXEL_HEIGHT as usize);
let mut enabled_pixels =
PixelGrid::new(PIXEL_WIDTH as usize, PIXEL_HEIGHT as usize);
enabled_pixels.fill(true);
for x_offset in 0..PIXEL_WIDTH as usize {
@ -33,7 +36,9 @@ fn main() {
let pixel_data: Vec<u8> = enabled_pixels.clone().into();
let bit_vec = BitVec::load(&*pixel_data);
connection.send(BitmapLinearAnd(0, bit_vec, CompressionCode::Gz)).unwrap();
connection
.send(BitmapLinearAnd(0, bit_vec, CompressionCode::Gz))
.unwrap();
thread::sleep(sleep_duration);
}
}