   ;; Always
   (.clearRect ctx 0 0 SCALE-W SCALE-H)
   (draw! (:background @state) ctx)
-  (draw! (:border @state) ctx)
   ;;
   ;; While playing and game-over
   (when (contains? #{:playing :gameover} (:mode @state))

    (.closePath ctx)
    (.restore ctx)))

(extend-type Rect
  IDrawable
  (draw! [{:keys [color x y width height]} ctx]
    (.save ctx)
    (aset ctx "lineWidth" "0.5")
    (aset ctx "fillStyle" color)
    (aset ctx "strokeStyle" "black")
    (.fillRect ctx x y width height)
    (.strokeRect ctx x y width height)
    (.restore ctx)))

(extend-type Frame
  IDrawable
  (draw! [{:keys [color x y width height frame-width]} ctx]
    (.save ctx)
    (aset ctx "lineWidth" (str frame-width))
    (aset ctx "strokeStyle" color)
    (.strokeRect ctx x y width height)
    (.restore ctx)))

;;-----------------------------------------------------------------------------
;; Moveable Objects

   :ball       (Ball. 400 225 13 3 2 BALL_COLOR false)})

(defonce state
  (atom (merge objects
               {:mode :game-start ;; game-start game-over playing
                :pause? false
                :current-paddle :paddle-1})))
