summaryrefslogtreecommitdiff
path: root/src/assets/viz/1/quil/middlewares/deprecated_options.cljc
blob: 6ed40d2e1b00c71fb33425a06241e29b992101e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
(ns quil.middlewares.deprecated-options)

(def ^:private deprecated
  {:decor ["2.0" "Try :features [:present] for similar effect"]
   :target ["2.0" "Use :features [:keep-on-top] instead."]
   :safe-draw-fn ["2.0" "Use :features [:no-safe-fns] instead."]})

(defn- check-features-vector [features]
  (let [features (set features)]
    (when (features :no-safe-draw)
      (println "Feature :no-safe-draw was renamed to :no-safe-fns in Quil 2.1."
               "Use :feature [:no-safe-fns] now."))
    (disj features :no-safe-draw)))

(defn deprecated-options
  "Checks if options map contains deprected options and removes them.
  Prints messages how to fix deprecated functions."
  [options]
  (let [options (update-in options [:features] check-features-vector)]
    (->> (for [[name value] options]
           (if-let [[version message] (deprecated name)]
             (do (println name "option was removed in Quil" version "." message)
                 nil)
             [name value]))
         (remove nil?)
         (into {}))))