Add stroke colors into recent colors summary.

This commit is contained in:
Andrey Antukh 2016-01-24 00:52:34 +02:00
parent 3fbe465b99
commit 9e72dbb0a0

View file

@ -26,16 +26,20 @@
#(rs/emit! (dw/toggle-tool :workspace/colorpalette))) #(rs/emit! (dw/toggle-tool :workspace/colorpalette)))
(defn- count-color (defn- count-color
[state shape] [state shape prop]
(let [color (:fill shape)] (let [color (prop shape)]
(if (contains? state color) (if (contains? state color)
(update state color inc) (update state color inc)
(assoc state color 1)))) (assoc state color 1))))
(defn- calculate-colors (defn- calculate-colors
[shapes] [shapes]
(let [result (reduce count-color {} shapes)] (as-> (comp
(take 5 (map first (sort-by second (into [] result)))))) #(count-color %1 %2 :fill)
#(count-color %1 %2 :stroke)) $
(reduce $ {} shapes)
(sort-by second (into [] $))
(take 5 (map first $))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Component ;; Component