aboutsummaryrefslogtreecommitdiff
path: root/src/math.rs
diff options
context:
space:
mode:
authorArne Dußin2020-10-30 22:32:28 +0100
committerArne Dußin2020-10-30 22:32:28 +0100
commit48c425a193cb13012eb9303df56ac04b9d683ed4 (patch)
treedbc7fc9bd4e595bd8438d4233c08fe3775c5c690 /src/math.rs
parent20c73199167ce3ef1b4a256db5a95acab8f467b3 (diff)
downloadgraf_karto-48c425a193cb13012eb9303df56ac04b9d683ed4.tar.gz
graf_karto-48c425a193cb13012eb9303df56ac04b9d683ed4.zip
Rewrite project to use raylib instead of piston
Sorry piston.. I really tried liking you, but I just couldn't :/ It's not you, it's me. What am I saying? It's you, sorry not sorry.
Diffstat (limited to 'src/math.rs')
-rw-r--r--src/math.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/math.rs b/src/math.rs
new file mode 100644
index 0000000..c4e7ac0
--- /dev/null
+++ b/src/math.rs
@@ -0,0 +1,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,
+ }
+}