Skip to content

Commit

Permalink
Switched while loop to a while let when reforming the red channel fro…
Browse files Browse the repository at this point in the history
…m raw bytes
  • Loading branch information
erlewa committed Aug 1, 2024
1 parent 8ad02bd commit 12bae36
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
20 changes: 11 additions & 9 deletions heatmap-client/src/canvas/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,17 @@ impl<'a> ApplicationHandler<UserMessage<'static>> for App<'a> {
.into();
let mut red_data: Vec<f32> = Vec::new();

let mut i = 0;
while i < raw_bytes.len() {
red_data.push(f32::from_be_bytes([
raw_bytes[i + 3],
raw_bytes[i + 2],
raw_bytes[i + 1],
raw_bytes[i],
]));
i += 16;
let mut raw_iter = raw_bytes.iter();

while let Ok(raw) = raw_iter.next_chunk::<4>() {
red_data.push(f32::from_le_bytes([*raw[0], *raw[1], *raw[2], *raw[3]]));

match raw_iter.advance_by(4 * 3) {
Ok(_) => {}
Err(_) => {
panic!("Rgba32Float texture was malformed, size not a multiple of 16")
}
}
}

let mut max = 0.0;
Expand Down
3 changes: 3 additions & 0 deletions heatmap-client/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#![feature(let_chains)]
#![feature(iter_next_chunk)]
#![feature(iter_advance_by)]

use canvas::Canvas;
use chrono::NaiveDate;
use leptos::*;
Expand Down

0 comments on commit 12bae36

Please sign in to comment.