Skip to content

Instantly share code, notes, and snippets.

@jackrusher
Last active October 1, 2017 18:53
Show Gist options
  • Save jackrusher/2954bf52f3d454f3f72c4e553475be7f to your computer and use it in GitHub Desktop.
Save jackrusher/2954bf52f3d454f3f72c4e553475be7f to your computer and use it in GitHub Desktop.
(defcell app-state {:red 0 :green 0 :blue 0})
(defn update-state [color]
#(swap! app-state assoc color
(int (* 2.55 (-> % (.-currentTarget) (.-value) js/parseInt)))))
(cell
(html [:div
[:p "red"]
[:input {:type "range" :default-value "0" :on-input (update-state :red)}]
[:p "green"]
[:input {:type "range" :default-value "0" :on-input (update-state :green)}]
[:p "blue"]
[:input {:type "range" :default-value "0" :on-input (update-state :blue)}]
[:div (colorize (rgb (:red @app-state) (:green @app-state) (:blue @app-state))
(square 200))]]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment