Remove usize casts
This commit is contained in:
@@ -4,7 +4,6 @@ use crate::{Material as _, SimSnapshot, SimState};
|
||||
use decorum::R64;
|
||||
use image::{RgbImage, Rgb};
|
||||
use imageproc::{pixelops, drawing};
|
||||
use std::convert::TryInto as _;
|
||||
use std::fs::File;
|
||||
use std::path::PathBuf;
|
||||
use y4m;
|
||||
@@ -56,13 +55,13 @@ trait SimSnapshotRenderExt {
|
||||
|
||||
impl SimSnapshotRenderExt for SimSnapshot {
|
||||
fn to_image(&self) -> RgbImage {
|
||||
let w = self.width().try_into().unwrap();
|
||||
let h = self.height().try_into().unwrap();
|
||||
let w = self.width();
|
||||
let h = self.height();
|
||||
let evec_spacing = 10;
|
||||
let mut image = RgbImage::new(w, h);
|
||||
for y in 0..h {
|
||||
for x in 0..w {
|
||||
let cell = self.get(x as usize, y as usize);
|
||||
let cell = self.get(x, y);
|
||||
let r = scale_signed_to_u8(cell.mat().mz(), 100.0);
|
||||
let b = scale_unsigned_to_u8(cell.mat().conductivity(), 10.0);
|
||||
let g = scale_signed_to_u8(cell.bz(), 1.0e-4);
|
||||
@@ -87,15 +86,15 @@ impl SimSnapshotRenderExt for SimSnapshot {
|
||||
|
||||
fn e_vector(&self, xidx: u32, yidx: u32, size: u32) -> Point {
|
||||
let mut e = Point::default();
|
||||
let w = self.width().try_into().unwrap();
|
||||
let h = self.height().try_into().unwrap();
|
||||
let w = self.width();
|
||||
let h = self.height();
|
||||
let xstart = xidx.min(w);
|
||||
let ystart = yidx.min(h);
|
||||
let xend = (xstart + size).min(w);
|
||||
let yend = (ystart + size).min(h);
|
||||
for y in ystart..yend {
|
||||
for x in xstart..xend {
|
||||
e += self.get(x as usize, y as usize).e();
|
||||
e += self.get(x, y).e();
|
||||
}
|
||||
}
|
||||
let xw = xend - xstart;
|
||||
@@ -240,7 +239,7 @@ impl MultiRenderer {
|
||||
pub fn render(&mut self, state: &SimState) {
|
||||
//let max_width = 1980; //< TODO: make configurable
|
||||
let max_width = 200;
|
||||
let dec = (state.width() as u32 + max_width - 1) / max_width;
|
||||
let dec = (state.width() + max_width - 1) / max_width;
|
||||
let snap = state.snapshot(dec);
|
||||
Renderer::render(self, &snap);
|
||||
}
|
||||
|
Reference in New Issue
Block a user