summaryrefslogtreecommitdiffstats
path: root/geometry.cpp
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2024-10-02 12:53:54 -0400
committerSam Anthony <sam@samanthony.xyz>2024-10-02 12:53:54 -0400
commit9ade04722dd351c3f42cd98be28fc255043b3030 (patch)
tree3aced80bf9cc9fb4160e2fab1ad7afa2d5b45df9 /geometry.cpp
parent2c54c155c9dc92c62881998c055bce17beddbe4f (diff)
downloadballs-9ade04722dd351c3f42cd98be28fc255043b3030.zip
multiple balls
Diffstat (limited to 'geometry.cpp')
-rw-r--r--geometry.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/geometry.cpp b/geometry.cpp
index ae2c8ae..2bdad8c 100644
--- a/geometry.cpp
+++ b/geometry.cpp
@@ -7,6 +7,12 @@ ptAddVec(Point p, Vector v) {
return p;
}
+Point
+Pt(double x, double y) {
+ Point p = {x, y};
+ return p;
+}
+
Rectangle
insetRect(Rectangle r, double n) {
r.min.x += n;
@@ -15,3 +21,8 @@ insetRect(Rectangle r, double n) {
r.max.y -= n;
return r;
}
+
+Point
+randPtInRect(Rectangle r) {
+ return Pt(randDouble(r.min.x, r.max.x), randDouble(r.min.y, r.max.y));
+}