Skip to content

Commit

Permalink
refactor: apply clippy suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
orhun committed Jan 14, 2025
1 parent 567c066 commit bc9131f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
11 changes: 5 additions & 6 deletions src/backend/canvas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,28 +83,27 @@ impl CanvasBackend {
);
}

let _ = self.ctx.translate(5 as f64, 5 as f64);
let _ = self.ctx.translate(5_f64, 5_f64);
let xmul = 10.0;
let ymul = 19.0;
for (y, line) in self.buffer.iter().enumerate() {
for (x, cell) in line.iter().enumerate() {
if cell != &self.prev_buffer[y][x] || force_redraw {
let colors = get_cell_color_for_canvas(&cell);
let colors = get_cell_color_for_canvas(cell);

self.ctx.set_fill_style_str(colors.1.as_str());
let _ = self
.ctx
self.ctx
.fill_rect(x as f64 * xmul, y as f64 * ymul, xmul, ymul);

self.ctx.set_fill_style_str(colors.0.as_str());

let _ = self
.ctx
.fill_text(&cell.symbol(), x as f64 * xmul, y as f64 * ymul);
.fill_text(cell.symbol(), x as f64 * xmul, y as f64 * ymul);
}
}
}
let _ = self.ctx.translate(-5 as f64, -5 as f64);
let _ = self.ctx.translate(-5_f64, -5_f64);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ pub(crate) fn get_sized_buffer() -> Vec<Vec<Cell>> {
}

pub(crate) fn get_sized_buffer_from_canvas(canvas: &HtmlCanvasElement) -> Vec<Vec<Cell>> {
let width = canvas.client_width() as u16 / 10 as u16;
let height = canvas.client_height() as u16 / 19 as u16;
let width = canvas.client_width() as u16 / 10_u16;
let height = canvas.client_height() as u16 / 19_u16;
vec![vec![Cell::default(); width as usize]; height as usize]
}

Expand Down

0 comments on commit bc9131f

Please sign in to comment.