Skip to content
Browse files

account for the difference between circles and rectangles

Signed-off-by: Chris Granger <ibdknox@gmail.com>
  • Loading branch information...
1 parent 2d9388e commit bf070226ea1227349bf010fae041bb5bec2c969c @ibdknox committed Sep 25, 2011
Showing with 16 additions and 6 deletions.
  1. +16 −6 src/pinot/draw/geometry.cljs
View
22 src/pinot/draw/geometry.cljs
@@ -22,13 +22,23 @@
;; Bounding functions
;;**************************************************
-(defn bottom-right [{:keys [x y w h]}]
- {:x (+ x (/ w 2))
- :y (+ y (/ h 2))})
+(defn bottom-right [{:keys [x y w h r]}]
+ ;;Account for circles whose x and y represent the center
+ ;;instead of the top left
+ (if r
+ {:x (+ x (/ w 2))
+ :y (+ y (/ h 2))}
+ {:x (+ x w)
+ :y (+ y h)}))
-(defn top-left [{:keys [x y w h]}]
- {:x (- x (/ w 2))
- :y (- y (/ h 2))})
+(defn top-left [{:keys [x y w h r]}]
+ ;;Account for circles whose x and y represent the center
+ ;;instead of the top left
+ (if r
+ {:x (- x (/ w 2))
+ :y (- y (/ h 2))}
+ {:x x
+ :y y}))
(defn in-radius? [origin obj radius]
(let [{:keys [dist]} (distance origin obj)]

0 comments on commit bf07022

Please sign in to comment.
Something went wrong with that request. Please try again.