Skip to content

Instantly share code, notes, and snippets.

@sebastibe
Last active August 3, 2019 07:59
Show Gist options
  • Save sebastibe/872df83ac328034fdbc4647700dbe756 to your computer and use it in GitHub Desktop.
Save sebastibe/872df83ac328034fdbc4647700dbe756 to your computer and use it in GitHub Desktop.
Some helpers when working with Colors in ClojureScript
;; Hex to RBG (.i.e #63411E -> [99 65 30])
(defn hex->rgb [s]
(->> (subs s 1 7)
(partition 2)
(map clojure.string/join)
(mapv #(js/parseInt % 16))))
(defn hex->rgba [s opacity]
(into [] (conj (hex->rgb s) opacity)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment