File tree Expand file tree Collapse file tree 2 files changed +21
-19
lines changed Expand file tree Collapse file tree 2 files changed +21
-19
lines changed Original file line number Diff line number Diff line change 32
32
33
33
(defn intersected?
34
34
[a-bounds b-bounds]
35
- (let [[a-left a-top a-right a-bottom] a-bounds
36
- [b-left b-top b-right b-bottom] b-bounds]
37
- (not (or (> b-left a-right)
38
- (< b-right a-left)
39
- (> b-top a-bottom)
40
- (< b-bottom a-top)))))
35
+ (when (and a-bounds b-bounds)
36
+ (let [[a-left a-top a-right a-bottom] a-bounds
37
+ [b-left b-top b-right b-bottom] b-bounds]
38
+ (not (or (> b-left a-right)
39
+ (< b-right a-left)
40
+ (> b-top a-bottom)
41
+ (< b-bottom a-top))))))
41
42
42
43
(defn contained?
43
44
[a-bounds b-bounds]
44
- (let [[a-left a-top a-right a-bottom] a-bounds
45
- [b-left b-top b-right b-bottom] b-bounds]
46
- (and (> a-left b-left)
47
- (> a-top b-top)
48
- (< a-right b-right)
49
- (< a-bottom b-bottom))))
45
+ (when (and a-bounds b-bounds)
46
+ (let [[a-left a-top a-right a-bottom] a-bounds
47
+ [b-left b-top b-right b-bottom] b-bounds]
48
+ (and (> a-left b-left)
49
+ (> a-top b-top)
50
+ (< a-right b-right)
51
+ (< a-bottom b-bottom)))))
50
52
51
- (defn contain -point?
53
+ (defn contained -point?
52
54
[[left top right bottom] [x y]]
53
55
(and (<= left x)
54
56
(<= top y)
Original file line number Diff line number Diff line change 22
22
(is (= (bounds/contained? [5 5 10 10 ] [0 0 20 20 ]) true ))
23
23
(is (= (bounds/contained? [0 0 10 10 ] [1 1 10 10 ]) false ))))
24
24
25
- (deftest test-contain -point?
25
+ (deftest test-contained -point?
26
26
(testing " bounds contain point"
27
- (is (= (bounds/contain -point? [0 0 10 10 ] [0 0 ]) true ))
28
- (is (= (bounds/contain -point? [0 0 10 10 ] [5 5 ]) true ))
29
- (is (= (bounds/contain -point? [0 0 10 10 ] [10 10 ]) true ))
30
- (is (= (bounds/contain -point? [0 0 10 10 ] [-5 5 ]) false ))
31
- (is (= (bounds/contain -point? [0 0 10 10 ] [5 -5 ]) false ))))
27
+ (is (= (bounds/contained -point? [0 0 10 10 ] [0 0 ]) true ))
28
+ (is (= (bounds/contained -point? [0 0 10 10 ] [5 5 ]) true ))
29
+ (is (= (bounds/contained -point? [0 0 10 10 ] [10 10 ]) true ))
30
+ (is (= (bounds/contained -point? [0 0 10 10 ] [-5 5 ]) false ))
31
+ (is (= (bounds/contained -point? [0 0 10 10 ] [5 -5 ]) false ))))
32
32
33
33
(deftest test-center
34
34
(testing " center of bounds"
You can’t perform that action at this time.
0 commit comments