 
 (defn ^:export on-init []
   (console/info "on-init")
-  ; Create a canvas element inside the "app" div.
+  (let [canvas (dom/createElement "canvas")]
+    (goog.object/set canvas "id" "app-canvas")
+    (goog.object/set canvas "width" 800)
+    (goog.object/set canvas "height" 800)
+    (dom/appendChild (poly/get-body) canvas))
   (setup)
   ;(inspect @state)
   )

        mouse-move (get-in state [:env :mouse-move])
        mouse-x (:client-x mouse-move)
        mouse-y (:client-y mouse-move)
        mouse-pos (str "[" mouse-x ":" mouse-y "]")]
    (set! (.-innerText (app-div))
          (string/join ", " [app-name fps env-time timestamp mouse-pos]))))

(defn on-env-animation-frame [timestamp]
  (render! timestamp @state)
  (get-in @state [:app :rendering?]))

(defn start-rendering! []
  (poly/listen-animation-frame! on-env-animation-frame))

(defn stop-rendering! []
  (swap! state assoc-in [:app :rendering?] false))


;; -----------------------------------------------------------------------------
;; Init/Load/Setup/Teardown

(defn setup []
  (console/info "setup")
  (poly/set-title! (get-in @state [:app :name]))
  (setup-event-channels!)
  (setup-event-subscriptions!)
  (start-rendering!))

(defn teardown []
  (console/info "teardown")
  (stop-rendering!)
  (teardown-event-subscriptions!)
  (teardown-event-channels!))


  (swap! state assoc-in [:env :frames-per-second] fps)
  (get-in @state [:app :measure-fps?]))

(declare start-rendering! stop-rendering!)

(defn on-env-keyboard-key [m]
  (console/info (:poly/keyword m))
  ;(inspect m)
  (condp = (:poly/keyword m)
    :a :>> #(start-rendering!)
    :q :>> #(stop-rendering!)
    nil))

(defn on-env-mouse-move [m]
