 (ns org.playasophy.wonderdome.mode.rainbow
   (:require
-    [org.playasophy.wonderdome.geometry.sphere :as sphere]
     [org.playasophy.wonderdome.mode.core :as mode]
-    [org.playasophy.wonderdome.util.color :as color]))
-
-
-(def ^:private ^:const move-rate
-  "Rate at which the angles change in radians per millisecond."
-  0.0005)
+    [org.playasophy.wonderdome.util.color :as color]
+    [org.playasophy.wonderdome.util.control :as control]))
 
 
 (defrecord RainbowMode
-  [polar azimuth scale speed offset]
+  [scale speed offset]
 
   mode/Mode
 


  (render
    [this pixel]
    (let [angle (sphere/angle-offset (:sphere pixel) [0 polar azimuth])
          index (* scale (- angle offset))]
      (color/rainbow index))))


(defn rainbow
  "Creates a new rainbow color-cycling mode."
  []
  (RainbowMode. 0.0 0.0 1.0 1.0 0.0))

            offset' (if (> offset' 1.0) (- offset' 1.0) offset')]
        (assoc this :offset offset'))

      [:button/repeat :x-axis]
      (assoc this :scale
             (control/adjust scale event
                             :rate 0.5
                             :min-val 0.1
                             :max-val 5.0))

      [:button/repeat :y-axis]
      (assoc this :speed
             (control/adjust speed event
                             :rate 0.5
                             :min-val -3.0
                             :max-val  3.0))

      ; default
      this))
