 (defn draw-cursor
   "Draws a cursor at the specified coordinate"
   [x y]
-  (draw :cursor x y
-        (fn []
-          (s/line (- cursor-size) 0, cursor-size 0)
-          (s/line 0 (- cursor-size), 0 cursor-size))))
+  (draw-thing :cursor x y
+              (fn []
+                (s/line (- cursor-size) 0, cursor-size 0)
+                (s/line 0 (- cursor-size), 0 cursor-size))))
 
 (def speech-balloon-properties {:offset 10
                                 :point-width 20

  (set-text-box! [:div "x:" [:span.highlight x] ", y:" [:span.highlight y]]))


;; Sketch

(defn draw
  "Lookup and apply styles for named object, translate origin to given coordinate, and draw using supplied function"
  [name x y f]
  (s/push-style)

  (let [p speech-balloon-properties
        balloon-width (+ (s/text-width speech) 40)
        balloon-height (+ (s/text-ascent) (s/text-descent) 40)]
    (draw-thing :speech-balloon x y
                (fn []
                  (s/translate (- (/ balloon-width 2))
                               (- (+ (p :offset) (p :point-height) balloon-height)))
                  
                  (shape [[0 0]
                          [balloon-width 0]
                          [balloon-width balloon-height]
                          [(+ (/ balloon-width 2) (p :point-width)) balloon-height]
                          [(/ balloon-width 2) (+ balloon-height (p :point-height))]
                          [(/ balloon-width 2) balloon-height]
                          [0 balloon-height]])
                  
                  (set-style :words)
                  (s/text speech 20 (+ 20 (s/text-ascent)))))))

(def person-radius 100)
(defn draw-person
  "Draws a person at the specified coordinate"
  [x y]
  (draw-thing :person x y
              (fn []
                (s/ellipse 0 0 person-radius person-radius)
                (draw-speech-balloon "How are you" 0 (- (/ person-radius 2))))))

(def images {})

