Add a bunch of .round()
s before conversions
Previously this was leading to inconsistencies when using f32 v.s. f64
This commit is contained in:
@@ -64,7 +64,7 @@ fn im_size(state: &dyn GenericSim, max_w: u32, max_h: u32) -> (u32, u32) {
|
||||
let mut height = width * state.height() / state.width();
|
||||
if height > max_h {
|
||||
let stretch = max_h as f32 / height as f32;
|
||||
width = (width as f32 * stretch) as _;
|
||||
width = (width as f32 * stretch).round() as _;
|
||||
height = max_h;
|
||||
}
|
||||
(width, height)
|
||||
@@ -249,8 +249,8 @@ impl ImageRenderExt for RgbImage {
|
||||
fn draw_field_arrow(&mut self, center: Vec2, rel: Vec2, color: Rgb<u8>, alpha: f32) {
|
||||
let start = (center - rel * 0.5).round();
|
||||
let end = (center + rel * 0.5).round();
|
||||
let i_start = (start.x() as _, start.y() as _);
|
||||
let i_end = (end.x() as _, end.y() as _);
|
||||
let i_start = (start.x().round() as _, start.y().round() as _);
|
||||
let i_end = (end.x().round() as _, end.y().round() as _);
|
||||
let interpolate_with_alpha = |left, right, left_weight| {
|
||||
pixelops::interpolate(left, right, left_weight*alpha)
|
||||
};
|
||||
|
Reference in New Issue
Block a user