Skip to content

Commit add1f52

Browse files
committed
add some docstrings
1 parent 5d7859b commit add1f52

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/renderer/utils/bounds.cljs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
[x1 y1 x2 y2])))
1717

1818
(defn union
19+
"Calculates the bounds that contain an arbitrary set of bounds."
1920
[& bounds]
2021
(concat (apply map min (map #(take 2 %) bounds))
2122
(apply map max (map #(drop 2 %) bounds))))
@@ -26,11 +27,13 @@
2627
(mat/sub [x2 y2] [x1 y1]))
2728

2829
(defn center
30+
"Calculates the center of bounds."
2931
[bounds]
30-
(let [[x1 y1 _x2 _y2] bounds]
31-
(mat/add [x1 y1] (mat/div (->dimensions bounds) 2))))
32+
(mat/add (take 2 bounds)
33+
(mat/div (->dimensions bounds) 2)))
3234

3335
(defn intersect?
36+
"Tests whether the provided set of bounds intersect."
3437
[a-bounds b-bounds]
3538
(when (and a-bounds b-bounds)
3639
(let [[a-left a-top a-right a-bottom] a-bounds
@@ -41,6 +44,7 @@
4144
(< b-bottom a-top))))))
4245

4346
(defn contained?
47+
"Tests whether `bounds-a` fully contain `bounds-b`."
4448
[a-bounds b-bounds]
4549
(when (and a-bounds b-bounds)
4650
(let [[a-left a-top a-right a-bottom] a-bounds
@@ -51,6 +55,7 @@
5155
(< a-bottom b-bottom)))))
5256

5357
(defn contain-point?
58+
"Tests whether the provided bounds contain a point."
5459
[[left top right bottom] [x y]]
5560
(and (<= left x)
5661
(<= top y)

src/renderer/utils/math.cljs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
(mod angle (* 2 Math/PI)))
2323

2424
(defn angle
25+
"Calculates the angle between two points."
2526
[x1 y1 x2 y2]
2627
(-> (Math/atan2 (- y2 y1) (- x2 x1))
2728
normalize-angle

0 commit comments

Comments
 (0)