blob: c4e7ac0272363264160a20adb951ad0a2f5928d2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
use raylib::math::{Rectangle, Vector2};
/// Function to calculate the bounding rectangle that is between two vectors. The order of the
/// vectors is irrelevent for this. As long as they are diagonally opposite of each other, this
/// function will work.
pub fn bounding_rect(pos1: Vector2, pos2: Vector2) -> Rectangle {
let min_x = pos1.x.min(pos2.x);
let min_y = pos1.y.min(pos2.y);
let max_x = pos1.x.max(pos2.x);
let max_y = pos1.y.max(pos2.y);
Rectangle {
x: min_x,
y: min_y,
width: max_x - min_x,
height: max_y - min_y,
}
}
|