                                 (println "Exception in Quil draw-fn for sketch" title ": " e "\nstacktrace: " (with-out-str (print-cause-trace e)))
                                 (Thread/sleep 1000))))
         draw-fn           (if (:safe-draw-fn options) safe-draw-fn draw-fn)
-        on-close-fn       (or (:on-close options) (fn [] nil))
+        on-close-fn       (or (:on-close options) no-fn)
         state             (atom nil)
         target-obj        (atom nil)
         looping?          (atom true)
         listeners         (into {} (for [name listeners]
-                                     [name (or (options name) (fn [] nil))]))
+                                     [name (or (options name) no-fn)]))
         applet-state      (merge options
                                  {:state state
                                   :target-obj target-obj


(generate-listeners)

(defn wrap-mouse-wheel
  "Wraps callback to an instance of java.awt.event.MouseEventListener
  or returns nil if given callback is nil."
  [mouse-wheel applet]
  (when mouse-wheel
    (reify java.awt.event.MouseWheelListener
      (mouseWheelMoved [this e]
        (with-applet applet
          (mouse-wheel (.getWheelRotation e)))))))

(defn applet
  "Create and start a new visualisation applet.

(defonce untitled-applet-id* (atom 0))
(def ^:dynamic *applet* nil)
(def ^:dynamic *graphics* nil)

(defn- no-fn
  "Function that does nothing."
  [])

(defn ^PApplet current-applet []
  *applet*)
