draw selection bounds independently of zoom

This commit is contained in:
Crispy 2024-12-10 23:11:27 +01:00
parent 9d54c17dcd
commit 6dcb6c9dd7
3 changed files with 10 additions and 12 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 105 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 122 B

After

Width:  |  Height:  |  Size: 99 B

View file

@ -1084,18 +1084,16 @@ impl Editor {
is_selecting: _,
}) = self.active_tool
{
let min = start.min(end);
let max = start.max(end);
let p_min = self.pos_to_screen(min.to_vec());
let p_max = self.pos_to_screen(max.to_vec());
let tex = textures.get("area_corner");
d.draw_texture_ex(tex, p_min, 0., self.zoom, Color::WHITE);
let one_xy = Vector2::new(tile_size as f32, tile_size as f32);
d.draw_texture_ex(tex, p_max + one_xy, 180., self.zoom, Color::WHITE);
let top_right = Vector2::new(p_max.x + tile_size as f32, p_min.y);
d.draw_texture_ex(tex, top_right, 90., self.zoom, Color::WHITE);
let bot_left = Vector2::new(p_min.x, p_max.y + tile_size as f32);
d.draw_texture_ex(tex, bot_left, -90., self.zoom, Color::WHITE);
let p_min = self.pos_to_screen(start.min(end).to_vec());
let p_max = self.pos_to_screen((start.max(end) + (1, 1).into()).to_vec());
let x = p_min.x as i32;
let y = p_min.y as i32;
let width = p_max.x as i32 - x;
let height = p_max.y as i32 - y;
d.draw_rectangle(x, y, width, 4, Color::WHITE);
d.draw_rectangle(x, y + height - 4, width, 4, Color::WHITE);
d.draw_rectangle(x, y, 4, height, Color::WHITE);
d.draw_rectangle(x + width - 4, y, 4, height, Color::WHITE);
}
}
}