Skip to content

Commit

Permalink
docs(README): updated; fix: cosmetics
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeromos Kovacs committed Sep 28, 2024
1 parent 5d20f0d commit 3dd4092
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ clone the repo and run `cargo r`
- [x] error handling
- [x] publishing to crates.io
- [x] changing to `Canvas` for rendering viewer block

## Warning!

If your terminal is messed up by accident fix: on Mac, Linux: `reset`, on Windows: exit the app.
- [ ] *maybe* the ability to parse `.cells` files

## Acknowledgements

The core of this app is adapted from the great [Rust-Wasm tutorial](https://rustwasm.github.io/docs/book/).
- The core of this app is adapted from the [Rust-Wasm tutorial](https://rustwasm.github.io/docs/book/).
- main dependencies:
- ratatui: ui
- crossterm: ratatui backend

## License

Expand Down
9 changes: 7 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,13 @@ impl Universe {
};
Universe { area, cells }
}

fn from_str(s: &str) -> Self {
let v = s.trim().lines().map(|l| l.into()).collect::<Vec<String>>();
let v = s
.trim()
.lines()
.map(std::convert::Into::into)
.collect::<Vec<String>>();
Self::from_vec_str(&v)
}

Expand All @@ -231,7 +236,7 @@ impl Universe {
}

let cells = vec![Cell::default(); area.len()];
let mut univ = Universe { cells, area };
let mut univ = Universe { area, cells };

let (start_row, start_col) = (
(area.height - figur.height()) / 2,
Expand Down
9 changes: 4 additions & 5 deletions src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ pub fn ui(f: &mut Frame, app: &mut App) {
.border_type(BorderType::Rounded)
.title("Conway's Game of Life");
// 2 blocks less: border
let new_area: crate::Area = (
chunks[0].width * BRAILLE.width - 2 * BRAILLE.width,
chunks[0].height * BRAILLE.height - 2 * BRAILLE.height,
)
.into();
let new_area = Area::new(
(chunks[0].width - 2) * BRAILLE.width,
(chunks[0].height - 2) * BRAILLE.height,
);
// apply the area change
if app.area != new_area {
app.area = new_area;
Expand Down

0 comments on commit 3dd4092

Please sign in to comment.