                                      [name (or (options name) no-fn)]))
         applet-state      (merge options
                                  {:state state
-                                  :target target
                                   :looping? looping?
                                   :on-close on-close-fn
                                   :setup-fn setup-fn

        (and (coll? size) (= 2 (count size))) size
        :else (throw (IllegalArgumentException.
                      (str "Invalid size definition:" size ". Was expecting :fullscreen or 2 elements vector: [x-size y-size].")))))

(def ^{:private true} VALID-TARGETS #{:frame :perm-frame})

(defn- validate-target!
  "Checks that the target option is one of the following allowed
  targets: [:frame, :perm-frame]."
  [target]
  (when-not (some VALID-TARGETS [target])
    (throw (IllegalArgumentException. (str "Invalid target:" target". Was expecting one of: " (vec VALID-TARGETS)))))
  target)

(defn- to-method-name [keyword]
  "Converts keyword to java-style method symbol. :on-key-pressed => onKeyPressed"

                                 listeners)
        prx-obj           (quil.Applet. applet-state)]
    (doto prx-obj
      (applet-run title renderer)
      (attach-applet-listeners))))

(def ^{:private true}
