add new compression commands to BitmapLinearWin

This commit is contained in:
Vinzenz Schroeter 2024-05-16 23:03:07 +02:00
parent 6834bb084b
commit da4df32878
8 changed files with 84 additions and 60 deletions

View file

@ -4,7 +4,7 @@ use std::time::Duration;
use clap::Parser;
use rand::{distributions, Rng};
use servicepoint2::{Command, Connection, Origin, PixelGrid};
use servicepoint2::{Command, CompressionCode, Connection, Origin, PixelGrid};
#[derive(Parser, Debug)]
struct Cli {
@ -23,7 +23,7 @@ fn main() {
loop {
connection
.send(Command::BitmapLinearWin(Origin::top_left(), field.clone()).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);
@ -36,6 +36,7 @@ fn iteration(field: PixelGrid) -> PixelGrid {
for y in 0..field.height {
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));
next.set(x, y, new_state);
}